Free — no signup required

Stage 2: The Bootloader (GRUB)

3 min read

The Translator Between Firmware and Kernel

Once UEFI (or BIOS) has done its job, it hands control to the bootloader. On Linux, this is almost universally GRUB2 (Grand Unified Bootloader, version 2). You know GRUB as the menu that appears for a few seconds before Linux starts — but it is doing far more than displaying a list.

GRUB's core responsibilities are:

  1. Present a boot menu — letting you choose between installed operating systems or kernel versions.
  2. Load the kernel image (vmlinuz) into RAM.
  3. Load the initramfs image into RAM alongside the kernel.
  4. Pass kernel parameters — a string of options that control kernel behavior at boot time.
  5. Jump to the kernel entry point — transferring CPU control to the kernel.

GRUB's configuration lives at /boot/grub/grub.cfg. You should never edit this file directly — it is auto-generated by the update-grub command (Debian/Ubuntu) or grub2-mkconfig (RHEL/Fedora) from template files in /etc/grub.d/ and settings in /etc/default/grub, which holds directives like GRUB_DEFAULT, GRUB_TIMEOUT, and GRUB_CMDLINE_LINUX_DEFAULT.

The GRUB_CMDLINE_LINUX_DEFAULT line is where you add persistent kernel parameters. Common examples:

Parameter Effect
quiet Suppress most boot messages
splash Show graphical splash screen
nomodeset Disable kernel mode-setting (fixes some GPU driver issues)
systemd.unit=rescue.target Boot into rescue mode
init=/bin/bash Skip init entirely, drop straight to a bash shell
ro Mount root filesystem read-only initially

After editing /etc/default/grub, you regenerate the actual config with update-grub on Debian/Ubuntu or grub2-mkconfig on RHEL/Fedora — editing the settings file alone has no effect until that regeneration step runs.

How GRUB Finds Its Files

On a BIOS/MBR system, GRUB installs a tiny first-stage loader in the MBR's 512 bytes. That loader knows only one thing: where to find GRUB's second stage, which lives in the gap between the MBR and the first partition (the "MBR gap"). The second stage is large enough to read filesystems and display the menu.

On a UEFI system, GRUB is installed as /boot/efi/EFI/ubuntu/grubx64.efi (or similar) on the ESP. UEFI loads it directly — no MBR gap tricks needed.

Interview Tip

A common SRE interview scenario: "A server boots to a GRUB rescue prompt instead of the menu. What happened and how do you recover?" The GRUB rescue prompt appears when GRUB's second stage cannot find its own configuration files — typically because a disk was repartitioned, a filesystem was corrupted, or GRUB was installed to the wrong device. Recovery involves using ls at the rescue prompt to find the boot partition, setting prefix and root variables manually, loading the normal module, and then running normal to get the full menu. From there you can boot and run update-grub to make the fix permanent.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free