Boot#
The Linux boot sequence brings a powered-off machine to a running system in a small number of well-defined stages (firmware → bootloader → kernel → initramfs → init). Each stage hands control to the next. Understanding where it is in the chain is the first step in diagnosing a boot failure.
flowchart LR
FW["Firmware<br/>BIOS / UEFI"] --> BL["Bootloader<br/>GRUB / systemd-boot"]
BL --> KR["Kernel<br/>vmlinuz"]
KR --> IR["Initramfs<br/>/init"]
IR --> IT["Init<br/>systemd, PID 1"]
Boot Sequence#
Linux boot runs in five standard stages, in order, each preparing the conditions the next depends on. Knowing which stage you are in narrows any failure to a handful of likely causes before you start digging into logs.
Stage |
What happens |
|---|---|
|
BIOS or UEFI runs, performs POST, finds a boot device |
|
Loaded from disk; locates and loads the kernel + initramfs |
|
Decompresses, initializes hardware, mounts initramfs |
|
Provides drivers / decryption / LVM to mount the real root |
|
|
1. Firmware#
The firmware (BIOS or UEFI) is the first code to run after power-on.
It performs POST, enumerates devices, and selects a boot source. UEFI
loads a .efi from the ESP via NVRAM BootOrder. Legacy BIOS
reads MBR boot code. Secure Boot verifies the loader’s signature when
enabled.
Step |
What happens |
|---|---|
|
CPU jumps to its reset vector and runs firmware ROM |
|
BIOS/UEFI POST checks CPU, memory, integrated devices |
|
Buses are scanned; storage, NICs, USB are registered |
|
UEFI consults NVRAM |
|
UEFI loads |
The firmware is the first code that runs after power-on. Modern systems use UEFI; legacy systems used BIOS. Both probe attached devices, expose a small runtime to the OS, and hand control to a bootloader once a valid boot source has been selected.
Component |
Purpose |
|---|---|
BIOS |
Legacy x86 firmware; looks for an MBR boot record |
UEFI |
Modern firmware; loads |
ESP ( |
FAT32 partition holding bootloader |
NVRAM boot entries |
UEFI variables ordering boot candidates |
Secure Boot |
UEFI extension; verifies signed bootloaders |
TPM |
Trusted Platform Module; measures boot for attestation |
|
Kernel-exposed EFI variables and tables |
|
DMI / SMBIOS information from firmware |
Example.
$ [ -d /sys/firmware/efi ] && echo "UEFI" || echo "BIOS / legacy"
$ sudo efibootmgr -v
$ sudo dmidecode -t bios
$ mokutil --sb-state
2. Bootloader#
Loaded by firmware, the bootloader (GRUB, systemd-boot, U-Boot) reads its
config and locates vmlinuz and initramfs on disk, then copies them
into RAM. It builds the kernel command line that becomes
/proc/cmdline and jumps to the kernel’s entry point.
Step |
What happens |
|---|---|
|
Reads its config ( |
|
User picks an entry, or the default fires after a timeout |
|
Loader copies |
|
Args from the loader become |
|
Loader jumps into the kernel entry point |
The bootloader is loaded by the firmware and is responsible for finding
the kernel image, loading it and the initramfs into memory, and passing in
the boot command line that the kernel will read back as /proc/cmdline.
Tool |
Purpose |
|---|---|
|
GRUB 2, the dominant Linux bootloader |
|
Install GRUB into a target device or ESP |
|
Regenerate |
|
Debian/Ubuntu wrapper around |
|
Same on RHEL family |
|
Simple UEFI-only loader ( |
|
Manage systemd-boot entries |
|
Graphical UEFI boot manager |
|
Lightweight loader (PXE, USB sticks) |
|
Syslinux variant for ISOs |
|
Syslinux variant for PXE network boot |
|
Embedded / ARM bootloader |
|
Legacy x86 loader (mostly retired) |
Example.
$ sudo update-grub
$ sudo grub-install /dev/sda
$ sudo bootctl status
$ sudo bootctl list
3. Kernel#
The compressed kernel self-decompresses, sets up paging and the GDT/IDT, brings the CPU online, initializes the scheduler, and probes builtin drivers. The initramfs cpio archive is unpacked into a tmpfs rootfs and mounted as the temporary root filesystem.
Step |
What happens |
|---|---|
|
The compressed kernel self-extracts in place |
|
Memory management, IDT/GDT, page tables, console set up |
|
Scheduler, VFS, networking stubs, drivers compiled in |
|
The cpio archive is unpacked into a |
The kernel is loaded by the bootloader and unpacks the initramfs into RAM.
The initramfs provides whatever userland is needed to mount the real root
filesystem (typically drivers, cryptsetup, LVM, and the network for
NFS roots).
Path / tool |
Purpose |
|---|---|
|
Compressed kernel image |
|
Initial ramdisk (Debian uses |
|
Kernel build configuration |
|
Kernel symbol map |
|
Active kernel command line |
|
Running kernel version string |
|
Running kernel release |
|
Build initramfs (Arch family) |
|
Build initramfs (RHEL / Fedora / openSUSE) |
|
Build initramfs (Debian / Ubuntu) |
|
Inspect contents of an initramfs |
|
Distro-specific initramfs inspectors |
Example.
$ uname -r
$ cat /proc/cmdline
$ sudo update-initramfs -u
$ lsinitramfs /boot/initrd.img-$(uname -r) | head
4. Initramfs#
PID 1 inside the initramfs is /init. It loads kernel modules via
udev, unlocks LUKS volumes, assembles LVM/RAID arrays, and waits for the
real root device. Once mounted, switch_root makes it / and the
initramfs memory is freed.
Step |
What happens |
|---|---|
|
Kernel execs |
|
Loads modules, opens LUKS, assembles RAID/LVM, awaits root |
|
Initramfs |
|
Real root becomes |
After the kernel mounts the real root, it executes PID 1 (the init process). The init system then brings the rest of the system to a runtime state by starting services in dependency order until a target like multi-user or graphical is reached.
Init system |
Notes |
|---|---|
|
Dominant on Debian, Ubuntu, Fedora, RHEL, Arch, openSUSE |
|
Classic SysV init scripts ( |
|
Used by Alpine, Gentoo |
|
Minimal supervision-tree init (Void) |
|
Process supervision suite |
|
Event-based init (Ubuntu 6.10–14.10); retired |
|
Minimal init for embedded / Alpine-style systems |
|
macOS init (for cross-reference) |
Example.
$ ps -p 1 -o comm=
$ ls -l /sbin/init
$ systemctl --version
5. Init (PID 1)#
The kernel execs /sbin/init (usually systemd) as the new PID 1.
systemd resolves the default.target, computes the dependency
graph, and starts units in parallel through sysinit.target and
basic.target to either multi-user.target or graphical.target,
ending with a getty or display manager.
Step |
What happens |
|---|---|
|
|
|
The boot-end-state target is resolved |
|
All units required by the target are queued |
|
Sockets, mounts, services launch in dependency order |
|
Sync point for fstab mounts, sysctl, modules, tmpfiles |
|
Basic system is ready (sockets, slices, timers) |
|
|
|
A login prompt or display manager is presented to the user |
|
PAM authenticates; user shell or session starts |
Example.
$ systemd-analyze
$ systemd-analyze blame
$ systemd-analyze critical-chain
$ systemd-analyze plot > boot.svg
Systemd Boot Targets#
systemd replaces SysV runlevels with targets, named units that group other units. The default target determines the system’s boot end-state, and switching it (or one-shot isolating to another) is how you choose between graphical, console, and rescue postures without rebuilding anything.
Target |
Purpose (rough SysV-runlevel equivalent) |
|---|---|
|
Halt and power off (runlevel 0) |
|
Single-user with root shell + minimal services (runlevel 1) |
|
Non-graphical multi-user (runlevels 2/3/4) |
|
Multi-user + display manager (runlevel 5) |
|
Reboot (runlevel 6) |
|
Emergency shell on the root filesystem only |
|
Symlink → the boot target (usually |
|
Early-boot synchronization point |
|
Basic system ready |
|
Network is up and reachable |
|
Halt without power off |
Example.
$ systemctl get-default
$ sudo systemctl set-default multi-user.target
$ sudo systemctl isolate rescue.target
$ systemctl list-units --type=target
Boot-Time Files#
The configuration that shapes each stage of boot. Most boot misbehavior roots in one of these files (a stale GRUB config, a missing fstab entry, a forgotten crypttab line, or an initramfs that has not been rebuilt after a kernel or module change).
Path |
Purpose |
|---|---|
|
GRUB user-facing settings ( |
|
Generated GRUB configuration (do not edit by hand) |
|
systemd-boot per-entry config |
|
Persistent mount config consulted after root is mounted |
|
LUKS volumes unlocked at boot |
|
Arch initramfs build config |
|
Dracut initramfs build config |
|
Debian initramfs build config |
|
Local systemd unit overrides |
|
systemd manager settings |
|
Kernel modules to load at boot |
|
Module options / blacklists |
|
Sysctl values applied at boot |
|
systemd-tmpfiles rules |
|
Distribution identity (consumed by many boot tools) |
Example.
$ sudo nano /etc/default/grub
$ sudo update-grub
$ sudo systemctl daemon-reload
$ sudo systemctl reboot
Diagnostics#
When the boot is slow, fails, or behaves oddly, these are the tools that show what happened. They reach into the systemd journal, the kernel ring buffer, and the unit graph to surface the slow units, the failed units, and the messages that explain why.
Tool |
Purpose |
|---|---|
|
Total boot time + per-stage breakdown |
|
Slowest units |
|
Critical path of the boot |
|
SVG plot of the boot timeline |
|
Static unit-file lint |
|
Logs from this boot |
|
Logs from the previous boot |
|
Kernel messages from the journal |
|
Kernel ring buffer (live) |
|
With human-readable timestamps |
|
Reboot history |
|
How long since last boot |
|
Units that failed during boot |
|
Units still running early in boot |
|
Kernel command line passed by the bootloader |
|
UEFI boot order / entries |
Example.
$ systemd-analyze
$ systemd-analyze blame | head
$ journalctl -b -p err
$ dmesg -T | tail -50
$ systemctl --failed
Common Tasks#
Identify the firmware mode. BIOS or UEFI decides which loader path is in use.
$ [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
$ sudo dmidecode -t bios | head
Check Secure Boot and MOK trust. The signed-loader chain that gates kernels and modules.
$ mokutil --sb-state
$ mokutil --list-enrolled | head
$ sudo dmesg | grep -i 'secure ?boot'
Enumerate UEFI boot entries. .efi loaders the firmware knows about, in priority order.
$ sudo efibootmgr -v
$ sudo efibootmgr -v | grep ^BootCurrent # which entry booted us
$ ls /boot/efi/EFI/
Read the kernel command line. Ground truth for what the bootloader actually passed in.
$ cat /proc/cmdline
$ grep -E '^GRUB_CMDLINE' /etc/default/grub
$ ls /boot/
Profile the boot timeline. Find which stage and which units cost the time.
$ systemd-analyze
$ systemd-analyze blame | head -20
$ systemd-analyze critical-chain
$ systemd-analyze plot > boot.svg
Triage a failed boot. Failed units, error-priority logs, and the kernel ring buffer.
$ systemctl --failed
$ journalctl -b -p err --no-pager
$ journalctl -b -1 -p err --no-pager # the previous boot
$ dmesg -T | tail -50
Walk reboot history. When the box last came up and whether any boots were unclean.
$ last reboot | head -20
$ journalctl --list-boots
$ uptime -s
Hunt boot-path persistence. Bootloader hooks, initramfs hooks, autoloaded modules.
$ ls -la /etc/grub.d/ /etc/default/grub.d/ 2>/dev/null
$ ls -la /etc/initramfs-tools/hooks/ /etc/dracut.conf.d/ 2>/dev/null
$ ls -la /etc/modules-load.d/ /etc/modprobe.d/
$ lsmod | head -20
Reboot, power off, or halt. Graceful shutdown, optionally scheduled.
$ sudo systemctl reboot
$ sudo systemctl poweroff
$ sudo shutdown -r +5 'patching kernel'
$ sudo shutdown -c # cancel a pending shutdown
Change the default boot target. Pick the end-state without rebuilding the image.
$ systemctl get-default
$ sudo systemctl set-default multi-user.target
$ sudo systemctl isolate rescue.target # one-shot, no reboot
Rebuild bootloader and initramfs. After a kernel, module, or crypto change.
$ sudo update-grub # Debian/Ubuntu
$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg # RHEL family
$ sudo update-initramfs -u -k all # Debian/Ubuntu
$ sudo dracut -f # RHEL/Fedora
Recover from a bad boot. One-shot cmdline edits and rescue targets.
# at the GRUB menu: press 'e', edit the linux line, Ctrl-X to boot
# add 'systemd.unit=rescue.target' or 'init=/bin/bash' for recovery
$ sudo grub-reboot 'Advanced options...' # one-shot next boot
$ sudo systemctl rescue # drop running system to rescue
References#
man bootup(the same sequence in systemd’s own words).man systemd,man init,man openrc(init systems).man systemd-analyze,man systemd.target,man systemd.special,man systemd.unit(boot targets and unit semantics).man journalctl,man dmesg(boot logs and kernel ring buffer).man efibootmgr,man mokutil,man dmidecode(firmware, Secure Boot, hardware tables).man grub-mkconfig,man update-grub,man bootctl(bootloader configuration).man initramfs-tools,man dracut,man mkinitcpio(initramfs build tooling).man 5 fstab,man 5 crypttab(mounts and encrypted volumes consulted at boot).Services for systemd unit and service management and inspecting failed services.
Filesystem for
/etc,/boot, and/boot/efilayout.Linux for the command quick-reference.