Booting RHEL 7 / CentOS 7 / SL 7 with systemd

When you boot a standard X86 computer to run RHEL 7, the BIOS boots from the selected medium (usually a local hard disk) and the boot loader (GRUB2 for RHEL 7) starts the RHEL 7 kernel and initial RAM disk. After that, the systemd process takes over to initialize the system and start all the system services.

Although there is not a strict order in which services are started when a RHEL 7 (systemd) system is booted, there is a structure to the boot process. The direction that the systemd process takes at boot time depends on the file. A long listing of the file shows you which target starts when the system boots:

# cd /etc/systemd/system
# ls -l 
lrwxrwxrwx. 1 root root 16 Aug 23 19:18 -> /lib/systemd/system/

You can see here that the (common for desktop systems or servers with graphical interfaces) is set as the (via a symbolic link). To understand what targets, services and other units start up with the graphical target, it helps to work backwards, as systemd does, to build the dependency tree. Here's what to look for:

  • The /lib/systemd/system/ file includes these lines:
    Conflicts=rescue.service rescue.service display-manager.service

    This tells systemd to start everything in the before starting the graphical target. Once that's done, the "Wants" entry tells systemd to start the display-manager.service service (/etc/systemd/system/display-manager.service), which runs the GNOME display manager (/usr/sbin/gdm).

  • The /usr/lib/systemd/system/ starts the services you would expect in a RHEL multi-user mode. The file contains the following line:

    This tells systemd to start everything in the /usr/lib/systemd/system/ target before starting the other multi-user services. After that, for the, all units (services, targets, etc.) in the /etc/systemd/system/ and /usr/lib/systemd/system/ directories are started. When you enable a service, a symbolic link is placed in the /etc/systemd/system/ directory. That directory is where you will find links to most of the services you think of as starting in multi-user mode (printing, cron, auditing, SSH, and so on). Here is an example of the services, paths, and targets in a typical directory:

    # cd /etc/systemd/system/
    abrt-ccpp.service      hypervkvpd.service        postfix.service
    abrtd.service          hypervvssd.service
    abrt-oops.service      irqbalance.service        rhsmcertd.service
    abrt-vmcore.service    ksm.service               rngd.service
    abrt-xorg.service      ksmtuned.service          rpcbind.service
    atd.service            libstoragemgmt.service    rsyslog.service
    auditd.service         libvirtd.service          smartd.service
    avahi-daemon.service   mdmonitor.service         sshd.service
    chronyd.service        ModemManager.service      sysstat.service
    crond.service          netcf-transaction.service tuned.service
    cups.path                    vmtoolsd.service
  • The /usr/lib/systemd/system/ file starts the basic services associated with all running RHEL 7 systems. The file contains the following line:

    This points systemd to the /usr/lib/systemd/system/, which must start before the can continue. The target file starts the firewalld and microcode services from the /etc/systemd/system/ directory and services for SELinux, kernel messages, and loading modules from the /usr/lib/systemd/system/ directory.

  • The /usr/lib/systemd/system/ file starts system initialization services, such as mounting file systems and enabling swap devices. The file contains the following line:

    Besides mounting file systems and enabling swap devices, the starts targets, services, and mounts based on units contained in the /usr/lib/systemd/system/ directory. These units enable logging, set kernel options, start the udevd daemon to detect hardware, and allow file system decryption, among other things. The /etc/systemd/system/ directory contains services that start iSCSI, multipath, LVM monitoring and RAID services.

  • The is set to run after the target, based on this line:

    There are no services associated with the target (you could add some to a "wants" directory if you like). However, units in the /usr/lib/systemd/system/ directory import the network configuration from the initramfs, run a file system check (fsck) on the root file system when necessary, and remounting the root file system (and special kernel file systems) based on the contents of the /etc/fstab file.

Although the boot process is built by systemd in the order just shown, it actually runs, in general, in the opposite order. As a rule, a target on which another target is dependent must be running before the units in the first target can start. To see more details about the boot process, see the bootup man page (man 7 bootup).

Comments powered by CComment