6.48. Systemd-231

The systemd package contains programs for controlling the startup, running, and shutdown of the system.

Approximate build time: 6.7 SBU
Required disk space: 430 MB

6.48.1. Installation of systemd

First, fix a build error when using Util-Linux built in Chapter 5:

sed -i "s:blkid/::" $(grep -rl "blkid/blkid.h")

Disable two tests that always fail:

sed -e 's@test/udev-test.pl @@'  \
    -e 's@test-copy$(EXEEXT) @@' \
    -i Makefile.in

Create a file to allow systemd to build when using Util-Linux built in Chapter 5, to disable LTO by default, and to build without xlstproc:

cat > config.cache << "EOF"
KILL=/bin/kill
MOUNT_PATH=/bin/mount
UMOUNT_PATH=/bin/umount
HAVE_BLKID=1
BLKID_LIBS="-lblkid"
BLKID_CFLAGS="-I/tools/include/blkid"
HAVE_LIBMOUNT=1
MOUNT_LIBS="-lmount"
MOUNT_CFLAGS="-I/tools/include/libmount"
cc_cv_CFLAGS__flto=no
XSLTPROC="/usr/bin/xsltproc"
EOF

LTO is disabled by default because it causes systemd and other auxiliary programs to link to libgcc_s.so, slows the build down and makes the compiled code larger.

Prepare systemd for compilation:

./configure --prefix=/usr            \
            --sysconfdir=/etc        \
            --localstatedir=/var     \
            --config-cache           \
            --with-rootprefix=       \
            --with-rootlibdir=/lib   \
            --enable-split-usr       \
            --disable-firstboot      \
            --disable-ldconfig       \
            --disable-sysusers       \
            --without-python         \
            --with-default-dnssec=no \
            --docdir=/usr/share/doc/systemd-231

The meaning of the configure options:

--config-cache

This switch tells the build system to use the config.cache file which was created earlier.

--with-root*

These switches ensure that core programs and shared libraries are installed in the subdirectories of the root partition.

--enable-split-usr

This switch ensures that systemd will work on systems where /bin, /lib and /sbin directories are not symlinks to their /usr counterparts.

--without-python

This switch prevents configure from trying to use Python which isn't built in LFS.

--disable-firstboot

This switch prevents installation of systemd services responsible for setting up the system for the first time. They are not useful for LFS because everything is done manually.

--disable-ldconfig

This switch prevents installation of a systemd unit that runs ldconfig at boot, making the boot time longer. Remove it if the described feature is desired, even though it's not useful for source distributions such as LFS.

--disable-sysusers

This switch prevents installation of systemd services responsible for setting up the /etc/group and /etc/passwd files. Both files were created early in this chapter.

--with-default-dnssec=no

This switch turns off the experimental DNSSEC suport.

Compile the package:

make LIBRARY_PATH=/tools/lib

This package has a test suite, but it can only be run after the package has been installed.

Install the package:

make LD_LIBRARY_PATH=/tools/lib install

Move the NSS libraries to /lib:

mv -v /usr/lib/libnss_{myhostname,mymachines,resolve}.so.2 /lib

Remove an unnecessary directory:

rm -rfv /usr/lib/rpm

Create the Sysvinit compatibility symlinks, so systemd is used as the default init system:

for tool in runlevel reboot shutdown poweroff halt telinit; do
     ln -sfv ../bin/systemctl /sbin/${tool}
done
ln -sfv ../lib/systemd/systemd /sbin/init

Create the /etc/machine-id file needed by systemd-journald:

systemd-machine-id-setup

Fix a broken symlink created by the systemd installation process:

rm -fv /etc/resolv.conf
ln -s ../lib/systemd/resolv.conf /etc/resolv.conf

Since the testsuite largely depends on the host system kernel configuration, some tests may fail. It also needs a modification in order not to look for a program that will be installed by Util-Linux package later in this chapter. To test the results, issue:

sed -i "s:minix:ext4:g" src/test/test-path-util.c
make LD_LIBRARY_PATH=/tools/lib -k check

6.48.2. Contents of systemd

Installed programs: bootctl, busctl, coredumpctl, halt, hostnamectl, init, journalctl, kernel-install, localectl, loginctl, machinectl, networkctl, poweroff, reboot, runlevel, shutdown, systemctl, systemd-analyze, systemd-ask-password, systemd-cat, systemd-cgls, systemd-cgtop, systemd-delta, systemd-detect-virt, systemd-escape, systemd-hwdb, systemd-inhibit, systemd-machine-id-setup, systemd-notify, systemd-nspawn, systemd-path, systemd-resolve, systemd-run, systemd-stdio-bridge, systemd-tmpfiles, systemd-tty-ask-password-agent, telinit, timedatectl, and udevadm
Installed libraries: libnss_myhostname.so.2, libnss_mymachines.so.2, libnss_resolve.so.2, libsystemd.so, libsystemd-shared-231.so, and libudev.so
Installed directories: /etc/binfmt.d, /etc/init.d, /etc/kernel, /etc/modules-load.d, /etc/sysctl.d, /etc/systemd, /etc/tmpfiles.d, /etc/udev, /etc/xdg/systemd, /lib/systemd, /lib/udev, /usr/include/systemd, /usr/lib/binfmt.d, /usr/lib/kernel, /usr/lib/modules-load.d, /usr/lib/sysctl.d, /usr/lib/systemd, /usr/lib/tmpfiles.d, /usr/share/doc/systemd-231, /usr/share/factory, /usr/share/systemd, /var/lib/systemd, and /var/log/journal

Short Descriptions

bootctl

used to query the firmware and boot manager settings

busctl

Used to introspect and monitor the D-Bus bus

coredumpctl

Used to retrieve coredumps from the systemd Journal

halt

Normally invokes shutdown with the -h option, except when already in run-level 0, then it tells the kernel to halt the system; it notes in the file /var/log/wtmp that the system is being brought down

hostnamectl

Used to query and change the system hostname and related settings

init

The first process to be started when the kernel has initialized the hardware which takes over the boot process and starts all the proceses it is instructed to

journalctl

Used to query the contents of the systemd Journal

kernel-install

Used to add and remove kernel and initramfs images to and from /boot

localectl

Used to query and change the system locale and keyboard layout settings

loginctl

Used to introspect and control the state of the systemd Login Manager

machinectl

Used to introspect and control the state of the systemd Virtual Machine and Container Registration Manager

networkctl

Used to introspect the state of the network links as seen by systemd-networkd

poweroff

Tells the kernel to halt the system and switch off the computer (see halt)

reboot

Tells the kernel to reboot the system (see halt)

runlevel

Reports the previous and the current run-level, as noted in the last run-level record in /var/run/utmp

shutdown

Brings the system down in a secure way, signaling all processes and notifying all logged-in users

systemctl

Used to introspect and control the state of the systemd system and service manager

systemd-analyze

Used to determine system boot-up performance of the current boot

systemd-ask-password

Used to query a system password or passphrase from the user, using a question message specified on the command line

systemd-cat

Used to connect STDOUT and STDERR of a process with the Journal

systemd-cgls

Recursively shows the contents of the selected Linux control group hierarchy in a tree

systemd-cgtop

Shows the top control groups of the local Linux control group hierarchy, ordered by their CPU, memory and disk I/O load

systemd-delta

Used to identify and compare configuration files in /etc that override default counterparts in /usr

systemd-detect-virt

Detects execution in a virtualized environment

systemd-escape

Used to escape strings for inclusion in systemd unit names

systemd-hwdb

Used to manage hardware database (hwdb)

systemd-inhibit

Used to execute a program with a shutdown, sleep or idle inhibitor lock taken

systemd-machine-id-setup

Used by system installer tools to initialize the machine ID stored in /etc/machine-id at install time with a randomly generated ID

systemd-notify

Used by daemon scripts to notify the init system about status changes

systemd-nspawn

Used to run a command or OS in a light-weight namespace container

systemd-path

Used to query system and user paths

systemd-resolve

Used to resolve domain names, IPV4 and IPv6 addresses, DNS resource records, and services

systemd-run

Used to create and start a transient .service or a .scope unit and run the specified command in it

systemd-tmpfiles

Creates, deletes and cleans up volatile and temporary files and directories, based on the configuration file format and location specified in tmpfiles.d directories

systemd-tty-ask-password-agent

Used to list or process pending systemd password requests

telinit

Tells init which run-level to change to

timedatectl

Used to query and change the system clock and its settings

udevadm

Generic Udev administration tool: controls the udevd daemon, provides info from the Udev database, monitors uevents, waits for uevents to finish, tests Udev configuration, and triggers uevents for a given device

libsystemd

systemd utility library

libudev

A library to access Udev device information