[lfs-support] [blfs-support] LFS SVN-20130125 + Systemd HowTo

Armin K. krejzi at email.com
Sun Jan 27 10:09:20 PST 2013


On 01/27/2013 06:34 PM, Armin K. wrote:
> Hello, I have taken some time to write a howto for LFS + Systemd.
>
> The instructions follow LFS BOOK versioned SVN-20130125 with additions
> from BLFS BOOK versioned 2013-01-26.
>
> Packages are installed in same order as alwas, mentioned versions were
> used without any modifications to the LFS book ones. I did some
> diversions and I've mentioned them below.
>
> Packages were added in specified place for a reason, I think I explained
> it for attr, acl and libcap2.
>
> Howto starts from Chapter 6, assuming everything else has been done as
> before.
>
> 6.6. Creating Essential Files and Symlinks
>
> change "touch /etc/mtab" to "ln -s /proc/self/mounts /etc/mtab"
>
> Proceed with the Book
>
> linux 3.7.4 api headers
> man-pages 3.45
> glibc 2.17
> zlib 1.27
> file 5.11
> binutils 2.23.1
> gmp 5.1.0
> mpfr 3.1.1
> mpc 1.0.1
> gcc 4.7.2
> sed 4.2.2
> bzip2 1.0.6
> pkg-config 0.28
> ncurses 5.9
> util-linux 2.22.2
> psmisc 2.20
> procps 3.3.6
> e2fsprogs 1.42.7
>
> (Not sure about this, but it could be possible that attr and acl need
> msgfmt, msgmerge and xgettext binaries from gettext package - I've
> installed all binaries from gettext in temporary stage so I can't
> confirm. I do remember that I had some problems with this in the past)
>
> attr 2.4.46 http://www.linuxfromscratch.org/blfs/view/svn/postlfs/attr.html
> acl 2.2.51
> http://www.linuxfromscratch.org/blfs/view/svn/postlfs/acl.html (This one
> is not stricly required for systemd - but I installed it so Coreutils,
> Shadow and Systemd might benefit from it as well from libcap2).
> libcap2 2.22
> http://www.linuxfromscratch.org/blfs/view/svn/postlfs/libcap2.html
>
> shadow 4.1.5.1
> coreutils 8.20 (without coreutils-8.20-i18n-1.patch)
> iana-etc 2.30
> m4 1.4.16
> bison 2.7
> grep 2.14
> readline 6.2
> bash 4.2
> libtool 2.4.2
> gdbm 1.10
> inetutils 1.9.1
> perl 5.16.2
> autoconf 2.69
> automake 1.13.1
> diffutils 3.2
> gawk 4.0.2
> findutils 4.4.2
> flex 2.5.37
> gettext 0.18.2
> groff 1.22.1
> xz 5.0.4
> grub 2.0.0
> less 451
> gzip 1.5
> iproute2 3.7.0
> kbd 1.15.5 (without kbd-1.15.5-backspace-1.patch)
> kmod 12
> libpipeline 1.2.2
> make 3.82
> man-db 2.6.3
> patch 2.7.1
> sysklogd 1.5 - Removed
> Sysvinit 2.88dsf (I choose to install few support programs from this
> package, like sulogin, mesg, pidof, last, fstab-decode and killall5 - I
> usually enable mesg and sulogin at util-linux stage though so no need
> for it from this package)
>
> make -C src
>
> cp -v src/last src/mesg /usr/bin
> ln -sfv last /usr/bin/lastb
>
> cp -v src/fstab-decode src/killall5 src/sulogin /sbin
> ln -sfv ../sbin/killall5 /bin/pidof
>
> cp -v man/{last,lastb,mesg}.1 /usr/share/man/man1
> cp -v man/{fstab-decode,killall5,pidof,sulogin}.8 /usr/share/man/man8
>
> tar 1.26
> texinfo 4.13a
>
> udev 197 (extracted from systemd) - Removed
> vim 7.3 - Removed in my setup - Replaced with nano 2.3.1
> http://www.linuxfromscratch.org/blfs/view/svn/postlfs/nano.html
>
> dhcp 4.2.5
> http://www.linuxfromscratch.org/blfs/view/svn/basicnet/dhcp.html (My
> connection uses DHCP - client only with ifup script and configuration
> for eth0)
>
> expat 2.1.0
> http://www.linuxfromscratch.org/blfs/view/svn/general/expat.html
> dbus 1.6.8 http://www.linuxfromscratch.org/blfs/view/svn/general/dbus.html
>
> Only difference now is that --without-systemdsystemunitdir becomes
> --with-systemdsystemunitdir=/lib/systemd/system
>
> Final configure script looks like
>
> ./configure --prefix=/usr \
>              --sysconfdir=/etc \
>              --localstatedir=/var \
>              --libexecdir=/usr/lib/dbus-1.0 \
>              --with-console-auth-dir=/run/console/ \
>              --with-systemdsystemunitdir=/lib/systemd/system \
>              --disable-systemd \
>              --disable-static
>
> --disable-systemd is still there because Systemd requires D-Bus and
> D-Bus requires Systemd for certain functionality only. It does not see
> any use in LFS since it uses logind which we will disable in lfs because
> it would need PAM to work like it should.
>
> D-Bus should be recompiled in BLFS for dbus-launch binary with "Xorg
> Libraries" as dependency and --disable-systemd should be removed there
> after Systemd has been fully rebuilt for BLFS (Including PAM and some
> other deps like Glib and G-I for GUdev and so on).
>
> gperf 3.0.4
> http://www.linuxfromscratch.org/blfs/view/svn/general/gperf.html
> xml-parser 2.41
> http://www.linuxfromscratch.org/blfs/view/svn/general/perl-modules.html
> intltool 0.50.2
> http://www.linuxfromscratch.org/blfs/view/svn/general/intltool.html
>
> systemd 197
>
> Journald appears to look for "adm" group, so add it (gid is reserved in
> BLFS specificaly for this group)
>
> groupadd -g 16 adm
>
> ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
> --libexecdir=/usr/lib --with-rootprefix= --with-rootlibdir=/lib
> --with-kbd-loadkeys=/bin/loadkeys --with-kbd-setfont=/bin/setfont
> --enable-split-usr --disable-static --disable-gudev --without-python
>
> make
>
> make check # triggers the testsuite but it appears to fail 5 tests.
>
> make install
> sed "s at 0775 root lock at 0755 root root at g" -i
> /usr/lib/tmpfiles.d/legacy.conf #1
> mkdir -p /var/log/journal #2
systemd-machine-id-setup #3
>
> #1 (So we don't add "lock" group).
> #2 (By default, journal logs to tmpfs at /run - not useful if you want
> to keep your logs, so create the directory /var/log/journal to keep your
> logs there - configurability +1 :P)
#3 And I wondered why journald started throwing errors at first boot. I 
forgot to setup /etc/machine-id.
 >
> package contents are attached - not including compatibility stuff.
>
> # Compatiblity stuff
>
> mv -v /usr/bin/udevadm /sbin
> ln -sfv ../../sbin/udevadm /usr/bin/udevadm
>
> sed -i "s@/usr/bin/udevadm@/sbin/udevadm at g"
> /lib/systemd/system/systemd-udev-settle.service
> sed -i "s@/usr/bin/udevadm@/sbin/udevadm at g"
> /lib/systemd/system/systemd-udev-trigger.service
>
> ln -sfv ../lib/systemd/systemd /bin/systemd
> ln -sfv ../lib/systemd/systemd-udevd /sbin/udevd
>
> for tool in runlevel reboot shutdown poweroff halt telinit; do
>      ln -sfv ../bin/systemctl /sbin/$tool
> done
>
> ln -sfv ../lib/systemd/systemd /sbin/init
>
> All systemd man pages are available online at
> http://www.freedesktop.org/software/systemd/man/
> libxslt and docbook are required to build them.
>
> Also, I have verified that it is possible to overwrite Systemd just at
> runtime without triggering kernel panic or whatever. Very useful if you
> want to rebuild Systemd later with more deps. It's useful to have Linux
> PAM for the PAM module - required for logind to register user sessions,
> GLib and G-I for GNOME and maybe some else you'll find useful - examine
> README file for list of deps.
>
> You'll also want to rebuild D-Bus with X11 deps as well as Systemd dep.
> Do note that lot of packages in BLFS can suppport Systemd out of date
> and ship Systemd units.
>
> # Continuing with the book
>
> 7.2. General Network Configuration - No-go, I didn't install persistent
> rules generators.
> 7.3. Customizing the /etc/hosts File - Network Card Version - Including
> ::1 -> localhost for IPv6 and 127.0.1.1 -> actual hostname.
> 7.5. Creating Custom Symlinks to Devices - Mostly No-go, no persistent
> cd rules generator.
>
> 7.6. LFS-Bootscripts-20130123
>
> I only installed ifup and ifdown from there along with necesary services.
>
> make install DESTDIR=$PWD/dest
>
> rm -rf dest/etc
>
> cp -av dest/* /
>
> /etc/sysconfig/createfiles has been replaced with /etc/tmpfiles.d/*.conf
> (See tmpfiles.d.5 man page (not installed with our basic setup) or
> http://www.freedesktop.org/software/systemd/man/tmpfiles.d.html)
>
> /etc/sysconfig/modules has been replaced with /etc/modules-load.d/*.conf
> (See modules-load.d.5 man page (not installed with our basic setup) or
> http://www.freedesktop.org/software/systemd/man/modules-load.d.html)
>
> Create networking unit
>
> echo "d /run/var 0755 root root -" > /etc/tmpfiles.d/ifupdown.conf &&
> cat > /lib/systemd/system/ifupdown at .service << EOF
> [Unit]
> Description=Start ifupdown for %i
> Requires=sys-subsystem-net-devices-%i.device
> After=sys-subsystem-net-devices-%i.device
>
> [Service]
> ExecStart=/sbin/ifup %i
> ExecStop=/sbin/ifdown %i
> RemainAfterExit=true
>
> [Install]
> WantedBy=multi-user.target
> EOF
>
> Enable networking for any device by executing:
>
> systemctl enable ifupdown at eth0
>
> Disable it by executing
>
> systemctl disable ifupdown at eth0
>
> Replace eth0 with your actual interface (In my case it was ens33 - the
> hell?).
>
> 7.7. How Do These Bootscripts Work? - No-go
> 7.8. Configuring the system hostname
>
> Now it is just "echo myhostname > /etc/hostname"
>
> 7.9. Configuring the setclock Script
>
> Systemd should configure clock by itself. You can change its behaviour
> with /etc/adjtime
>
> For non-UTC hwclock
>
> cat > /etc/adjtime << EOF
> 0.0 0 0.0
> 0
> LOCAL
> EOF
>
> For UTC hwclock
>
> cat > /etc/adjtime << EOF
> 0.0 0 0.0
> 0
> UTC
> EOF
>
> Yes, it's /etc/adjtime despite having corrected it in util-linux
> instructions to /var/lib/hwclock/adjtime. Nothing gets written in it
> though.
>
> 7.10. Configuring the Linux Console
>
> Systemd uses /etc/vconsole.conf in order to configure the console.
> Examine vconsole.conf.5 man page or
> http://www.freedesktop.org/software/systemd/man/vconsole.conf.html
>
> Short:
>
> KEYMAP= and FONT= is the same as in LFS console, they just go in
> /etc/vconsole.conf instead of /etc/sysconfig/console
>
> An example for Croatian keyboard layout and the font I use is the
> following:
>
> KEYMAP=croat
> FONT=lat2-16
> FONT_MAP=8859-2
>
> 7.11. Configuring the sysklogd Script - No-go
> 7.12. The rc.site File - No-go
> 7.13. The Bash Shell Startup Files
>
> The same would apply for Systemd when setting locale, but instead LANG
> variables should go in /etc/locale.conf instead of /etc/profile and
> "export LANG=" would change only to "LANG="
>
> See locale.conf.5 man page or
> http://www.freedesktop.org/software/systemd/man/locale.conf.html
>
> An example for en_US.UTF-8 locale is:
>
> echo "LANG=en_US.UTF-8" > /etc/locale.conf
>
> 7.14. Creating the /etc/inputrc File - Same as always
>
> 8.2. Creating the /etc/fstab File
>
> You can omit anything but your rootfs, swap and other partitions since
> Systemd handles procfs, sysfs, tmpfs, devtmpfs by itself.
>
> cat > /etc/fstab << "EOF"
> # Begin /etc/fstab
>
> # file system  mount-point  type     options             dump  fsck
> #                                                              order
>
> /dev/<xxx>     /            <fff>    defaults            1     1
> /dev/<yyy>     swap         swap     pri=1               0     0
>
> # End /etc/fstab
> EOF
>
> Please note that systemd will mount /tmp as tmpfs too. If you don't want
> it to mount a tmpfs there, just remove
> /lib/systemd/system/local-fs.target.wants/tmp.mount
>
> 8.3. Linux-3.7.4
>
> I'll just go through few options that should really be enabled.
>
> General Setup - Enable system-call auditing support # (Not sure about
> this but it created some nasty issues with ConsoleKit when running
> without this, maybe it can create some for Systemd, too).
>
> General Setup - Control Group support # (No controlers are required, but
> I usually enable General Setup - Automatic process group scheduling so
> Group CPU scheduler is enabled by default).
>
> Network - Networking Options - The IPv6 protocol # (Not required but
> strongly recommended by README file).
> File Systems - Kernel automounter version 4 support (also supports v3) #
> (Same as for IPv6 support - strongly recommended).
>
> Device Drivers - Generic Driver Options ->
>
> () path to uevent helper # Should be empty
> [*] Maintain a devtmpfs filesystem to mount at /dev
> [*]   Automount devtmpfs at /dev, after the kernel mounted the rootfs #
> (not listed in README, but once Systemd didn't mount devtmpfs on /dev so
> I selected it).
>
> Some of the other features Systemd can utilize
>
> Security Options - Enable the securityfs filesystem # Mounted by default
> and can't be overriden - It is safe if you disable it though.
> File Systems - Quota support # Systemd supports Quota checks.
> File Systems - FUSE (Filesystem in Userspace) support # Systemd mounts
> fuse control automagicaly.
> File Systems - Pseudo File Systems - HugeTLB file system support # It is
> enabled by default and mounted if support is available. Can be disabled,
> no harm if it's not present.
>
> And of course, anything else your hardware needs.
>
> 9.1. The End - Same as always, but I added this file, too
>
> cat > /etc/os-release << EOF
> NAME="Linux From Scratch"
> ID=lfs
> PRETTY_NAME="Linux From Scratch"
> ANSI_COLOR="1;33"
> EOF
>
> You can change anything you want here.
>
> In a VMWare Player, LFS system installed with instructions above takes
> 15 sec to boot, with 14 seconds to the kernel part (before starting
> Systemd - I was lazy to optimize kernel). Systemd takes 1.3 seconds from
> executing /sbin/init (with some modules enabled, too) to the getty.
>
> Any feedback is welcome. I am not even sorry for grammatical mistakes.
>
> And no, ranting is not welcome. Please use the howto and give feedback
> or don't use the howto and be quiet.
>
> I don't need any more rants like "Why the hell would I want
> systemd/dbus/libcap/expat/whatever on my system" - It's your system your
> rules man, no one ever said I want to put these instructions in the
> book. Just a howto for people who want to try Systemd (and maybe profit).
>
> This howto is specifically written for Bruce - He said that he didn't
> like vi and he got used to it after he tried vi improved, so maybe
> that'll be the case with Systemd, too (Just kidding man).
>
>




More information about the lfs-support mailing list