devutils/ATFQ/book ATFQ git

Part II · Your system

20.1 From firmware to init

alsoboot sequenceboot processbootloaderinitramfsinitrduefibiossecure boot

TL;DR

  • The firmware (UEFI or BIOS) checks the hardware and starts a bootloader from disk.
  • The bootloader (GRUB, systemd-boot) loads the kernel and the initramfs into RAM.
  • The kernel uses the initramfs to find and mount the real root filesystem, then starts init: process 1.
  • Init (systemd on most distros) starts services until it reaches the default target.
systemd-analyze          # time spent in each stage
systemd-analyze blame    # slowest services first
journalctl -b -1         # logs of the previous boot

On your machine

alice@laptopexample
$ atfq 20.1
  Firmware  UEFI · Secure Boot on
  Kernel    6.12.48-amd64
  Cmdline   BOOT_IMAGE=/vmlinuz-6.12.48-amd64
            root=UUID=3f1c2a9e-8b7d-4e21-9c55-0a6b2d7e9f10 ro
            rootflags=subvol=@ quiet splash
  Init      systemd · default target graphical.target
  Loader    systemd-boot 256.4 · 1 unified kernel image(s)
  Up        3 days, 4 h

An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.

Pitfalls

Deep dive 2 questions

What is the initramfs for?

The kernel can't carry drivers for every disk controller, RAID, LVM or encryption setup. The initramfs is a small archive, loaded next to the kernel, with just enough tools to reach the real root: unlock a LUKS disk, assemble a RAID, mount the filesystem. Then it hands over to the real init.

UEFI or BIOS?

A BIOS runs the 446 bytes of code at the start of the first disk, which then loads the rest of the bootloader. UEFI reads files from the EFI System Partition, a small FAT partition often mounted at /boot/efi or /efi, and keeps its boot entries in firmware memory: efibootmgr lists them. UEFI is also what makes Secure Boot possible.

Commands
systemd-analyze journalctl efibootmgr
Paths
/boot /boot/efi
See also
20. Boot
20.3 GRUB vs systemd-boot vs UKI
20.4 systemd targets
20.2 The kernel command line
21.2 Kernel modules