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:
| Parameter | Effect |
|---|---|
quiet | Suppress most boot messages |
splash | Show graphical boot screen |
nomodeset | Disable GPU driver (use for graphics issues) |
single / 1 | Boot into single-user mode |
root=UUID=... | Which device is the root filesystem |
ro | Mount root read-only initially |
init=/bin/bash | Use 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.