Introduction to systemd

Even though systemd was built in LFS, there are some features provided by the package that some BLFS packages need, but their dependencies didn't fit into LFS.

There are two reasons why systemd needs to be rebuilt. Some packages require GUdev library to be present in order to compile while others expect working systemd-logind service in order to work properly. To build the GUdev library, make sure that you have installed first set of required dependencies. In order to get systemd-logind to work properly, make sure that you have installed second set of required dependencies.

Unlike other packages in BLFS, there is no set version of systemd in this page's title and no set version specified for download. Version updates to systemd make it possible that the user's system may have a systemd version different from the one in the current LFS book. Therefore, users should use the version of systemd that is currently installed on their system.

This package is known to build and work properly using an LFS-7.6 systemd platform using systemd-216 source.

Package Information

Make sure you download the "compat" patch whose version matches the systemd version you are building.



If you are unsure which version needs to be downloaded, issue systemctl --version in order to find out. Some of the commands below might need the version information. Issue the following command to store the systemd version number into an environment variable:

export SYSTEMD_VERSION=$(systemctl --version | head -n1 | awk '{print $2}')

systemd Dependencies

Required (GUdev)

GLib-2.40.0 and gobject-introspection-1.40.0

Required (Logind)


Recommended Runtime Dependency


cURL-7.37.1, elfutils-0.160, GnuTLS-3.3.7, GTK-Doc-1.20, libgcrypt-1.6.2, libidn-1.29, Python-3.4.1, Valgrind-3.10.0, cryptsetup, libmicrohttpd, libqrencode, libseccomp, lxml (Python Module), and lz4



In order to build the systemd Python module, lxml package needs to be installed for the corresponding Python version (2 or 3). Note that configure defaults to Python 2. In order to build the module for Python 3, make sure you pass the PYTHON=python3 environment variable to the configure command below.

Optional (for rebuilding manual pages)

libxslt-1.1.28, docbook-xml-4.5, and docbook-xsl-1.78.1

User Notes:

Installation of systemd

First, apply the required patch:

patch -Np1 -i ../systemd-${SYSTEMD_VERSION}-compat-1.patch

Rebuild systemd by running the following commands:

cc_cv_CFLAGS__flto=no              \
./configure --prefix=/usr          \
            --sysconfdir=/etc      \
            --localstatedir=/var   \
            --with-rootprefix=     \
            --with-rootlibdir=/lib \
            --enable-split-usr     \
            --disable-firstboot    \
            --disable-ldconfig     \
            --disable-sysusers     \
            --docdir=/usr/share/doc/systemd-${SYSTEMD_VERSION} &&


For the best results, make sure you run the testsuite from a system that is booted by the same systemd version you are rebuilding.

To test the results, issue: make -k check.



Installing the package will override all files installed by systemd in LFS. It is critical that nothing uses either systemd or Udev libraries or programs during the installation phrase. Best way to achieve that is to do the installation in the rescue mode. To switch to the rescue mode, issue the following command as the root user from a TTY:

systemctl start

Now, as the root user:

make install

Move NSS libraries to /lib by running the following command as the root user:

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

Remove an unnecessary directory by running the following command as the root user:

rm -rfv /usr/lib/rpm

Remove a reference to a non-existent group by running the following command as the root user:

sed -i "s:0775 root lock:0755 root root:g" /usr/lib/tmpfiles.d/legacy.conf

Configuring systemd

If the systemd PAM module was built, the /etc/pam.d/system-sesion file needs to be modified and a new file needs to be created in order for systemd-logind to work correctly. To accomplish that, run the following commands as the root user:

cat >> /etc/pam.d/system-session << "EOF"
# Begin Systemd addition
session   required
-session   optional

# End Systemd addition

cat > /etc/pam.d/systemd-user << "EOF"
# Begin /etc/pam.d/systemd-user

account  required
account  include  system-account

session  required
session  required
session  include  system-session

auth     required
password required

# End /etc/pam.d/systemd-user

At this point it would be a nice idea to reboot to test if the reinstallation was successful.


A list of the installed files, along with their short descriptions can be found at ../../../../lfs/view/7.6-systemd/chapter06/systemd.html#contents-systemd.

Below are listed newly installed libraries and directories along with short descriptions.

Installed Programs: None
Installed Libraries: and (in /lib/security)
Installed Directories: /usr/include/gudev-1.0 and /usr/share/gtk-doc/html/gudev

Short Descriptions

is a GObject-based wrapper library for libudev.

is a PAM module used to register user sessions with the systemd login manager, systemd-logind.

Last updated on 2014-08-23 15:42:10 -0700