From Power-On to Shell: The Full Boot Chain
From Power-On to Shell: The Full Boot Chain
The journey from pressing the physical power button on a computer to receiving an interactive shell prompt involves a relay race of hardware, firmware, bootloaders, kernel subsystems, and userspace processes.
+-------------------------------------------------------------+
| 1. Firmware Initialization (UEFI / BIOS) |
| - Power-On Self Test (POST) |
| - Reads NVRAM boot entries; locates EFI System Partition |
+-------------------------------------------------------------+
|
v
+-------------------------------------------------------------+
| 2. Bootloader Stage (GRUB / systemd-boot) |
| - Loads vmlinuz and initramfs into physical RAM |
| - Passes command line parameters (root=..., quiet) |
+-------------------------------------------------------------+
|
v
+-------------------------------------------------------------+
| 3. Kernel Early Boot (Ring 0) |
| - Unpacks self, sets up page tables and interrupt tables |
| - Detects CPU cores, initializes memory and devices |
| - Unpacks initramfs into rootfs (tmpfs) |
| - Executes /init in early userspace |
+-------------------------------------------------------------+
|
v
+-------------------------------------------------------------+
| 4. Early Userspace (Initramfs) |
| - Loads storage drivers, mounts LUKS / LVM / ZFS / NFS |
| - Mounts real root filesystem to /newroot |
| - Executes pivot_root or switch_root to /newroot/sbin/init|
+-------------------------------------------------------------+
|
v
+-------------------------------------------------------------+
| 5. System Initialization (PID 1) |
| - Remounts root read-write, mounts /proc, /sys, /dev |
| - Launches udev / mdev for device rules |
| - Starts network, system daemons, display manager |
| - Spawns agetty on virtual consoles (tty1) -> Shell! |
+-------------------------------------------------------------+
The Baton Pass
Notice how every stage has a single purpose: load the next, more capable stage, and get out of the way: 1. UEFI initializes basic memory and PCI buses, then launches the bootloader. 2. The bootloader reads the filesystem of /boot, loads the compressed kernel and initramfs into memory, and jumps to the kernel’s entry point. 3. The kernel initializes drivers and memory, then executes /init inside the temporary in-memory initramfs. 4. The initramfs script resolves complex storage (decryption, RAID assembly, network mounts), mounts the permanent root disk, and executes switch_root. 5. switch_root wipes the temporary initramfs from memory and replaces the running process with the real /sbin/init (PID 1). 6. PID 1 manages services, configures networking, and spawns login prompts.