%general-entities; ]> Introduction Booting a Linux system involves several tasks. The process must mount both virtual and real file systems, initialize devices, activate swap, check file systems for integrity, mount any swap partitions or files, set the system clock, bring up networking, start any daemons required by the system, and accomplish any other custom tasks needed by the user. This process must be organized to ensure the tasks are performed in the correct order but, at the same time, be executed as fast as possible. In the packages that were installed in Chapter 6, there were two different boot systems installed. LFS provides the ability to easily select which system the user wants to use and to compare and contrast the two systems by actually running each system on the local computer. The advantages and disadvantages of these systems is presented below. System V System V is the classic boot process that has been used in Unix and Unix-like systems such as Linux since about 1983. It consists of a small program, init, that sets up basic programs such as login (via getty) and runs a script. This script, usually named rc, controls the execution of a set of additional scripts that perform the tasks required to initialize the system. The init program is controlled by the /etc/inittab file and is organized into run levels that can be run by the user: 0 — halt 1 — Single user mode 2 — Multiuser, without networking 3 — Full multiuser mode 4 — User definable 5 — Full multiuser mode with display manager 6 — reboot The usual default run level is 3 or 5. Advantages Established, well understood system. Easy to customize. Disadvantages Slower to boot. A medium speed base LFS system takes 8-12 seconds where the boot time is measured from the first kernel message to the login prompt. Network connectivity is typically established about 2 seconds after the login prompt. Serial processing of boot tasks. This is related to the previous point. A delay in any process such as a file system check, will delay the entire boot process. Does not directly support advanced features like control groups (cgroups), and per-user fair share scheduling. Adding scripts requires manual, static sequencing decisions. Systemd Systemd is a group of interconnected programs that handles system and individual process requests. It provides a dependency system between various entities called "units". It automatically addresses dependencies between units and can execute several startup tasks in parallel. It provides login, inetd, logging, time, and networking services. Advantages Used on many established distributions by default. There is extensive documentation. See . Parallel execution of boot processes. A medium speed base LFS system takes 6-10 seconds from kernel start to a login prompt. Network connectivity is typically established about 2 seconds after the login prompt. More complex startup procedures may show a greater speedup when compared to System V. Implements advanced features such as control groups to manage related processes. Maintains backward compatibility with System V programs and scripts. Disadvantages There is a substantial learning curve. Some advanced features such as dbus or cgroups cannot be disabled if they are not otherwise needed. Although implemented as several executable programs the user cannot choose to implement only the portions desired. Due to the nature of using compiled programs, systemd is more difficult to debug. Logging is done in a binary format. Extra tools must be used to process logs or additional processes must be implemented to duplicate traditional logging programs. Selecting a Boot Method Selecting a boot method in LFS is relatively easy. Both systems are installed side-by-side. The only task needed is to ensure the files that are needed by the system have the correct names. The following scripts do that. cat > /usr/sbin/set-systemd << "EOF" #! /bin/bash ln -svfn init-systemd /sbin/init ln -svfn init.d-systemd /etc/init.d for tool in halt poweroff reboot runlevel shutdown telinit; do ln -sfvn ${tool}-systemd /sbin/${tool} ln -svfn ${tool}-systemd.8 /usr/share/man/man8/${tool}.8 done echo "Now reboot with /sbin/reboot-sysv" EOF chmod 0744 /usr/sbin/set-systemd cat > /usr/sbin/set-sysv << "EOF" #! /bin/bash ln -sfvn init-sysv /sbin/init ln -svfn init.d-sysv /etc/init.d for tool in halt poweroff reboot runlevel shutdown telinit; do ln -sfvn ${tool}-sysv /sbin/${tool} ln -svfn ${tool}-sysv.8 /usr/share/man/man8/${tool}.8 done echo "Now reboot with /sbin/reboot-systemd" EOF chmod 0744 /usr/sbin/set-sysv Now set the desired boot system. The default is System V: /usr/sbin/set-sysv Changing the boot system can be done at any time by running the appropriate script above and rebooting.