2024-01-20 05:35:53 +08:00
<?xml version="1.0" encoding="UTF-8"?>
2016-06-02 13:39:31 +08:00
< !DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../../general.ent">
%general-entities;
2022-09-08 14:46:59 +08:00
<!-- <!ENTITY systemd - download - http "https://anduin.linuxfromscratch.org/LFS/systemd - &systemd - version; - &systemd - stable;.tar.xz"> For whenever we move to a stable snapshot for backports -->
2018-12-29 06:18:36 +08:00
<!ENTITY systemd-download-http "https://github.com/systemd/systemd/archive/v&systemd-version;/systemd-&systemd-version;.tar.gz">
2016-06-02 13:39:31 +08:00
<!ENTITY systemd-download-ftp " ">
2023-12-23 21:53:56 +08:00
<!ENTITY systemd-md5sum "521cda27409a9edf0370c128fae3e690">
<!ENTITY systemd-size "15 MB">
2023-07-29 10:34:02 +08:00
<!ENTITY systemd-buildsize "198 MB (with tests)">
2023-03-07 12:38:46 +08:00
<!ENTITY systemd-time "3.7 SBU (with tests using 4 cores)">
2016-06-02 13:39:31 +08:00
]>
2018-12-29 06:18:36 +08:00
<sect1 id= "systemd" xreflabel= "Systemd-&systemd-version;" revision= "systemd" >
2016-06-02 13:39:31 +08:00
<?dbhtml filename="systemd.html"?>
2018-12-29 06:18:36 +08:00
<title > Systemd-&systemd-version; </title>
<!-- Whenever we switch back to stable backports, make sure to add the systemd - stable reference back. -->
2016-06-02 13:39:31 +08:00
<indexterm zone= "systemd" >
<primary sortas= "a-systemd" > systemd</primary>
</indexterm>
<sect2 role= "package" >
<title > Introduction to systemd</title>
<para >
While <application > systemd</application> was installed when
building LFS, there are many features provided by the package that
2016-08-28 17:28:15 +08:00
were not included in the initial installation because
2016-06-02 13:39:31 +08:00
<application > Linux-PAM</application> was not yet installed.
The <application > systemd</application> package needs to be
rebuilt to provide a working <command > systemd-logind</command> service,
2016-08-28 17:28:15 +08:00
which provides many additional features for dependent packages.
2016-06-02 13:39:31 +08:00
</para>
2021-09-07 01:42:49 +08:00
2024-02-17 16:49:09 +08:00
&lfs121_checked;
2016-06-02 13:39:31 +08:00
<bridgehead renderas= "sect3" > Package Information</bridgehead>
<itemizedlist spacing= "compact" >
<listitem >
2020-03-19 18:00:16 +08:00
<para >
Download (HTTP): <ulink url= "&systemd-download-http;" />
</para>
2016-06-02 13:39:31 +08:00
</listitem>
<listitem >
2020-03-19 18:00:16 +08:00
<para >
Download (FTP): <ulink url= "&systemd-download-ftp;" />
</para>
2016-06-02 13:39:31 +08:00
</listitem>
<listitem >
2020-03-19 18:00:16 +08:00
<para >
Download MD5 sum: &systemd-md5sum;
</para>
2016-06-02 13:39:31 +08:00
</listitem>
<listitem >
2020-03-19 18:00:16 +08:00
<para >
Download size: &systemd-size;
</para>
2016-06-02 13:39:31 +08:00
</listitem>
<listitem >
2020-03-19 18:00:16 +08:00
<para >
Estimated disk space required: &systemd-buildsize;
</para>
2016-06-02 13:39:31 +08:00
</listitem>
<listitem >
2020-03-19 18:00:16 +08:00
<para >
Estimated build time: &systemd-time;
</para>
2016-06-02 13:39:31 +08:00
</listitem>
</itemizedlist>
2020-03-20 10:02:29 +08:00
2024-02-10 19:04:46 +08:00
<!-- Comment out (instead of remove) in case a patch will be needed. -->
2019-01-12 01:05:56 +08:00
<bridgehead renderas= "sect3" > Additional Downloads</bridgehead>
<itemizedlist spacing= "compact" >
<listitem >
<para >
Required patch:
2024-02-10 19:04:46 +08:00
<ulink url= "&patch-root;/systemd-&systemd-version;-upstream_fixes-1.patch" />
2022-04-06 23:25:29 +08:00
</para>
</listitem>
2019-01-12 01:05:56 +08:00
</itemizedlist>
2024-02-10 19:04:46 +08:00
2016-06-02 13:39:31 +08:00
<bridgehead renderas= "sect3" > systemd Dependencies</bridgehead>
2023-03-23 00:43:58 +08:00
<bridgehead renderas= "sect4" > Recommended</bridgehead>
<note >
<para >
<xref linkend= 'linux-pam' /> is not strictly required to build
<application > systemd</application> , but the main reason to rebuild
<application > systemd</application> in BLFS (it's already built in
LFS anyway) is for the <command > systemd-logind</command> daemon and
the
<filename class= 'libraryfile' > pam_systemd.so</filename> PAM module.
<xref linkend= 'linux-pam' /> is required for them. All packages in
BLFS book with a dependency on <application > systemd</application>
expects it has been rebuilt with <xref linkend= 'linux-pam' /> .
</para>
</note>
2016-06-02 13:39:31 +08:00
<para role= "recommended" >
2023-03-23 00:43:58 +08:00
<xref linkend= "linux-pam" /> and
<xref role= "runtime" linkend= "polkit" /> (runtime)
2016-06-02 13:39:31 +08:00
</para>
<bridgehead renderas= "sect4" > Optional</bridgehead>
<para role= "optional" >
2021-02-05 13:26:02 +08:00
<xref linkend= "btrfs-progs" /> , <!-- homed may support it, see the C.E. -->
2016-06-02 13:39:31 +08:00
<xref linkend= "curl" /> ,
2018-12-01 06:22:17 +08:00
<xref linkend= "cryptsetup" /> ,
2018-08-11 04:58:19 +08:00
<xref linkend= "git" /> ,
2016-06-02 13:39:31 +08:00
<xref linkend= "gnutls" /> ,
<xref linkend= "iptables" /> ,
<xref linkend= "libgcrypt" /> ,
2017-09-19 03:32:04 +08:00
<xref linkend= "libidn2" /> ,
2020-03-20 10:02:29 +08:00
<xref linkend= "libpwquality" /> ,
2017-09-30 16:46:14 +08:00
<xref linkend= "libseccomp" /> ,
2016-06-02 13:39:31 +08:00
<xref linkend= "libxkbcommon" /> ,
2018-12-01 06:22:17 +08:00
<xref linkend= "make-ca" /> ,
2021-08-15 04:19:40 +08:00
<xref linkend= "p11-kit" /> ,
2019-10-10 11:19:42 +08:00
<xref linkend= "pcre2" /> ,
2016-06-02 13:39:31 +08:00
<xref linkend= "qemu" /> ,
2021-01-02 11:39:56 +08:00
<xref linkend= "qrencode" /> ,
2021-04-29 09:31:11 +08:00
<xref linkend= "rsync" /> ,
2023-01-19 00:02:55 +08:00
<xref linkend= "sphinx" /> ,
2016-06-02 13:39:31 +08:00
<xref linkend= "valgrind" /> ,
2016-08-12 10:11:43 +08:00
<xref linkend= "zsh" /> (for the zsh completions),
2023-07-29 10:34:02 +08:00
<ulink url= "https://www.apparmor.net/" > AppArmor</ulink> ,
<ulink url= "https://github.com/linux-audit/audit-userspace" > audit-userspace</ulink> ,
<ulink url= "https://github.com/scop/bash-completion" > bash-completion</ulink> ,
<ulink url= "https://jekyllrb.com/" > jekyll</ulink> ,
2016-06-02 13:39:31 +08:00
<ulink url= "https://www.kernel.org/pub/linux/utils/kernel/kexec/" > kexec-tools</ulink> ,
2021-12-31 09:06:39 +08:00
<ulink url= "https://github.com/libbpf/libbpf" > libbpf</ulink> ,
2021-05-20 23:41:12 +08:00
<ulink url= "https://sourceware.org/elfutils/" > libdw</ulink> ,
2020-12-06 03:29:55 +08:00
<ulink url= "https://developers.yubico.com/libfido2/" > libfido2</ulink> ,
2016-06-02 13:39:31 +08:00
<ulink url= "https://www.gnu.org/software/libmicrohttpd/" > libmicrohttpd</ulink> ,
2023-12-23 21:53:56 +08:00
<ulink url= "https://pypi.org/project/pefile/" > pefile</ulink> ,
2023-07-29 10:34:02 +08:00
<ulink url= "https://pypi.org/project/pyelftools/" > pyelftools</ulink> ,
<ulink url= "https://sourceforge.net/projects/linuxquota/" > quota-tools</ulink> ,
<ulink url= "https://rpm.org/" > rpm</ulink> ,
<ulink url= "https://github.com/SELinuxProject/selinux" > SELinux</ulink> ,
<ulink url= "https://sourceware.org/systemtap/" > systemtap</ulink> ,
2021-05-20 23:41:12 +08:00
<ulink url= "https://tpm2-tss.readthedocs.io/en/latest/" > tpm2-tss</ulink>
2023-07-29 10:34:02 +08:00
and <ulink url= "https://xenproject.org" > Xen</ulink>
2016-06-02 13:39:31 +08:00
</para>
<bridgehead renderas= "sect4" > Optional (to rebuild the manual pages)</bridgehead>
<para role= "optional" >
<xref linkend= "DocBook" /> ,
2019-01-21 03:51:28 +08:00
<xref linkend= "docbook-xsl" /> ,
<xref linkend= "libxslt" /> , and
<xref linkend= "lxml" /> (to build the index of systemd manual pages)
2016-06-02 13:39:31 +08:00
</para>
2023-12-22 06:44:05 +08:00
<para condition= "html" role= "usernotes" >
Editor Notes: <ulink url= "&blfs-wiki;/Logind" />
</para>
2016-06-02 13:39:31 +08:00
</sect2>
<sect2 role= "installation" >
<title > Installation of systemd</title>
2023-05-10 15:11:10 +08:00
2020-03-19 18:00:16 +08:00
<para >
2021-07-09 12:07:13 +08:00
Remove two unneeded groups,
<systemitem class= "groupname" > render</systemitem> and
<systemitem class= "groupname" > sgx</systemitem> , from the default udev
2020-03-19 18:00:16 +08:00
rules:
</para>
2017-12-22 14:54:12 +08:00
2021-07-09 12:07:13 +08:00
<screen > <userinput remap= "pre" > sed -i -e 's/GROUP="render"/GROUP="video"/' \
-e 's/GROUP="sgx", //' rules.d/50-udev-default.rules.in</userinput> </screen>
2017-12-22 14:54:12 +08:00
2023-12-31 05:20:32 +08:00
<para >
Now fix a security vulnerability in the DNSSEC verification of
2024-02-10 19:04:46 +08:00
<command > systemd-resolved</command> and a bug breaking running
<command > systemd-analyze verify</command> on an instantiated systemd
unit:
2023-12-31 05:20:32 +08:00
</para>
2024-02-10 19:04:46 +08:00
<screen > <userinput > patch -Np1 -i ../systemd-&systemd-version; -upstream_fixes-1.patch</userinput> </screen>
2023-12-31 05:20:32 +08:00
2016-06-02 13:39:31 +08:00
<para >
Rebuild <application > systemd</application> by running the
following commands:
</para>
2018-04-02 01:51:19 +08:00
<screen > <userinput > mkdir build & &
cd build & &
2023-03-14 00:48:55 +08:00
meson setup .. \
--prefix=/usr \
--buildtype=release \
-Ddefault-dnssec=no \
-Dfirstboot=false \
-Dinstall-tests=false \
-Dldconfig=false \
-Dman=auto \
-Dsysusers=false \
-Drpmmacrosdir=no \
2023-12-23 21:53:56 +08:00
-Dhomed=disabled \
2023-03-14 00:48:55 +08:00
-Duserdb=false \
-Dmode=release \
2023-12-31 03:04:16 +08:00
-Dpam=enabled \
2023-03-14 00:48:55 +08:00
-Dpamconfdir=/etc/pam.d \
2023-04-10 16:19:51 +08:00
-Ddev-kvm-mode=0660 \
2023-09-14 15:35:05 +08:00
-Dnobody-group=nogroup \
2023-12-23 21:53:56 +08:00
-Dsysupdate=disabled \
-Dukify=disabled \
2023-03-14 00:48:55 +08:00
-Ddocdir=/usr/share/doc/systemd-&systemd-version; & &
2018-04-02 01:51:19 +08:00
2017-10-08 10:08:26 +08:00
ninja</userinput> </screen>
2020-03-21 12:35:03 +08:00
<!-- Regarding homed and userdb, see the note below in Command Explanations -->
2016-06-02 13:39:31 +08:00
<note >
<para >
2022-12-14 02:19:29 +08:00
For the best test results, make sure you run the test suite from
2016-06-02 13:39:31 +08:00
a system that is booted by the same
<application > systemd</application> version you are rebuilding.
</para>
</note>
<para >
2023-07-05 01:06:52 +08:00
To test the results, issue: <command > ninja test</command> .
<!-- test - netlink: https://github.com/systemd/systemd/issues/27969 -->
The test named <filename > test-stat-util</filename> and
<filename > test-netlink</filename> are known to fail
if some kernel features are not enabled.
If the test suite is ran as the &root; user, some
2023-05-10 15:44:55 +08:00
other tests may fail because they depend on various kernel
configuration options.
2016-06-02 13:39:31 +08:00
</para>
<para >
Now, as the <systemitem class= "username" > root</systemitem> user:
</para>
2017-10-08 10:08:26 +08:00
<screen role= "root" > <userinput > ninja install</userinput> </screen>
2021-12-31 09:06:39 +08:00
2016-06-02 13:39:31 +08:00
</sect2>
2020-03-21 12:35:03 +08:00
<sect2 role= "commands" >
<title > Command Explanations</title>
2021-06-04 19:26:37 +08:00
<xi:include xmlns:xi= "http://www.w3.org/2001/XInclude"
href="../../xincludes/meson-buildtype-release.xml"/>
2020-12-06 03:29:55 +08:00
<para >
<parameter > -Dpamconfdir=/etc/pam.d</parameter> : Forces the PAM files to
be installed in /etc/pam.d rather than /usr/lib/pam.d.
</para>
2020-03-21 12:35:03 +08:00
<para >
<parameter > -Duserdb=false</parameter> : Removes a daemon that does not
offer any use under a BLFS configuration. If you wish to enable the
<application > userdbd</application> daemon, replace "false" with "true"
in the above meson command.
</para>
<para >
2023-12-23 21:53:56 +08:00
<parameter > -Dhomed=disabled</parameter> : Removes a daemon that does not offer
2020-03-21 12:35:03 +08:00
any use under a traditional BLFS configuration, especially using accounts
created with useradd. To enable systemd-homed, first ensure that you have
2022-02-19 03:06:30 +08:00
<xref linkend= "cryptsetup" /> and <xref linkend= "libpwquality" /> installed,
2023-12-23 21:53:56 +08:00
and then change <quote > disabled</quote> to <quote > enabled</quote>
in the above <command > meson setup</command> command.
</para>
<para >
<parameter > -Dukify=disabled</parameter> : Removes a script for
combining a kernel, an initramfs, and a kernel command line etc.
into an UEFI application which can be loaded by the UEFI firmware
to start the embedded Linux kernel. It's not needed for booting a
BLFS system with UEFI if following <xref linkend= 'grub-setup' /> .
And, it requires the <application > pefile</application> Python module
at runtime, so if it's enabled but <application > pefile</application>
is not installed, in the test suite one test for it will fail. To
enable <command > systemd-ukify</command> , install the
<application > pefile</application> module and then change
<quote > disabled</quote> to <quote > enabled</quote> in the above
<command > meson setup</command> command.
2020-03-21 12:35:03 +08:00
</para>
<!-- EDITORS NOTE: Explanation on removing userdbd and homed:
In BLFS, we do not fully support disk encryption. We offer instructions for
building 'cryptsetup' as a dependency, but we do not offer instructions for
actually configuring it. In addition, we generally do not include
functionality that could potentially conflict with other packages, or that
is not of any use to us (in an enterprise configuration using Thin Clients
or laptops with LUKS encryption, it could make sense though, but that isn't
the configuration that we natively support).
A few of the complications of systemd-homed include:
- SSH Logins
- Disk Space Assignments
- UID Assignments (chown() on login)
(See https://cfp.all-systems-go.io/media/homed-asg2019.pdf)
In an article I read when systemd-homed was originally unveiled, I remember
reading about systemd-homed causing problems with OpenSSH Private Key Auth
because the user would have to login at the console in order to unlock
their home directory, thus allowing the private key to be unlocked and
processed by OpenSSH. Since BLFS does not fully support encrypted disks,
and because systemd-homed is incompatible with our usage of useradd /
traditional UNIX users and groups, I advise that we take the following
approach to avoid any confusion:
- Leave the added Short Descriptions for homectl and userdbctl
- Add the above command explanations and restore the previous behavior
2021-09-07 01:42:49 +08:00
Should we decide to enable homed by default anytime in the future,
2020-03-21 12:35:03 +08:00
let's move cryptsetup to recommended or required.
I would be open to discussing this after the next systemd version when
systemd-homed has matured a bit more. -renodr -->
</sect2>
2016-06-02 13:39:31 +08:00
<sect2 role= "configuration" >
<title > Configuring systemd</title>
<para >
2017-04-05 22:05:08 +08:00
The <filename > /etc/pam.d/system-session</filename> file needs to
2016-06-02 13:39:31 +08:00
be modified and a new file needs to be created in order for
<command > systemd-logind</command> to work correctly. Run the following
commands as the <systemitem class= "username" > root</systemitem> user:
</para>
2021-12-09 19:52:04 +08:00
<screen role= "root" > <userinput > grep 'pam_systemd' /etc/pam.d/system-session ||
cat > > /etc/pam.d/system-session < < "EOF"
2016-06-02 13:39:31 +08:00
<literal > # Begin Systemd addition
2021-09-07 01:42:49 +08:00
2018-12-14 15:32:06 +08:00
session required pam_loginuid.so
session optional pam_systemd.so
2016-06-02 13:39:31 +08:00
# End Systemd addition</literal>
EOF
cat > /etc/pam.d/systemd-user < < "EOF"
<literal > # Begin /etc/pam.d/systemd-user
2018-12-14 15:32:06 +08:00
account required pam_access.so
account include system-account
2016-06-02 13:39:31 +08:00
2018-12-14 15:32:06 +08:00
session required pam_env.so
session required pam_limits.so
session required pam_loginuid.so
session optional pam_keyinit.so force revoke
session optional pam_systemd.so
2016-06-02 13:39:31 +08:00
2018-12-14 15:32:06 +08:00
auth required pam_deny.so
password required pam_deny.so
2016-06-02 13:39:31 +08:00
# End /etc/pam.d/systemd-user</literal>
EOF</userinput> </screen>
2024-01-20 08:59:51 +08:00
<!-- For some unknown reason if I don't do this, the per - user systemd
manager fails to start with "Trying to run as user instance,
but $XDG_RUNTIME_DIR is not set." This command is enough to
fix the issue, and it also seems logical to start using the newly
rebuilt systemd right away (like "exec bash -‐ login" in LFS),
so just add it. -->
<para >
As the &root; user, replace the running <command > systemd</command>
manager (the <command > init</command> process) with the
<command > systemd</command> executable newly built and installed:
</para>
<screen role= 'root' > <userinput > systemctl daemon-reexec</userinput> </screen>
<important >
<para >
Now ensure <xref linkend= 'shadow' /> has been already rebuilt with
<xref linkend= 'linux-pam' /> support first, then logout, and login
again. This ensures the running login session registered with
<command > systemd-logind</command> and a per-user systemd instance
running for each user owning a login session. Many BLFS packages
listing Systemd as a dependency needs the
<command > systemd-logind</command> integration and/or a running
per-user systemd instance.
</para>
</important>
2020-03-19 18:00:16 +08:00
<warning >
<para >
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.
</para>
</warning>
2016-06-02 13:39:31 +08:00
</sect2>
<sect2 role= "content" >
<title > Contents</title>
<para >
A list of the installed files, along with their short
descriptions can be found at
2020-08-21 20:19:40 +08:00
<ulink url= "&lfs-root;/chapter08/systemd.html#contents-systemd" /> .
2016-06-02 13:39:31 +08:00
</para>
<para >
2021-12-27 20:53:46 +08:00
Listed below are the newly installed programs
2016-06-02 13:39:31 +08:00
along with short descriptions.
</para>
<segmentedlist >
<segtitle > Installed Programs</segtitle>
<seglistitem >
<seg >
2020-03-20 10:45:12 +08:00
<!-- maybe userdbd/userdbctl can go in LFS, try at next time -->
2023-03-07 12:38:46 +08:00
homectl (optional),
2022-02-17 19:52:03 +08:00
systemd-cryptenroll (if <xref linkend= "cryptsetup" /> is installed),
2023-03-07 12:38:46 +08:00
and userdbctl (optional)
2016-06-02 13:39:31 +08:00
</seg>
</seglistitem>
</segmentedlist>
<variablelist >
<bridgehead renderas= "sect3" > Short Descriptions</bridgehead>
<?dbfo list-presentation="list"?>
<?dbhtml list-presentation="table"?>
2020-03-20 10:45:12 +08:00
<varlistentry id= "homectl" >
<term > <command > homectl</command> </term>
<listitem >
<para >
is a tool to create, remove, change, or inspect a home directory
managed by <command > systemd-homed</command> ; note that it's
useless for the classic UNIX users and home directories which
we are using in LFS/BLFS book
</para>
<indexterm zone= "systemd homectl" >
<primary sortas= "b-homectl" > homectl</primary>
</indexterm>
</listitem>
</varlistentry>
2022-02-17 19:52:03 +08:00
<varlistentry id= "systemd-cryptenroll" >
<term > <command > systemd-cryptenroll</command> </term>
<listitem >
<para >
Is used to enroll or remove a system from full disk encryption,
as well as set and query private keys and recovery keys
</para>
<indexterm zone= "systemd systemd-cryptenroll" >
<primary sortas= "b-systemd-cryptenroll" > systemd-cryptenroll</primary>
</indexterm>
</listitem>
</varlistentry>
2020-03-20 10:45:12 +08:00
<varlistentry id= "userdbctl" >
<term > <command > userdbctl</command> </term>
<listitem >
<para >
2020-08-12 08:55:24 +08:00
inspects users, groups, and group memberships
2020-03-20 10:45:12 +08:00
</para>
<indexterm zone= "systemd userdbctl" >
<primary sortas= "b-userdbctl" > userdbctl</primary>
</indexterm>
</listitem>
</varlistentry>
2016-06-02 13:39:31 +08:00
<varlistentry id= "pam_systemd" >
<term > <filename class= "libraryfile" > pam_systemd.so</filename> </term>
<listitem >
<para >
is a PAM module used to register user sessions with the
<application > systemd</application> login manager,
2021-02-19 23:20:16 +08:00
<command > systemd-logind</command>
2016-06-02 13:39:31 +08:00
</para>
<indexterm zone= "systemd pam_systemd" >
<primary sortas= "c-pam_systemd" > pam_systemd.so</primary>
</indexterm>
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1>