Linux Labs

Inside the system: resources, kernel, processes / Stage 10 of 12

From GRUB to a target: how the system boots

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 8 · on a machine · 5 min

The boot relay

Booting is a relay race: each stage prepares the ground for the next one and hands over control.

The machine's firmware (BIOS or UEFI) runs first: it checks the hardware and starts the boot loader from the disk. The GRUB boot loader reads /boot/grub/grub.cfg, loads the kernel and the initramfs — a small temporary root file system — into memory and passes the kernel its command line. You can see it in /proc/cmdline:

bash
cat /proc/cmdline

BOOT_IMAGE is the kernel file, root=UUID=… is where the real root file system lives, and console=ttyS0 is where to print the boot messages: to the serial port, which is also how your terminal is connected to the machine.

The kernel brings up the hardware and the programs from the initramfs, and they find the root file system by root= and mount it. Then the kernel starts the first process — systemd with PID 1 — and it starts units until the system reaches the boot target.

Of these stages systemd-analyze measures the last two: kernel is from the kernel's start to systemd's start, userspace is from systemd to the target. It cannot see the firmware and GRUB on this machine.

Check yourself 1 question

An update put a new kernel into /boot, and the old one stays next to it. Which boot stage decides which kernel the machine comes up with?

  • systemd is started by the kernel, which by then has been chosen and is running. The kernel is chosen earlier, in the boot loader.

  • initramfs is loaded into memory by GRUB together with the kernel: the choice has already been made by then.

GRUB chooses the kernel: it reads /boot/grub/grub.cfg, loads the chosen kernel with its initramfs and hands the kernel its command line. The kernel running now shows in /proc/cmdline and in uname -r.

Key points

  • The boot goes in stages: firmware → GRUB → the kernel with its initramfs → systemd → the boot target.
  • GRUB chooses the kernel and passes it the command line from /proc/cmdline: the root file system and the console are there.
  • systemd-analyze measures the kernel and the services (userspace), and cannot see the firmware and the boot loader here.
Ubuntu 24.04
Loading…