Skip to content

The Boot Process and GRUB

Between pressing the power button and seeing a login prompt, a Linux machine passes through several distinct, sequential stages. Each stage loads the next one and then hands off control to it. Knowing this sequence matters most when something goes wrong — a server that fails to come back up after a reboot gives very different clues depending on which stage it got stuck in, and reading those clues correctly starts with understanding the sequence itself.

This article covers everything that happens before init and systemd takes over. What happens once the kernel is running continues in Kernel Modules and, for the recovery scenarios this knowledge unlocks, in Rescue and Emergency Mode.

What You Will Learn

By the end of this article you will be able to:

  • name the five stages a machine passes through, from BIOS/UEFI to systemd, in order;
  • explain what GRUB does and where its configuration files live;
  • temporarily change a kernel parameter for a single boot;
  • add a kernel parameter permanently through /etc/default/grub;
  • narrow down, from the symptoms alone, roughly which stage a boot failure is happening in.

The Five Stages

1. BIOS/UEFI  →  2. Bootloader (GRUB)  →  3. Kernel  →  4. initramfs  →  5. systemd (PID 1)
  1. BIOS/UEFI — firmware that runs the instant power is applied. It runs a Power-On Self-Test (POST) to check basic hardware, then searches a configured list of boot devices (disk, USB, network) in order and loads a bootloader from the first one it finds bootable.
  2. Bootloader (GRUB) — locates a kernel image on disk and loads it into memory. It also gives the user a boot menu and a way to edit kernel parameters for a single boot.
  3. Kernel — the Linux kernel itself is loaded into memory, initializes the hardware it can talk to directly, and starts the first user-space process — init, running inside the initramfs.
  4. initramfs (initial RAM filesystem) — a small, temporary filesystem holding just enough drivers and tools to mount the real root filesystem, for example when the root volume sits on LVM or software RAID and needs a specific driver loaded before it can even be found.
  5. systemd (PID 1) — once the real root filesystem is mounted, the kernel hands control to systemd as PID 1. From here the system boots up through the target and unit mechanism covered in init and systemd.

Info

On UEFI systems, GRUB is sometimes replaced by a simpler bootloader such as systemd-boot. Ubuntu Server defaults to GRUB, so this article focuses on GRUB specifically.

What GRUB Actually Does

GRUB (GRand Unified Bootloader) has two jobs:

  • present a boot menu so the user can pick which kernel or operating system to load;
  • load the chosen kernel into memory with the right parameters and hand off control to it.

GRUB's configuration is split across three files, each with a distinct role:

File Role
/etc/default/grub The file an administrator actually edits: default kernel, menu timeout, kernel command-line parameters
/etc/grub.d/ Scripts that generate the individual boot menu entries
/boot/grub/grub.cfg The final configuration, generated automatically from the two files above

Danger

Never edit /boot/grub/grub.cfg by hand — it gets overwritten the next time update-grub runs, and any manual edit is silently lost. A permanent change always goes into /etc/default/grub first, then gets regenerated into grub.cfg with update-grub.

Changing a Kernel Parameter for a Single Boot

This method only affects the current boot — it disappears on the next reboot, which makes it a safe way to experiment.

  1. While the server is rebooting and the GRUB menu appears, interrupt it by holding Shift (BIOS systems) or pressing Esc (UEFI systems).
  2. Select the entry you want and press e — GRUB opens an editable view of that entry's boot commands.
  3. Find the line starting with linux and append the parameter you need, for example:
linux   /boot/vmlinuz-... root=UUID=... ro quiet splash single
  1. Press Ctrl+X or F10 to boot with this modified line.

This is the standard way to add a parameter such as single or systemd.unit=rescue.target temporarily, exactly the technique used in the recovery scenarios in Rescue and Emergency Mode.

Adding a Kernel Parameter Permanently

A parameter that should apply on every boot goes into the GRUB_CMDLINE_LINUX_DEFAULT line of /etc/default/grub:

sudo nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

For example, to see the full kernel log output during boot, remove quiet:

GRUB_CMDLINE_LINUX_DEFAULT="splash"

Once the file is saved, the configuration must be regenerated:

sudo update-grub

On Ubuntu and Debian this command is a wrapper around grub-mkconfig -o /boot/grub/grub.cfg. Once it finishes without errors, the change takes effect starting with the next reboot.

Warning

After running update-grub — and before actually rebooting — check that the resulting /boot/grub/grub.cfg contains the parameter you expect:

grep -m1 'linux ' /boot/grub/grub.cfg

A malformed kernel parameter (for example, a root= value that no longer points to a real device) can leave a system unable to boot at all. On a production server, only make this kind of change when you have physical or KVM/iLO access to the console.

GRUB_CMDLINE_LINUX vs GRUB_CMDLINE_LINUX_DEFAULT

/etc/default/grub actually has two command-line variables, and confusing them is a classic interview trap:

  • GRUB_CMDLINE_LINUX_DEFAULT — appended only to the normal boot entries. This is where cosmetic or routine options like quiet splash belong.
  • GRUB_CMDLINE_LINUX — appended to every entry, including the recovery ones. A parameter that must apply even in recovery mode (for example, a serial-console setting like console=ttyS0,115200) goes here.

The ro already present on the generated linux line is not cosmetic: the kernel mounts the root filesystem read-only at first so a filesystem check can run safely against a quiet disk, and systemd later remounts it read-write. That is also why recovery work in Rescue and Emergency Mode starts with an explicit mount -o remount,rw /.

Interview angle

On a UEFI machine, GRUB does not live in the disk's boot sector — it is an .efi binary (grubx64.efi) on the EFI System Partition, mounted at /boot/efi. If GRUB itself is damaged (not just its config), regenerating grub.cfg with update-grub is not enough; the bootloader has to be reinstalled with sudo grub-install /dev/sda (BIOS) or sudo grub-install (UEFI, which writes into /boot/efi), followed by update-grub. On Secure Boot systems the chain also passes through shim before GRUB — a useful point to name if asked why an unsigned custom kernel refuses to boot.

Narrowing Down Where a Boot Failure Happened

Symptom Likely stage
Nothing on screen at all, not even power indicators BIOS/UEFI or hardware
GRUB menu appears, but the system hangs after an entry is selected Kernel or initramfs
"Gave up waiting for root device" message initramfs cannot find the real root filesystem
Kernel messages scroll by, then systemd reports failures and stops A systemd target or unit problem — see systemd troubleshooting

Interview angle

A common interview question is "the server won't boot — where do you even start looking?" The answer is exactly this table: match the last visible symptom to a stage, because each stage fails for structurally different reasons (firmware/hardware, a missing kernel image, a driver missing from initramfs, or a misconfigured systemd unit) and needs a different fix. Jumping straight to journalctl when the machine never even reached GRUB wastes time on a tool that has not started yet.

Exercises

  1. In a disposable test VM, interrupt the GRUB menu with Shift/Esc and look at the list of existing entries.
  2. Temporarily add systemd.log_level=debug to the kernel line by pressing e, boot with it, then inspect the extra detail with journalctl -b.
  3. Change the GRUB_TIMEOUT value in /etc/default/grub, run update-grub, and check how the change is reflected in grub.cfg.
  4. From memory, describe the five boot stages (BIOS/UEFI, GRUB, kernel, initramfs, systemd) in order, in your own words.

Verification criterion: you should be able to state, for a given boot symptom, which of the five stages it most likely belongs to, without looking at the table above.

Summary

Every boot starts at BIOS/UEFI, passes through GRUB to the kernel, from there through initramfs to the real root filesystem, and finally to systemd. GRUB's actual settings live in /etc/default/grub; the generated result lives in /boot/grub/grub.cfg, which is never edited by hand. A kernel parameter can be added temporarily at boot time (pressing e in the GRUB menu) or permanently (/etc/default/grub plus update-grub). The next article, Kernel Modules, picks up right after the kernel has started and shows how to manage its drivers.

References