Kennisbank › Linux Kernel › GRUB: The Bootloader of GNU/Linux — A Practical Guide
linux kernel starter 27 August 2026

GRUB: The Bootloader of GNU/Linux — A Practical Guide

GRUB: The Bootloader of GNU/Linux — A Practical Guide

In 1999, Gordon Matzigkeit and Yoshinori K. Okuji made GRUB part of the official GNU Project. From that point on, development was opened up to contributions from programmers worldwide.

The original version, now called GRUB Legacy, had a complex and difficult-to-maintain codebase. That is why GRUB 2 was completely rewritten with a modular architecture. The last version of GRUB Legacy was 0.97, released in 2005. Around 2009, Ubuntu and Fedora began installing GRUB 2 by default. According to the Dutch-language Wikipedia, GRUB 2 has been the default bootloader of most Linux distributions since 2014. The current version is 2.06, released in 2021.

Configuration File: grub.cfg

The configuration file grub.cfg contains the list of available operating systems, kernel options, and boot menus. System administrators rarely edit this file directly. They use `update-grub`, a stub for `grub-mkconfig`, which automatically generates the configuration file based on detected kernels and settings.

Steps: Configuring and Updating GRUB

Step 1: Check the GRUB version

grub-install --version

This confirms that GRUB 2 is installed and shows the version number.

Step 2: Update the GRUB configuration file

sudo update-grub

This command regenerates `grub.cfg` based on the current system configuration. Run this after installing a new kernel or changing boot settings.

Step 3: View the generated configuration file

cat /boot/grub/grub.cfg | less

Check whether the correct kernels and operating systems appear in the menu.

Step 4: Temporarily choose a different boot menu item

sudo grub-reboot 2

This selects the second menu item for the next boot, without permanently changing the default setting. Useful for testing new kernels.

Step 5: Retrieve information about devices

grub-probe --target=device /boot

This shows which device contains the `/boot` partition. Essential when configuring the bootloader.

Step 6: Convert SYSLINUX configuration to GRUB format

grub-syslinux2cfg /path/to/syslinux.cfg

This converts SYSLINUX configuration files to a format that GRUB can read. Supports variants such as ISOLINUX and PXELINUX.

Step 7: Check kernel boot arguments

cat /proc/cmdline

This shows the kernel boot arguments that GRUB has passed. These include the root partition and security features such as secure boot.

Step 8: Check disk partitions with GPT tools

sudo gdisk -l /dev/sda

This shows the GPT partition table of the disk. GRUB 2 supports both MBR and GPT, but on GPT disks without UEFI, it requires a small BIOS Boot Partition.

Verification

Check whether GRUB works correctly:

grub-install --version && sudo update-grub

If both commands run without errors, GRUB is correctly configured. Restart the computer to confirm that the boot menu appears and loads the correct operating system.

Frequently Asked Problems

Problem 1: GRUB does not show a boot menu after installing a new kernel

Solution: Run `sudo update-grub`. If the menu still does not appear, check whether the kernel is actually installed with `dpkg --list | grep linux-image` (on Debian/Ubuntu) or `rpm -qa | grep kernel` (on Fedora/RHEL).

Problem 2: GRUB cannot find a GPT disk

Solution: Check whether a BIOS Boot Partition is present. Create one with `gdisk` or `cgdisk` (type code `ef02`). This partition must be at least 1 MiB in size and does not require a file system.

Problem 3: GRUB does not start after an update

Solution: Boot from a live CD and reinstall GRUB:

sudo mount /dev/sda1 /mnt
sudo grub-install --root-directory=/mnt /dev/sda

Replace `/dev/sda1` with the correct root partition and `/dev/sda` with the disk on which GRUB should be installed.

Disk Management Tools

In addition to the GRUB utilities, there are tools that indirectly affect how GRUB works. gdisk, cgdisk, and parted are used to create or edit GPT partition tables. These tools ensure that the disk is properly set up so that GRUB can be installed.

GRUB 2 supports both MBR and GPT, but has specific requirements per format. On GPT disks without UEFI, a BIOS Boot Partition is required. These tools create that partition and manage the partition table.

GRUB also works with other system components. The /proc/cmdline file contains the kernel boot arguments that GRUB passes through. These arguments determine, among other things, how much memory the system uses and which root partition is active.

GRUB on Specific Hardware

GRUB not only supports standard x86-pc systems. There is also support for specific hardware. grub-render-label generates, for example, a `.disk_label` file for Apple Mac systems. This file is used by macOS to give a disk a custom name and appearance in the Finder.

This support shows that GRUB takes into account different hardware and operating system requirements. It makes GRUB usable on a wide range of systems, from servers to desktop computers.

GRUB and Security

GRUB plays a role in the security of the boot process. It supports secure boot and can pass kernel boot arguments that enable security features. The kernel boot arguments in `/proc/cmdline` can indicate whether secure boot is enabled.

GRUB is regularly updated for security fixes. It is therefore important to keep GRUB up to date. On Debian/Ubuntu systems, you do this with:

sudo apt update && sudo apt upgrade grub-pc

On Fedora/RHEL systems:

sudo dnf update grub2

GRUB and Virtualization

GRUB also works in virtualized environments. In virtual machines, GRUB is installed on the virtual disk and works in the same way as on physical hardware. This makes it possible to use the same tools and commands for managing GRUB in virtual machines.

The modular architecture of GRUB 2 makes it easy to add support for new hardware. This is important in virtualization environments where hardware is constantly changing.

GRUB and Network Booting

GRUB supports network booting via PXE. This makes it possible to boot a computer from a network server instead of a local disk. This is useful in environments where many computers need to be installed or configured at the same time.

The PXELINUX variant of SYSLINUX can be converted to GRUB format using `grub-syslinux2cfg`. This makes it easy to migrate existing PXE configurations to GRUB.

GRUB and File Systems

GRUB 2 supports a wide range of file systems, including ext4, Btrfs, XFS, and ZFS. This means GRUB can load kernels from almost any modern file system. Support is continuously expanded with new file systems.

The configuration file `grub.cfg` is stored in the `/boot` partition. This partition must be accessible to GRUB. It is therefore important that the `/boot` partition uses a file system that GRUB supports.

GRUB and Firmware

GRUB 2 supports both BIOS and UEFI firmware. On UEFI systems, GRUB is installed as an EFI executable. This requires an EFI System Partition (ESP) with a FAT file system.

Installation on UEFI systems differs from that on BIOS systems. The command `grub-install` automatically detects the firmware type and installs the appropriate version.

GRUB and Multiple Operating Systems

One of the most important features of GRUB is supporting multiple operating systems. GRUB displays a menu with all available operating systems and lets the user choose which one to boot.

The configuration file `grub.cfg` contains the menu items for each operating system. These are automatically generated by `update-grub` based on detected operating systems.

GRUB and Kernel Management

GRUB plays a central role in kernel management. When a new kernel is installed, `update-grub` must be run to add the new kernel to the boot menu. This ensures the kernel can be selected during boot.

The command `grub-reboot` makes it possible to temporarily select a different kernel. This is useful when testing new kernels without permanently changing the default setting.

GRUB and System Recovery

GRUB can also be used for system recovery. If the system no longer boots, GRUB can be used to load an alternative kernel or a recovery mode. This is essential for system administrators.

The kernel boot arguments in `/proc/cmdline` can be adjusted to start the system in a recovery mode. This may be necessary, for example, if the file system is damaged.

GRUB and Automation

GRUB can be automated using scripts. The configuration file `grub.cfg` can be generated using `grub-mkconfig` and custom scripts. This makes it possible to tailor the boot menu to specific requirements.

System administrators can create scripts that automatically run `update-grub` after installing a new kernel. This ensures the boot menu is always up to date.

GRUB and Documentation

GRUB is extensively documented. The official documentation contains detailed information about all options and commands. In addition, numerous tutorials and guides are available for specific use cases.

The Dutch-language Wikipedia contains an extensive article about GRUB with information about its history, versions, and functionality. This article is a good starting point for further study.

The development of GRUB remains active, with regular updates for security fixes and new hardware support. The modular architecture makes it easy to add new features and improve existing ones, which keeps GRUB relevant in a constantly changing technological landscape.

← Back to knowledge base
← Terug naar kennisbank