Markdown

GRUB

GRUB is the Acronym for GRand Unified Bootloader

The most common bootloader for Linux-based systems. It serves as the gatekeeper that hands off control from your computer’s hardware to the operating system kernel.

While technically third-party relative to the hardware manufacturer or the OS kernel itself, it is the industry standard for managing multi-boot environments.

What Does GRUB Actually Do?

When you turn on your computer, a specific sequence occurs:

  1. BIOS/UEFI initializes the hardware.
  2. It looks for a bootloader in the EFI partition or MBR.
  3. GRUB starts and presents a menu (if configured).
  4. GRUB loads the chosen Kernel into memory and starts the OS.

Key Features

  • Multi-boot Support: It can handle multiple operating systems (Linux, Windows, macOS) on the same drive.
  • Dynamic Configuration: You don’t have to reinstall the bootloader every time you change a setting; you just update a configuration file.
  • Rescue Mode: If your OS fails to boot, GRUB provides a command-line interface to manually find and boot your partitions.
  • File System Support: It understands many file systems (ext4, XFS, Btrfs, etc.), allowing it to find the kernel even if it’s tucked deep in a directory.

The Two Versions of GRUB

FeatureGRUB Legacy (v1)GRUB 2 (The Current Standard)
ScriptingVery limitedSupports complex scripts and “if/else” logic
HardwareMostly BIOSSupports BIOS, UEFI, and ARM
Configurationmenu.lstgrub.cfg (generated via /etc/default/grub)
PartitioningMBR onlyMBR and GPT

Essential Commands

If you are managing a Linux system, you’ll likely interact with GRUB using these tools:

  • update-grub: A script (common in Debian/Ubuntu) that automatically probes your drives for OSs and updates the menu.
  • /etc/default/grub: The primary file where users change settings like the default OS or the “timeout” duration.
  • grub-install: The command used to physically write the bootloader code to your disk’s boot sector.

A Quick Tip: If you ever find yourself stuck at a black screen with a grub> prompt, don’t panic! It usually means GRUB can’t find its configuration file. You can often point it to the right partition manually using the ls, set root, and insmod commands.