Linux Boot Process
BIOS/UEFI → GRUB2 → kernel → initramfs → systemd: understanding every stage of boot.
Overview
Overview Understanding the Linux boot process helps diagnose startup failures and tune boot performance.
Stage 1 — POST and firmware: Power-On Self Test runs, then BIOS or UEFI firmware takes over. BIOS uses MBR (Master Boot Record, first 512 bytes of disk), limited to 4 primary partitions and 2TB disks. UEFI supports GPT (GUID Partition Table), Secure Boot (cryptographic signature verification of bootloader), and reads the EFI System Partition (ESP, typically /boot/efi, FAT32 formatted).
Stage 2 — GRUB2: The bootloader. In BIOS mode, GRUB stage 1 lives in the MBR and loads stage 1.5 from the gap after MBR, which loads stage 2 from /boot/grub/. In UEFI mode, GRUB lives on the ESP as a .efi file. GRUB reads /boot/grub/grub.cfg (generated by update-grub or grub2-mkconfig, never edited directly) to display the boot menu. Kernel parameters are passed here (root=UUID=..., ro, quiet, splash, init=/path for alternative init).
Stage 3 — Kernel initialization: GRUB decompresses the kernel image (vmlinuz) into RAM and passes control. The kernel initializes CPU, memory management, and devices. It mounts the initramfs (initial RAM filesystem) as a temporary root.
Stage 4 — initramfs: A small, compressed cpio archive containing just enough tools and drivers to mount the real root filesystem (drivers for disk controllers, LVM, RAID, crypto). After mounting real root, it performs pivot_root to switch over.
Stage 5 — systemd: PID 1 takes over, reads unit files, starts services in dependency order to reach the default target (usually multi-user.target or graphical.target). systemd-analyze blame shows which services are slowest to start.
Key concepts
- UEFI vs BIOS
- GRUB2
- initramfs
- systemd targets vs runlevels
Interview questions
- Describe every step from pressing the power button to the login prompt appearing.
- What is initramfs and why does Linux need it?
Sign up free to read the full topic
More Linux topics
Start free on Cariara · Coding problems · System design studio