systemd

Revision 3 as of 2010-10-24 13:37:29

Clear message

systemd - An Alternative Boot Manager

systemd is a system and session 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.

See the systemd home page for further information.

Warning! Experimental Code

systemd is under active development. It has not yet been shipped in a production release of any major Linux distro.

Current versions of systemd require that you customize your kernel as well as running a non-standard init process. These are pretty intrusive changes.

Installing systemd is likely to limit the amount of help and support available to you. If you have a commercial support agreement, installing systemd would almost certainly invalidate it. Even if you rely on forums etc, you will probably have to reproduce problems on a standard Ubuntu build before anyone can help you much.

A good place to experiment with systemd at this stage is on a "sandpit" system (e.g. a virtual machine) that you would be happy just to re-install if it gets too messed up. If you put this on a system containing data that you care about, please take a full backup first, and have a plan for restoring from that backup when the system no longer boots :-).

Personal Package Area Location

systemd and related packages are available on this PPA To use the PPA, first add it to your software sources list as follows.

add-apt-repository ppa:andrew-edmunds/ppa
apt-get update

Kernel Requirements

systemd requires the directory /sys/fs/cgroup as a mountpoint. It doesn't exist in the current Ubuntu kernel (2.6.35). It can't be created with mkdir either because sysfs doesn't allow that. To create the directory this patch from the 2.6.36 kernel must be backported.

The following kernel config options must be selected. The standard Ubuntu kernel meets these config requirements.

General setup  --->
     [*] Control Group support
Device Drivers --->
     Generic Driver Options  --->
          [*] Maintain a devtmpfs filesystem to mount at /dev
          [*]   Automount devtmpfs at /dev, after the kernel mounted the rootfs (NEW)
File systems --->
     < > Kernel automounter support
     <*> Kernel automounter version 4 support (also supports v3)

A suitably patched kernel is available on the PPA. You can install it as follows.

apt-get install linux-image-2.6.35-22-generic=2.6.35-22.33ppa1 linux-headers-2.6.35-22-generic=2.6.35-22.33ppa1 linux-headers-2.6.35-22=2.6.35-22.33ppa1

If you prefer to build your own kernel you will need to apply the patch and select the config options mentioned above.

Installing systemd

systemd can be installed from the PPA as follows.

apt-get install systemd libpam-systemd systemd-gui systemd-extra-units

This results in systemd being installed alongside upstart. If you were going to try replacing upstart altogether (not recommended currently) then you would need the additional package systemd-sysv, which provides replacements for commands such as reboot.

Using systemd

Booting

After installation, the machine will still boot under upstart by default. To boot under systemd, edit the kernel command line and add the following argument:

init=/bin/systemd

Note that systemd resides in /bin rather than /sbin.

For example, if the relevant line in grub normally says this:

linux /boot/vmlinuz-2.6.35-22-generic root=UUID=02dcb9e2-1240-4eb6-bc3c-821218b0cd64 ro   crashkernel=384M-2G:64M,2G-:128M quiet splash

then you might change it to:

linux /boot/vmlinuz-2.6.35-22-generic root=UUID=02dcb9e2-1240-4eb6-bc3c-821218b0cd64 ro   crashkernel=384M-2G:64M,2G-:128M init=/bin/systemd

If a normal boot under systemd is not successful then the following is worth a try:

init=/bin/systemd systemd.unit=emergency.service
  • systemd.unit= specifies the target state that the system should boot to (similar to specifying a run level under sysvinit).

  • emergency.service launches an emergency bash shell on the console without attempting to start any other services.

Controlling systemd once booted

The principal command used to control systemd is systemctl. Some of its subcommands are as follows.

  • systemctl list-units - List all units (where unit is the term for a job/service)

  • systemctl start [NAME...] - Start (activate) one or more units
  • systemctl stop [NAME...] - Stop (deactivate) one or more units
  • systemctl enable [NAME...] - Enable one or more unit files
  • systemctl disable [NAME...] - Disable one or more unit files
  • systemctl reboot - Shut down and reboot the system

For the complete list, see systemctl(1).

Status as at October 2010

systemd on Ubuntu can do basic system initialization and boot to a command line login prompt. Many services are simply not started. This is because they have been converted to "native" upstart jobs in Ubuntu. systemd parses traditional sysvinit boot scripts (under /etc/init.d) but does not parse native upstart jobs (under /etc/init).

Package systemd-extra-units exists to work around this by shipping additional units (configuration files). It should be reasonably straightforward to get more services started by adding appropriate unit files to this package.