Step by Step Linux Boot Process (Centos/Rhel 8)
Step by Step Linux Boot Process (Centos/Rhel 8)
Modern computer systems are complex combinations of hardware and software. Starting from
an undefined, powered-down state to a running system with a login prompt requires many pieces
of hardware and software to work together. The following list gives a high-level overview of the
tasks involved for a physical x86_64 system booting Red Hat Enterprise Linux 8. The list
for x86_64 virtual machines is roughly the same, but the hypervisor handles some of the
hardware-specific steps in the software.
POST
The machine is powered on. The system firmware, either modern UEFI or older BIOS, runs a
Power On Self Test (POST) and starts to initialize some of the hardware.
Configured using the system BIOS or UEFI configuration screens that you typically reach by
pressing a specific key combination, such as F2, early during the boot process.
MBR
The system firmware searches for a bootable device, either configured in the UEFI boot
firmware or by searching for a Master Boot Record (MBR) on all disks, in the order configured
in the BIOS.
Configured using the system BIOS or UEFI configuration screens that you typically reach by
pressing a specific key combination, such as F2, early during the boot process.
GRUB2
The system firmware reads a boot loader from disk and then passes control of the system to the
boot loader. On a CentOS/RHEL 8 system, the boot loader is the GRand Unified Bootloader
version 2 (GRUB2).
Configured using the grub2-install command, which installs GRUB2 as the boot loader on the
disk.
GRUB2 loads its configuration from the /boot/grub2/grub.cfg file and displays a menu where
you can select which kernel to boot.
Kernel
After you select a kernel, or the timeout expires, the boot loader loads the kernel
and initramfs from disk and places them in memory. An initramfs is an archive containing the
kernel modules for all the hardware required at boot, initialization scripts, and more. On Red Hat
Enterprise Linux 8, the initramfs contains an entire usable system by itself.
systemd
The systemd instance from the initramfs executes all units for the initrd.target target. This
includes mounting the root file system on disk on to the /sysroot directory.
Configured using /etc/fstab
– The kernel switches (pivots) the root file system from initramfs to the root file system in /
sysroot. systemd then re-executes itself using the copy of systemd installed on the disk.
– systemd looks for a default target, either passed in from the kernel command line or
configured on the system, then starts (and stops) units to comply with the configuration for that
target, solving dependencies between units automatically. In essence, a systemd target is a set of
units that the system should activate to reach the desired state. These targets typically start a
text-based login or a graphical login screen.
Configured using /etc/systemd/system/default.target and /etc/systemd/system/.
Rebboting and Shutting Down
To power off or reboot a running system from the command line, you can use
the systemctl command. systemctl poweroff stops all running services, unmounts all file
systems (or remounts them read-only when they cannot be unmounted), and then powers down
the system. systemctl reboot stops all running services, unmounts all file systems, and then
reboots the system.
You can also use the shorter version of these commands, poweroff and reboot, which are
symbolic links to their systemctl equivalents.
note: systemctl halt and halt are also available to stop the system, but unlike poweroff, these
commands do not power off the system; they bring a system down to a point where it is safe to
power it off manually.
Selecting a systemd target
A systemd target is a set of systemd units that the system should start to reach a desired state.
The following table lists the most important targets.
TARGET PURPOSE
emergency.target sulogin prompt, initramfs pivot complete, and system root mounted on /
read only.
A target can be a part of another target. For example, the graphical.target includes
multiuser.target, which in turn depends on basic.target and others. You can view these
dependencies with the following command.
Isolating a target stops all services not required by that target (and its dependencies), and starts
any required services not yet started. Not all targets can be isolated. You can only isolate targets
that have AllowIsolate=yes set in their unit files. For example, you can isolate the graphical
target, but not the cryptsetup target.
When the system starts, systemd activates the default.target target. Normally the default target
in /etc/systemd/system/ is a symbolic link to either graphical.target or multiuser.target.
Instead of editing this symbolic link by hand, the systemctl command provides two
subcommands to manage this link: get-default and set-default.
To select a different target at boot time, append the systemd.unit=target.target option to the
kernel command line from the boot loader. For example, to boot the system into a rescue shell
where you can change the system configuration with almost no services running, append the
following option to the kernel command line from the boot loader.
systemd.unit=rescue.target
This configuration change only affects a single boot, making it a useful tool for troubleshooting
the boot process. To use this method of selecting a different target, use the following procedure: