lördag 5 oktober 2013

Howto: Install systemd in gentoo linux

This is how i installed Systemd in gentoo linux.

http://www.freedesktop.org/wiki/Software/systemd/
http://wiki.gentoo.org/wiki/Systemd
https://wiki.archlinux.org/index.php/Systemd
https://dornea.nu/blog/2013/08/gentoo-systemd-consolekit-udev-and-some-failed-system-update
https://wiki.archlinux.org/index.php/Improve_Boot_Performance


Most up to date Systemd  REQUIREMENTS:
http://cgit.freedesktop.org/systemd/systemd/tree/README#n36

REQUIREMENTS:
        Linux kernel >= 3.0
          CONFIG_DEVTMPFS
          CONFIG_CGROUPS (it's OK to disable all controllers)
          CONFIG_INOTIFY_USER
          CONFIG_SIGNALFD
          CONFIG_TIMERFD
          CONFIG_EPOLL
          CONFIG_NET
          CONFIG_SYSFS

        Linux kernel >= 3.8 for Smack support

        Udev will fail to work with the legacy layout:
          CONFIG_SYSFS_DEPRECATED=n

        Legacy hotplug slows down the system and confuses udev:
          CONFIG_UEVENT_HELPER_PATH=""

        Userspace firmware loading is deprecated, will go away, and
        sometimes causes problems:
          CONFIG_FW_LOADER_USER_HELPER=n

        Some udev rules and virtualization detection relies on it:
          CONFIG_DMIID

        Mount and bind mount handling might require it:
          CONFIG_FHANDLE

        Support for some SCSI devices serial number retrieval, to
        create additional symlinks in /dev/disk/ and /dev/tape:
          CONFIG_BLK_DEV_BSG

        Optional but strongly recommended:
          CONFIG_IPV6
          CONFIG_AUTOFS4_FS
          CONFIG_TMPFS_POSIX_ACL
          CONFIG_TMPFS_XATTR
          CONFIG_SECCOMP

        For systemd-bootchart a kernel with procfs support and several
        proc output options enabled is required:
          CONFIG_PROC_FS
          CONFIG_SCHEDSTATS
          CONFIG_SCHED_DEBUG

        For UEFI systems:
          CONFIG_EFI_VARS
          CONFIG_EFI_PARTITION

        Note that kernel auditing is broken when used with systemd's
        container code. When using systemd in conjunction with
        containers please make sure to either turn off auditing at
        runtime using the kernel command line option "audit=0", or
        turn it off at kernel compile time using:
          CONFIG_AUDIT=n

Create  /etc/portage/profile/use.force with -consolekit.
$ cat /etc/portage/profile/use.force
-consolekit

Create /etc/portage/profile/use.mask with consolekit and -systemd.
$ cat /etc/portage/profile/use.mask
consolekit
-systemd

Add to package.use.
$ cat /etc/portage/package.use
sys-fs/udisks systemd
sys-auth/polkit systemd
sys-auth/pambase systemd

When you install systemd you must have desktop profile set.

# eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/13.0
  [2]   default/linux/amd64/13.0/selinux
  [3]   default/linux/amd64/13.0/desktop *
  [4]   default/linux/amd64/13.0/desktop/gnome
  [5]   default/linux/amd64/13.0/desktop/kde
  [6]   default/linux/amd64/13.0/developer
  [7]   default/linux/amd64/13.0/no-multilib
  [8]   default/linux/amd64/13.0/x32
  [9]   hardened/linux/amd64
  [10]  hardened/linux/amd64/selinux
  [11]  hardened/linux/amd64/no-multilib
  [12]  hardened/linux/amd64/no-multilib/selinux
  [13]  hardened/linux/amd64/x32
  [14]  hardened/linux/uclibc/amd64


"OPS" It is very  important you don't reboot without one or the other installed. The results would be rather unfortunate.

I use xfce4 and that means only remove udev. Consolekit get removed with above settings.
emerge -C udev

Install systemd first then add systemd to make.conf.
emerge -1av systemd

Add systemd to make.conf.
USE="-gnome -kde -minimal -qt4 -consolekit -pulseaudio systemd

Update your system.
emerge --keep-going  --update --newuse --ask --deep --with-bdeps=y @world

Add systemd to grub2.
GRUB_CMDLINE_LINUX="init=/usr/lib/systemd/systemd"

Mine looks like this.
GRUB_CMDLINE_LINUX="quiet  audit=0  ipv6.disable=1 init=/usr/lib/systemd/systemd"

Done with systemd and reboot.

------------------------------------------------------------------------------------------------------

Now fix little things after :)

Check here again.
https://wiki.archlinux.org/index.php/Systemd
http://wiki.gentoo.org/wiki/Systemd
------------------------------------------------------------------------------------------------------

http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
Start Network
systemctl enable NetworkManager
systemctl start NetworkManager

If you have dhcpcd.
systemctl enable dhcpcd.service

If it doesn´t work
systemctl enable dhcpcd@interface_name.service

If you use dhclient.
User raddaqii in gentoo forums post this.
https://forums.gentoo.org/viewtopic-t-972608.html

If you want to have static ip look there.
https://wiki.archlinux.org/index.php/Network_Configuration#Static_IP_address

If you have a wpa_supplicant.
https://wiki.archlinux.org/index.php/WPA_supplicant#Enabling_with_systemd

-----------------------------------------------------------------------------------------------------

If you have trouble with mounting usb ,burning with dvd.not login to tty  a.s.o,
check if your user-session is active. (google have alot from arch linux forum)

https://wiki.archlinux.org/index.php/Systemd/User

$ loginctl --no-pager show-session $XDG_SESSION_ID | grep Active
Active=yes

$ loginctl show-session $XDG_SESSION_ID active

Id=c5
Timestamp=Sat 2013-10-05 13:13:55 CEST
TimestampMonotonic=93942897
VTNr=7
Display=:0
Remote=no
Service=lightdm
Scope=session-c5.scope
Leader=2364
Audit=0
Type=x11
Class=user
Active=yes
State=active
IdleHint=no
IdleSinceHint=0
IdleSinceHintMonotonic=0
Name=croutch

I fix this with the simplest solution. I installed lightDM displaymanager.
https://wiki.archlinux.org/index.php/LightDM

systemctl enable lightdm

If you want to have another display manager.
Enable with.

for kdm
systemctl enable kdm.service
systemctl start kdm.service

for gdm
systemctl enable gdm.service
systemctl start gdm.service

-----------------------------------------------------------------------------------------------------

If you have a large /home partition, it might be better to allow services that do not depend on /home to start while /home is checked by fsck. This can be achieved by adding the following options to the /etc/fstab entry of your /home partition.

noauto,x-systemd.automount

-----------------------------------------------------------------------------------------------------

Readahed section here before.

https://www.mail-archive.com/systemd-devel@lists.freedesktop.org/msg21693.html

----------------------------------------------------------------------------------------------------

Early start for services

One central feature of systemd is D-Bus and socket activation. This causes services to be started when they are first accessed and is generally a good thing. However, if you know that a service (like UPower) will always be started during boot, then the overall boot time might be reduced by starting it as early as possible. This can be achieved (if the service file is set up for it, which in most cases it is) by issuing.

# systemctl enable upower

----------------------------------------------------------------------------------------------------

After install i would recommend if you still have openrc installed  but wants systemd to take care of how programs starts. And maby save some time on boot.
To check in terminal - rc-update show.

I removed to start with.

dbus
networkmanager
alsa
syslog-ng (uninstalled)

----------------------------------------------------------------------------------------------------


Systemd comes with a rumour to boot fast and that is all true.

Look at this thread at arch linux forums. This thread is very good and you got many tips and trix from other users.

Post your systemd startup times
https://bbs.archlinux.org/viewtopic.php?id=147841


Command in terminal : systemd-analyze && systemd-analyze blame

or like me in .bashrc

alias sys='systemd-analyze && systemd-analyze blame'

And here you have my boot times at the moment.
Startup finished in 4.997s (firmware) + 961ms (loader) + 1.128s (kernel) + 535ms (userspace) = 7.622s

Whats interest are those numbers :)  and yes i have an intel 180g ssd.
Startup finished in 1.128s (kernel) + 535ms (userspace) =1.633

----------------------------------------------------------------------------------------------------

And if you have an more advanced setup with encryption,initramfs.You should look at user nlsa8z6zoz7lyih3ap´s thread on gentoo forums.
https://forums.gentoo.org/viewtopic-t-972332.html

----------------------------------------------------------------------------------------------------

croutch