Here is the detailed, step-by-step breakdown of the modern Linux boot process (specifically utilizing UEFI, GPT, GRUB2, and systemd as found in modern Red Hat Enterprise Linux 8/9 and other current distributions).
When you press the power button, the motherboard firmware takes control.
- Power-On Self-Test (POST): The UEFI firmware initializes core hardware components (CPU, RAM, storage controllers, and PCIe devices) to ensure the system is stable enough to run.
- NVRAM Reading: Unlike legacy BIOS which blindly searches the first sectors of a disk, UEFI reads boot entries stored in its own onboard non-volatile RAM (NVRAM).
- Accessing the ESP: UEFI looks for a specific partition format on the storage drive called the EFI System Partition (ESP). This partition must be formatted as FAT32 and resides on a GPT (GUID Partition Table) disk.
- Loading the EFI App: UEFI locates the bootloader executable file (typically grubx64.efi for 64-bit systems, or a Secure Boot shim like shimx64.efi) inside the ESP directory (e.g., /boot/efi/EFI/redhat/) and executes it.
The bootloader acts as the bridge between the motherboard firmware and the operating system.
- Configuration Read: GRUB2 initializes and searches for its configuration file (on RHEL, this is usually /boot/grub2/grub.cfg or dynamically managed under /boot/loader/entries/).
- OS Selection Menu: If configured, GRUB2 displays the menu screen allowing you to choose different kernel versions, recovery modes, or other operating systems.
- Loading Components into RAM: Once a choice is made, GRUB2 performs two critical actions:
- It extracts and loads the compressed Linux Kernel image (e.g., vmlinuz-xxx) into system memory. 2. It loads the initial RAM filesystem (initramfs-xxx) image right alongside it.
- Hand-off: GRUB2 passes execution control to the kernel, along with "kernel command-line arguments" (like ro for read-only, quiet to suppress text, or rhgb for Red Hat graphical boot).
The kernel is now alive, but it lacks the heavy storage drivers needed to talk to your actual root filesystem.
- Hardware Probing: The kernel uncompresses itself, takes over CPU management, sets up memory pages, and probes the hardware buses to detect devices.
- Mounting initramfs: Because the kernel doesn't yet have the drivers to read complex storage arrays (like LVM, RAID, or encrypted partitions), it mounts the initramfs (which was loaded into RAM by GRUB2) as a temporary, virtual root filesystem.
- Running the Temporary systemd: A micro-version of systemd runs inside this RAM disk. It loads essential storage drivers (e.g., NVMe, SCSI, device-mapper) and opens up the real drive.
- The Pivot (Switch Root): Once the real storage drive is accessible, the temporary systemd clears itself out of memory, mounts the real root filesystem (usually at /), and execution shifts to the true /usr/lib/systemd/systemd binary on the physical disk.
The true OS environment begins starting background services, utilizing parallel processing to speed up boot times.
- PID 1: The real systemd process takes over as Process ID 1, the parent of all other processes on the system.
- Target Assessment: systemd looks at its configuration to determine the Default Target (analogous to legacy runlevels):
- multi-user.target: Standard text-based CLI environment for servers.
- graphical.target: Desktop GUI environment.
- Dependency Resolution: systemd builds a dependency tree of "units" (services, mount points, sockets). It spawns independent services simultaneously (in parallel) to drastically cut boot times.
- Final Storage Mounts: It processes /etc/fstab to securely mount all remaining local disks, network shares, and swap spaces.
The system transitions from an automated machine boot to human interaction.
- Target Reached: Once all required services for the target are loaded, the system drops into the login state.
- For CLI Mode (multi-user.target): systemd spawns agetty processes on virtual terminals (TTYs), presenting the classic text login: prompt.
- For GUI Mode (graphical.target): systemd launches the Display Manager service (such as GDM on RHEL/GNOME, or SDDM). The graphical greeter appears, waiting for you to enter your username and password.
To help visualize this whole timeline from power-on to desktop, here is a functional diagram tracking the ownership shift across the four distinct pillars of the modern boot chain:
systemctl get-default
sudo systemctl set-default graphical.target
sudo systemctl set-default multi-user.target