Part 6 of 7 · 4 min read
Boot stages
Following a boot, and finding where it stopped
Think of a relay race. Each runner carries the baton part of the way and hands it on, and if the team stops, the place where the baton was dropped shows which runner failed. The boot stages work in the same way. The analogy stops in one place: in a relay each runner works alone, and in a boot each stage must also leave the machine ready for the next.
In plain words: Boot is a chain of stages: firmware, boot loader, kernel, first process and services. Each stage starts the next. A failure at each stage looks different, so the symptom shows where the boot stopped, and the kernel's own messages, shown by dmesg, record how far it got.
The whole route, in order:
| Stage | Who runs | What it does |
|---|---|---|
| 1 | Firmware (BIOS or UEFI) | Self-test, device scan, choose boot device |
| 2 | Boot loader (such as GRUB) | Load the kernel and the initramfs, pass settings |
| 3 | Kernel | Set up memory and devices, mount the root file system |
| 4 | First process (systemd) | Start the daemons and the login |
| 5 | Login prompt or desktop | The system is running |
A failure at each stage looks different, which helps diagnosis.
- Nothing on screen, no beeps or lights. Hardware or firmware problem (stage 1).
- "No bootable device" message. The firmware could not find a valid boot block (stage 1 to 2).
- A boot loader menu or error such as "file not found". The loader cannot find the kernel (stage 2).
- "Kernel panic: unable to mount root fs". The kernel ran but could not reach the root file system, often because the
root=setting or the driver is wrong (stage 3). - Services failing, no login. A daemon or configuration fault (stage 4).
A worked example.
A made-up timing for a laptop shows where boot time goes: firmware 8 seconds, boot loader 2, kernel 4, first process and services 12. The total is 26 seconds. Services take 12 / 26, which is 46 per cent of the time, so the services are the best place to look for savings. A system may start fewer daemons at boot, or start some in parallel.
You can see the kernel's own messages from boot with the command dmesg. Each line starts with the number of seconds since the kernel started, such as [ 0.000000] Linux version ..., and the next lines are the devices and drivers found.
Read it as
A boot is a chain of handovers, each stage a bit more capable than the last. When it fails, the last message you saw tells you which stage held the baton.
Interview angle
Answer in your head first, then open it.
What happens when you power on a computer?
Firmware runs, tests the hardware, finds the boot device and loads the boot loader. The loader loads the kernel. The kernel starts the first process, which starts the services and the login.
BIOS versus UEFI?
UEFI is the modern firmware: a single boot manager, better with large disks and 64-bit systems.
What is initramfs for?
To supply the drivers needed to reach the real root file system.
What is process 1?
The first user process, which starts all the others (systemd on most Linux systems).
Check yourself:
1. At which stage does "unable to mount root fs" occur?
2. What does dmesg show?
3. In the timing example, which stage takes the largest share?
Words you will meet
| Word | Meaning |
|---|---|
| Booting | Starting a computer by loading the kernel |
| Firmware | Software in non-volatile memory that runs at power-on |
| Boot block | The fixed disk block that the firmware loads first |
| Root file system | The file system that holds the top of the file tree |
| Daemon | A background program that lasts as long as the system runs |
| Kernel panic | A fatal kernel error that stops the system |
Quick notes
- The bootstrap problem: loading a program needs a program already running, so the first one lives in non-volatile memory.
- Firmware (BIOS or UEFI) tests the hardware and hands control to the boot loader.
- The boot loader loads the kernel and an initial RAM file system and passes a command line.
- The kernel mounts the root file system and starts the first process, PID 1 on Linux.
- Daemons are background processes that provide services for the whole life of the system.
- A failure at each stage looks different, which helps diagnosis.