A boot loader is one of the most important components of your Linux operating system's boot process.

This article will show you what a boot loader is and the role it plays in a Linux system. In particular, this guide will focus on the Grand Unified Bootloader (GRUB), a powerful and highly flexible boot loader program. But before looking at GRUB in detail, it is important to understand the boot process in Linux.

The Linux Boot Process

The boot process on Linux is a series of activities that occur from the time you press the power button on your PC until the time the login screen appears.

There are four main stages in the boot process of your operating system and they occur in the following order:

  1. BIOS: Stands for Basic Input/Output System and is mainly responsible for loading the bootloader. When the computer starts, it runs a Power On Self Test (POST) to make sure that core hardware such as the memory and hard disk is working properly. Afterward, the BIOS will check the primary hard drives' Master Boot Record (MBR), which is a section on your hard drive where the bootloader is located.
  2. Bootloader: Loads the kernel into the RAM with a set of kernel parameters.
  3. Kernel: The kernel's primary function is to initialize devices and memory. Afterward, it loads the init process.
  4. Init: Responsible for starting and stopping essential services on your system.

Note: The BIOS is not a Linux-related process, it is a process that happens regardless of your operating system.

Learn more: Is a Computer's BIOS Considered Software, Hardware, or Firmware?

What Is the Grand Unified Bootloader?

GRUB is mainly responsible for providing you with an options menu from which you can select the operating system or environment that you want to boot into. In addition, GRUB is responsible for loading the Linux Kernel.

Here is what a GRUB menu option looks like. If you have multiple operating systems installed, you will have them listed here.

grub boot menu options

Note: GRUB is not only limited to booting into Linux operating systems, you can also use it to boot into other operating systems such as Windows.

There are two main versions of GRUB that are available at the time of this writing.

  1. GRUB Legacy: This is the first version of GRUB and was initially developed in 1995.
  2. GRUB 2: This is the latest version of GRUB used by many mainstream Linux distros such as Manjaro, Ubuntu, Fedora, and Red Hat Enterprise Linux (RHEL). GRUB 2 provides you with better tools and configuration options than its predecessor.

Apart from GRUB, Linux distros also use other boot loaders such as Linux Loader (LILO), coreboot, and SYSLINUX.

The Role of GRUB

Once you select the operating system to boot into, GRUB will load the selected kernel. GRUB uses kernel parameters to know where the kernel is located and other important parameters to use.

  • initrd: Used for specifying the initial RAM disk.
  • BOOT_IMAGE: The location of the Linux kernel image.
  • root: Specifies the location of the root filesystem. Used by the kernel to find init which in turn loads critical services.
  • ro: Responsible for mounting the filesystem in read-only mode.
  • quiet: Hides some system-specific messages as your PC is booting.
  • splash: Used for displaying the splash screen when your system is booting.

When you are in the GRUB options menu, you can edit kernel parameters by pressing the E key on your keyboard.

Configuring the GRUB Bootloader

GRUB 2 gives you a lot of flexibility and power when it comes to configuring your boot loader.

The /boot/grub directory contains a file named grub.cfg, which is the main configuration file for GRUB. However, you are advised not to edit the grub.cfg file directly, instead you should edit the /etc/default/grub file.

When you make changes to the /etc/default/grub file, you should make sure to run the command below, so that your changes are written to the grub.cfg file automatically.

        sudo update-grub
    

You can learn more about GRUB and some of its configuration options by running the following command:

        info -f grub
    

Customizing GRUB on Linux

This guide has shown you that GRUB is a highly powerful and flexible boot loader and plays a crucial role in the working of your operating system. Users have complete control over the appearance of the GRUB boot screen. You can even customize the background image of the boot screen easily.