2/32 · 5 min
From power on to a login prompt
Pressing the power button starts a chain where each stage knows just enough to find and start the next. Nothing in it is magic, and knowing the order is what makes a machine that will not boot diagnosable.
The chain
firmware (BIOS or UEFI)
| runs a power on self test, finds a bootable device
bootloader (GRUB, systemd-boot, Windows Boot Manager)
| loads the kernel image and an initial ramdisk into memory
kernel
| initialises memory, detects devices, mounts the real root filesystem
init process (PID 1, usually systemd)
| starts services in dependency order
login promptWhy an initial ramdisk exists
The kernel must mount the root filesystem, but the driver for the disk it lives on may itself be a module stored on that filesystem. The initial ramdisk breaks the circle: a small filesystem loaded straight into memory containing just enough drivers to reach the real one.
PID 1 is special
The first process the kernel starts has process id 1 and two unusual properties. It adopts orphaned processes, so nothing is ever parentless. And if it exits, the kernel panics, because there is nothing left to run.
$ ps -p 1 -o pid,comm
PID COMMAND
1 systemdThis matters outside kernel work more than it sounds, because inside a container your application is usually PID 1, and if it does not reap the children it spawns they accumulate as zombies.
What starts, and in what order
Older systems ran numbered shell scripts in sequence, so a slow service delayed everything after it. Modern init systems build a dependency graph and start independent services in parallel, which is why a machine that took ninety seconds to boot now takes eight.
| Stage | Fails when | Symptom |
|---|---|---|
| Firmware | no bootable device | "no operating system found" |
| Bootloader | kernel missing or config wrong | a bootloader prompt |
| Kernel | wrong driver, bad hardware | a panic, a stack trace |
| init | a required service will not start | boots to a rescue shell |
Reading which stage the message came from is most of the diagnosis.