Linux Applications

What is GRUB

Bootloader plays an essential role in your operating systems to boot your system, and GRUB is one of them. GRUB, or grand unified bootloader, is a flexible and potent program for booting the operating systems’ kernels.

It works as a default bootloader for the system based on the Linux kernel. However, many tech geeks are still unaware of what GRUB exactly is. In this guide, we will explain everything you need to know about the GRUB.

What Is GRUB?

GRUB (bootloader program) enables the selection of kernel or installed operating systems to be loaded when the system boots. GRUB starts up, loads the kernel into memory, and executes it. Afterward, you can select the operating system from the various operating systems that you want to boot. Thus GRUB acts as both a bootloader and a boot manager. To understand GRUB better, let’s look at some of its features.

Features of GRUB

  • It does not require a user input; it works automatically.
  • No need to write the configuration file every time it is changed.
  • It loads the operating system from different locations.
  • GRUB decompresses the operating system before launching it.
  • It installs and runs on many devices including USB drives, CD-ROMs, DVDs, floppy disks, and hard drives.
  • Dynamically configurable GRUB allows the users to change during boot-up.
  • An unlimited number of boot entries can be created.

Versions of GRUB

Presently, two main versions of GRUB are available which are as follows:

GRUB Legacy (Version 0)

They released the first version of GRUB in 1995. It is a multiboot bootloader and was designed initially by Erich Stefan Boleyn and later maintained by the GNU Project.

GRUB 2 (Version 2)

GRUB 2 is the widely used version of GRUB. We can find it on Linux distros such as Ubuntu, Manjaro, Red Hat Enterprise Linux (RHEL), and Fedora. It provides better configuration options and tools as compared to version 0.

How Does GRUB Work?

GRUB provides an options menu with a list of operating systems and Linux kernels. You can interact with this menu to make a selection of your choice. A screenshot of the GRUB menu list is attached for your reference.

After selecting the operating system for booting from the previous menu, GRUB loads the selected kernel. It has different parameters. These parameters have their functions while booting the operating system, which is as follows:

Parameters Functions
kernel Finds out the location of the kernel.
splash It displays the splash screen while the PC is booting.
quiet It hides some system-specific messages while the system is booting.
BOOT_IMAGE Location of Linux kernel image.
ro It mounts the file system in read-only mode.
root It is the location of the root filesystem.
initrd Specifies the initial RAM disk.

The configuration set by the Linux distribution determines the entries on the GRUB menu. Press the “e” key in the GRUB menu interface to edit a GRUB menu entry. It allows you to change the kernel parameters before loading. You can also enter GRUB’s command line menu using the “c” key.

It keeps at least one older version even after the Linux distribution updates the kernel version. It does this to boot into an older Linux kernel if you encounter any issues with the updated version.

In the end, you will see an entry like UEFI settings or System setup which allows you to access the BIOS settings of your machine.

How to Configure the GRUB

Any change you make in GRUB with the help of the menu interface is not permanent. To make permanent changes to GRUB, like changing the default timeout, you must change the configuration file after booting into the Linux system.

The main GRUB configuration file is grub.cfg which is located in the /boot/grub directory. Directly editing this file is not recommended. Alternatively, you can edit the GRUB configuration file located at /etc/default/grub. You can make additional changes by adding the .cfg config file to this directory. It also has a /etc/default/grub.d directory.

Use the following command to change the /etc/default/grub:

sudo update-grub

This allows you to write your changes automatically to the grub.cfg file.

More information on GRUB can be obtained using the following command:

info -f grub

Conclusion

The bootloader is the first software that starts when the computer boots. Through this guide, you must have come to know that GRUB is a flexible and very powerful boot loader, and the user completely controls its boot screen.

GRUB is a vast topic in itself. The purpose of this article is to provide all the necessary information. This guide included the details like GRUB’s features, versions, and configuration.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.