GRUB Bootloader

GRUB (Grand Unified Bootloader) is the first piece of software your OS controls after the firmware hands off. It finds your kernel on disk, lets you choose which one to boot, and passes configuration to it. When GRUB breaks, your system won't boot — so understanding it is essential.

What a Bootloader Does

Why does Linux need a bootloader at all? When the computer powers on, the firmware (BIOS/UEFI) only knows how to do very basic things. It can't read ext4 or understand Linux kernel formats. The bootloader bridges this gap — it knows enough about the filesystem to find the kernel, load it into RAM, and jump to its entry point.

GRUB Configuration

GRUB's main config file is generated automatically — you should never edit it directly:

# DO NOT edit /boot/grub/grub.cfg directly # Edit the template instead: sudo nano /etc/default/grub # Then regenerate: sudo update-grub # Debian/Ubuntu sudo grub2-mkconfig -o /boot/grub2/grub.cfg # Fedora/RHEL

Key settings in /etc/default/grub:

GRUB_DEFAULT=0 # which entry to boot (0 = first) GRUB_TIMEOUT=5 # seconds to show menu GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" # kernel params GRUB_CMDLINE_LINUX="" # extra params always added

Kernel Parameters

The kernel command line lets you control kernel behavior at boot:

ParameterEffect
quietSuppress most boot messages
splashShow graphical boot screen
nomodesetDisable GPU driver (use for graphics issues)
single / 1Boot into single-user mode
root=UUID=...Which device is the root filesystem
roMount root read-only initially
init=/bin/bashUse bash as PID 1 (emergency)

GRUB Rescue Mode

I see "grub rescue>" — what happened? GRUB loaded its Stage 1 from MBR but couldn't find its Stage 2 or config file. Usually means the partition table changed, a disk was removed, or grub.cfg is missing.
# At grub rescue> prompt: # Find where your boot partition is grub rescue> ls (hd0) (hd0,gpt1) (hd0,gpt2) grub rescue> ls (hd0,gpt2)/ # Look for /boot/grub/ directory grub rescue> set root=(hd0,gpt2) grub rescue> set prefix=(hd0,gpt2)/boot/grub grub rescue> insmod normal grub rescue> normal # Now you should see the GRUB menu

After booting, run sudo update-grub && sudo grub-install /dev/sda to permanently fix it.

Frequently Asked Questions

What will I learn here?

This page covers the core concepts and techniques you need to understand the topic and progress confidently to the next lesson.

How should I use this page?

Start with the overview, then follow the section links to deepen your understanding. Use the table of contents on the right to jump to specific sections.

What should I read next?

Use the navigation below to continue to the next lesson or explore related topics.