systemd
From systemd's website:
systemd is a system and service manager for Linux, compatible with SysV and LSB init scripts. systemd provides aggressive parallelization capabilities, uses socket and D-Bus activation for starting services, offers on-demand starting of daemons, keeps track of processes using/ Linux cgroups, supports snapshotting and restoring of the system state, maintains mount and automount points and implements an elaborate transactional dependency-based service control logic. It can work as a drop-in replacement for sysvinit.
Contents
|
[edit] Installation
[edit] Kernel
The Gentoo ebuild for systemd requires at least 2.6.38 kernel. Although it is higher than what upstream requires, we already had trouble running systemd on 2.6.37.
systemd requires some non-standard kernel options to be enabled:
Linux Kernel Configuration: systemd options |
General setup ---> [*] Control Group support Device Drivers --->/ Generic Driver Options ---> [*] Maintain a devtmpfs filesystem to mount at /dev File systems ---> [*] Filesystem wide access notification < > Kernel automounter support <*> Kernel automounter version 4 support (also supports v3) |
(Re)build and (Re)install.
[edit] Userland
Many packages support systemd by default and are already available in the official portage tree but are (obviously) not stable yet.
Keyword required for installing systemd:
sys-apps/systemd sys-apps/dbus sys-fs/udev sys-kernel/linux-headers >=sys-apps/kmod-5
Optional: if you want GTK support, then add these packages too:
dev-libs/atk dev-libs/glib dev-lang/vala x11-libs/gtk+:2
For desktops you can also add the following few systemd-ready packages:
net-dns/avahi net-misc/networkmanager net-wireless/bluez net-wireless/wpa_supplicant sys-auth/consolekit
Install systemd and related packages:
[edit] Finalizing w/ grub
By default systemd will start your system to allow you to login in on a tty. This means no display manager gets started, no network is set up, etc. Make sure to enable the necessary services before you reboot.
Finally you will need to tell your kernel to run the init provided by systemd. If you have a kernel built by genkernel, change the real_init kernel parameter to point to /usr/bin/systemd:
... title=My Gentoo Linux root (hd0,0) kernel /my-genkernel... root=/dev/hda3 real_init=/usr/bin/systemd initrd /initramfs-genkernel-x86-2.6.32-gentoo-r7
If you have built your kernel yourself, change the init kernel parameter to point to /usr/bin/systemd:
title=My Gentoo Linux root (hd0,0) kernel /vmlinuz.bin root=/dev/hda3 init=/usr/bin/systemd ...
[edit] Finalizing w/ grub 2
/etc/default/grub file gedited to have this line look like this....
GRUB_CMDLINE_LINUX_DEFAULT="init=/usr/bin/systemd quiet"
[edit] Services
To list available services, run:
To enable services (similar to what rc-update -a
does):
A further list of unit files is available from git.overlays.gentoo.org/gitweb/?p=user/systemd.git;a=tree;f=sys-apps/systemd-units/files or from cgit.freedesktop.org/systemd/systemd/tree/units
You can find a list of some packages and their openrc and systemd services in the Gentoo Wiki
[edit]
[edit] LVM
[Unit] Description=Linux Volume Manager DefaultDependencies=no Requires=udev-settle.service After=udev-settle.service Before=shutdown.target local-fs.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/sbin/pvscan --ignorelockingfailure ExecStart=/sbin/vgscan --mknodes --ignorelockingfailure ExecStart=/sbin/vgchange --sysinit -a ly ExecStop=/sbin/lvchange --sysinit -a ln $(/sbin/vgs -o vg_name --noheadings --nosuffix 2> /dev/null) ExecStop=/sbin/lvchange --sysinit -a ln ExecStop=/sbin/vgchange --sysinit -a ln [Install] WantedBy=sysinit.target
[edit] microcode_ctl
[Unit] Description=CPU microcode updater [Service] Type=oneshot ExecStart=/usr/sbin/microcode_ctl -qu -f /lib/firmware/microcode.dat [Install] WantedBy=multi-user.target
[edit] radeon-power_profile
[Unit] Description=Radeon Power Profile [Service] Type=oneshot ExecStart=/usr/local/sbin/radeon-power_profile low [Install] WantedBy=multi-user.target
#!/bin/sh EXEC_NAME=`basename $0`; TARGET="/sys/class/drm/card0/device/power_profile" CURRENT_PROFILE=`cat ${TARGET}` append_profile() { local PROFILE=$1 echo -n " ${PROFILE}" if [ "x${CURRENT_PROFILE}x" == "x${PROFILE}x" ]; then echo -n " (current)" fi echo } if [ $# != 1 ]; then echo "usage: ${EXEC_NAME} <profile>" echo echo "Valid profiles:" for AVAILABLE_PROFILE in low high default auto; do append_profile ${AVAILABLE_PROFILE} done exit 0 fi PROFILE="$1" if [ "x${PROFILE}x" == "xlowx" ] || [ "x${PROFILE}x" == "xhighx" ] || [ "x${PROFILE}x" == "xautox" ] || [ "x${PROFILE}x" == "xdefaultx" ]; then echo "${PROFILE}" > ${TARGET} else logger "[${EXEC_NAME}] WARN: Invalid power_profile '${PROFILE}'" exit 1 fi exit 0
[edit] ALSA
alsa-utils already provides systemd service files. They are enabled automatically when installed.
[edit] Network
[edit] Static network
[Unit] Description=Network Connectivity [Service] Type=oneshot RemainAfterExit=yes ExecStart=/sbin/ifconfig eth0 192.168.1.2 mtu 1496 ExecStart=/sbin/route add default gw 192.168.1.1 ExecStop=/sbin/ifconfig eth0 down [Install] WantedBy=network.target
interface eth0 static ip_address=192.168.1.2/24 static routers=192.168.1.1 static domain_name_servers=192.168.1.1
[edit] DHCPCD
As of 5.2.12-r1, dhcpcd ebuild installs dhcpcd.service unit file.
[edit] wpa_supplicant
As of 0.7.3-r3, wpa_supplicant ebuild provides two systemd units:
-
wpa_supplicant.service
for NetworkManager users (using D-Bus), -
wpa_supplicant@.service
for plain wpa_supplicant users.
The latter one should be enabled as wpa_supplicant@wlan0.service
, where wlan0 shall be replaced by your wireless interface.
[edit] network manager
fix me please =(
[edit] wicd
[Unit] Description=Wicd Network Manager [Service] Type=dbus BusName=org.wicd.daemon ExecStart=/usr/sbin/wicd -f [Install] WantedBy=network.target
[edit] dnsmasq
[Unit] Description=dnsmasq service After=network.target [Service] ExecStartPre=/usr/sbin/dnsmasq --test ExecStart=/usr/sbin/dnsmasq -d -u dnsmasq -g dnsmasq ExecReload=/bin/kill -s HUP $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
[edit] munge
See code.google.com/p/munge/issues/detail?id=11
[Unit] Description=Start/Stop the MUNGE authentication service. After=syslog.target auditd.service [Service] Type=forking User=munge # Start up will fail if /etc/munge/munge.key does not exist # A fresh key can be generated with /usr/sbin/create-munge-key ExecStartPre=/usr/bin/test -r /etc/munge/munge.key ExecStart=/usr/sbin/munged ExecReload=/bin/kill -HUP $MAINPID PIDFile=/var/run/munge/munged.pid [Install] WantedBy=multi-user.target
[edit] Core services
[edit] dcron
[Unit] Description=dcron [Service] ExecStart=/usr/sbin/crond Type=forking [Install] WantedBy=multi-user.target
[edit] fcron
[Unit] Description=fcron service [Service] ExecStart=/usr/sbin/fcron -f -y [Install] WantedBy=multi-user.target
[edit] hwclock
[Unit] Description=hwclock [Service] Type=oneshot ExecStart=/sbin/hwclock --hctosys --localtime ExecStop=/sbin/hwclock --systohc --localtime [Install] WantedBy=multi-user.target
[edit] loadkeys
[Unit] Description=Loads keymap in console (dvorak in example) DefaultDependencies=no Before=sysinit.target [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/loadkeys -q /usr/share/keymaps/i386/dvorak/dvorak.map.gz [Install] WantedBy=multi-user.target
[edit] metalog
[Unit] Description=System Logger Daemon [Service] ExecStart=/usr/sbin/metalog
[Unit] Description=Syslog Socket [Socket] ListenDatagram=/dev/log [Install] WantedBy=sockets.target
[edit] ntp-client
[Unit] Description=NTP client After=hwclock.service [Service] Type=oneshot ExecStart=/usr/sbin/ntpdate -s -b -u 0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org [Install] WantedBy=multi-user.target
[edit] Display managers
[edit] KDM
[Unit] Description=K Display Manager on %I Requires=dev-%i.device After=dev-%i.device [Service] ExecStart=/usr/bin/kdm -nodaemon %I StandardOutput=syslog [Install] Alias=graphical.target.wants/kdm@tty7.service
Starting with systemd-187, the file contents have changed.
[Unit] Description=KDM Display Manager Conflicts=getty@tty1.service After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service [Service] ExecStart=/usr/bin/kdm -nodaemon Restart=always IgnoreSIGPIPE=no [Install] Alias=display-manager.service
[edit] XDM/GDM
[Unit] Description=X-Window Display Manager After=systemd-user-sessions.service [Service] ExecStart=/usr/bin/xdm -nodaemon [Install] Alias=display-manager.service
(or quite possibly just 'systemctl enable xdm.service' as there is already a xdm.service file located @ /usr/lib64/systemd/system/xdm.service)
[edit] startx
[Unit] Description=Startx [Service] #User=bob #uncomment this to run startx as desired user (in example bob), otherwise it will run startx as root ExecStart=/usr/bin/startx [Install] WantedBy=graphical.target
[edit] Daemons and servers
[edit] Samba
[Unit] Description=Samba server After=syslog.target After=network.target [Service] Group=samba ExecStart=/usr/sbin/smbd --pid-file=/var/run/samba/smbd.pid ExecStop=/bin/kill -15 $MAINPID PIDFile=/var/run/samba/smbd.pid Restart=always [Install] WantedBy=multi-user.target
[edit] NMBD
[Unit] Description=NMBD server After=syslog.target After=network.target [Service] Group=samba ExecStart=/usr/sbin/smbd --pid-file=/var/run/samba/nmbd.pid ExecStop=/bin/kill -15 $MAINPID PIDFile=/var/run/samba/nmbd.pid Restart=always [Install] WantedBy=multi-user.target
[edit] CUPS
Starting with cups 1.5.2-r20 the necessary socket, path and service files are provided by the ebuild.
[edit] distccd
[Unit] Description=distcc [Service] ExecStart=/usr/bin/distccd --user distcc --daemon --no-detach --port 3632 --log-level info --allow 192.168.1.0/24 --listen 192.168.1.111 -N 15 [Install] WantedBy=multi-user.target
[edit] lighttpd
[Unit] Description=Lighttpd Daemon After=network.target [Service] ExecStartPre=/usr/sbin/lighttpd -t -f /etc/lighttpd/lighttpd.conf ExecStart=/usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf ExecReload=/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target
d /var/run/lighttpd 0750 lighttpd lighttpd -
[edit] MySQL
[Unit] Description=MySQL database server After=syslog.target After=network.target [Service] User=mysql Group=mysql ExecStart=/usr/sbin/mysqld --pid-file=/var/run/mysqld/mysqld.pid ExecStop=/bin/kill -15 $MAINPID PIDFile=/var/run/mysqld/mysqld.pid # We rely on systemd, not mysqld_safe, to restart mysqld if it dies Restart=always # Place temp files in a secure directory, not /tmp PrivateTmp=true [Install] WantedBy=multi-user.target
# systemd tmpfile settings for mysql # See tmpfiles.d(5) for details d /var/run/mysqld 0755 mysql mysql -
[edit] PostgreSQL
This starts PostgreSQL.
d /run/postgres 0700 postgres postgres -
[Unit] Description=Initializing Postgresql %i Database [Service] User=postgres Group=postgres EnvironmentFile=/etc/conf.d/postgresql-%I PermissionsStartOnly=true ExecStartPre=/bin/mkdir /run/postgresql -p ExecStartPre=/bin/chown postgres:postgres /run/postgresql ExecStart=-/bin/sh -c "/usr/lib/postgresql-%I/bin/postgres -D /etc/postgresql-%I --data-directory=/var/lib/postgresql/%I/data" [Install] WantedBy=multi-user.target
[edit] NFS
Implements the functions of /etc/init.d/nfs, /etc/init.d/nfsmount and helper services.
sunrpc nfs
The following is only necessary if you are running a NFS server.
nfsd
The following files are necessary for all versions of NFS: