Introduction to systemd

While systemd was installed when building LFS, there are many features provided by the package that were not included in the initial installation because Linux-PAM was not yet installed. The systemd package needs to be rebuilt to provide a working systemd-logind service, which provides many additional features for dependent packages.

This package is known to build and work properly using an LFS-8.3 platform.

Package Information

Additional Downloads

systemd Dependencies



Recommended Runtime Dependencies


make-ca-0.8, cURL-7.61.0, git-2.18.0, GnuTLS-3.5.19, Iptables-1.8.0, libgcrypt-1.8.3, libidn2-2.0.5, libseccomp-2.3.3, libxkbcommon-0.8.2, qemu-3.0.0, Valgrind-3.13.0, zsh-5.5.1 (for the zsh completions), cryptsetup, gnu-efi, kexec-tools, libmicrohttpd, lz4, qrencode, quota-tools and Sphinx

Optional (to rebuild the manual pages)

docbook-xml-4.5, docbook-xsl-1.79.2, and libxslt-1.1.32

User Notes:

Installation of systemd

First, apply a fix for glibc-2.28:

patch -Np1 -i ../systemd-239-glibc_statx_fix-1.patch

Remove an unneeded group, render, from the default udev rules:

sed -i 's/GROUP="render", //' rules/

Rebuild systemd by running the following commands:

mkdir build &&
cd    build &&

meson --prefix=/usr         \
      --sysconfdir=/etc     \
      --localstatedir=/var  \
      -Dblkid=true          \
      -Dbuildtype=release   \
      -Ddefault-dnssec=no   \
      -Dfirstboot=false     \
      -Dinstall-tests=false \
      -Dldconfig=false      \
      -Drootprefix=         \
      -Drootlibdir=/lib     \
      -Dsplit-usr=true      \
      -Dsysusers=false      \
      -Db_lto=false         \
      ..                    &&



For the best test 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: ninja test.



Installing the package will overwrite all files installed by systemd in LFS. It is critical that nothing uses either systemd or Udev libraries during the installation. The best way to ensure that these libraries are not being used is to run the installation in rescue mode. To switch to rescue mode, run the following command as the root user (from a TTY):

systemctl start

Now, as the root user:

ninja install

If RPM is not installed, remove an unnecessary directory by running the following command as the root user:

rm -rfv /usr/lib/rpm

Configuring systemd

The /etc/pam.d/system-session file needs to be modified and a new file needs to be created in order for systemd-logind to work correctly. 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, you should reload the systemd daemon, and reenter multi-user mode with the following commands (as the root user):

systemctl daemon-reload
systemctl start


If upgrading from a previous version of systemd and an initrd is used for system boot, you should generate a new initrd before rebooting the system.


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

Listed below are the newly installed libraries and directories along with short descriptions.

Installed Programs: None
Installed Libraries: (in /lib/security)
Installed Directories: None

Short Descriptions

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

Last updated on 2018-08-14 19:39:38 -0700