Understanding and Configuring the GRUB Linux Bootloader


VPN offers!

1. NordVPN

2. Surfshark

3. ExpressVPN

The Linux bootloader is the program that loads a kernel and initializes an operating system. It’s responsible for loading as well as managing all of the software in your computer, from applications to drivers. GRUB stands for Grand Unified Boot Loader which was created by David Shimomura who also wrote its predecessor Multiboot.

The “grub configuration file in linux” is an important part of the Linux boot process. It is a text file that contains the commands to be executed by the kernel during booting. This article will cover how to understand and configure the GRUB Linux Bootloader.

Understanding and Configuring the GRUB Linux Bootloader

The GRUB Linux Bootloader is the most often used Linux bootloader. Learning about GRUB would be beneficial to any prospective Linux user. This article will teach you what GRUB is, how it works, and how to set up some useful GRUB options.

Take a look to learn more.


If you want to follow along with this guide, you’ll need a Linux device with the GRUB bootloader. This lesson will be based on Ubuntu 18.04.5 LTS, which will be installed in an Oracle VirtualBox virtual machine.

The GRUB Boot Process: An Overview

The Grand Unified Boot Loader (GRUB) is the main and most important component for starting your device. GRUB is also the most often used Linux bootloader. Your adventure will begin with a basic understanding of GRUB’s booting procedure.

The BIOS begins the booting process by calling the POST step and then searching for the bootloader in the Master Boot Record (MBR).

The MBR is the initial sector of any hard disk’s information. The MBR specifies the location of an Operating System. The information in the MBR is used to load (boot) the operating system into the device’s RAM.

This article focuses only on the MBR aspect of things. GPT, which stands for GUID Partition Tables, may also be used to locate drives. GPT is preferable if you want to create more than four partitions, since an MBR disk can only accommodate four main partitions.

MBR vs. GPT: Which Partition Style Should You Use?

A schematic of the booting process may be seen in the image below. As you can see, GRUB loads the kernel you choose into the RAM (Random Access Memory) (RAM). Users may log onto the device once the kernel has been loaded.

The function of GRUB during the Linux boot procedure The function of GRUB during the Linux boot procedure

GRUB and LILO Bootloaders are compared.

LILO, GRUB, and GRUB2 are the three primary boot loaders in the Linux world. In Linux distributions, GRUB2 is the most recent and major bootloader. The default Ubuntu bootloader, GRUB2, is the most often used and illustrated in this lesson, however LILO still exists under Linux. You’ll find out how they stack up against each other in this section.

LILO Linux Bootloader: Understanding and Configuration

Other Linux bootloaders, such as GNU GRUB, which has excellent memory management and an object-oriented foundation, are available on the market. SYSLINUX, a lightweight boot loader, is the alternative option.

GRUB can boot a variety of operating systems. LILO, on the other hand, can only run one operating system.

GRUB lets you to choose from a variety of operating systems. GRUB lets you to choose from a variety of operating systems.

GRUB supports Windows, Linux, Unix, macOS, BSD, and Solaris, while LILO exclusively supports Linux.

LILO must be reinstalled to the MBR if the configuration file is updated in LILO. It is not necessary to reinstall GRUB if you update its settings.

Choosing from a variety of kernels or recovery modes

This section explains how to choose a kernel when starting a device that has had its kernel compromised.

A kernel serves as a link between the hardware and software worlds. All of the processes that users execute on the device are under its control.

Here are the methods for selecting a kernel in Oracle VirtualBox utilizing a VM.

1. Using Oracle VirtualBox, log into the Ubuntu device console directly.

2. Use the shutdown command to restart your Ubuntu system, as illustrated below.

When your device resumes, hold Shift while loading GRUB, and the GRUB bootloader menu will appear. If you don’t make any choices, GRUB will start the system with the default kernel and continue the boot procedure.

When you need to boot with a kernel other than the default kernel, you should choose Advanced settings for Ubuntu. Or if you’re having problems with the system, such as file corruption or the kernel not loading properly.

The GRUB loading procedureThe GRUB loading procedure

4. A GRUB menu will appear once you pick the Advanced settings for Ubuntu. You should be able to choose from a variety of kernel alternatives in the menu. If you don’t choose an option, the first kernel that appears will be loaded by default.

Every kernel has two more choices, as seen in the figure below: upstart and recovery.

  • (upstart): an event-based replacement for the /sbin/init daemon, which is responsible for launching processes and services at boot time, halting them at shutdown time, and managing them while the system is operating.
  • (recovery mode): recovers the kernel from any system faults.

Using the GRUB menu to choose a kernel Using the GRUB menu to choose a kernel

5. After logging into the device, use the uname command to see whether the kernel you requested is loaded. The -r switch displays the kernel name.

Using the console to verify the kernel Using the console to verify the kernel

Choosing an Operating System as the Default

You’ll alter a few GRUB setup parameters now that you’re more comfortable with it. To begin, choose which Operating System will be loaded by default.

1. Open your preferred SSH client and connect to your Ubuntu device.

2. Now, use the awk program to list the GRUB boot menu items, as shown below. All of the entries in /boot/grub/grub.cfg will be shown using the awk program. On the terminal, the contents of the file will be shown. Keep an eye on the lines. You’ll need the number linked with the line ahead of you, which begins with zero, such as 0 for Ubuntu and 1 for Ubuntu with Linux 4.4.0-210-generic.

/boot/grub/grub.cfg awk -F’ ‘/menuentry / print $2’

Filtering all items in /boot/grub/grub.cfg using the awk command Filtering all items in /boot/grub/grub.cfg using the awk command

3. Finally, make changes to the GRUB configuration file. You can use vi to edit the file and modify the value for GRUB DEFAULT, but you can also use your favorite editor.

Set the value of GRUB DEFAULT to the appropriate OS entry’s line number. Do you recall the awk command you used? Those were the operating system entries. If you set GRUB DEFAULT to 0, the device will boot the first OS item in the GRUB boot menu, if you set it to 1, the device will boot the second OS entry, and so on. The first OS Entry Ubuntu is configured to boot by default in the picture below.

GRUB does not wait on the boot menu by default, and begins booting in 0 seconds. The value for GRUB TIMEOUT may be changed to adjust the timeout setting. The setting indicates how long the menu will be shown before booting begins. If the number is 5, a boot menu will show for 5 seconds, allowing you to choose which operating system to load when the machine begins.

GRUB configuration file editing GRUB configuration file editing

4. Make sure to execute the update-grub command after saving the modifications to the GRUB configuration file. The update-grub command updates the system with the modified configuration file.

The GRUB setup has to be updated. The GRUB setup has to be updated.

In GRUB, you may change the background image.

It’s not necessary to have a boring GRUB setup. By adding a backdrop picture to the GRUB menu, you may give it some personality. The GRUB BACKGROUND option allows you to specify photos as the backdrop in GRUB. To modify GRUB, follow the instructions below.

1. Using vi or your chosen text editor, add the GRUB BACKGROUND line to the GRUB configuration file, as shown below. The image is saved in a user home folder called UBUNTU in this example, and since GRUB runs as root, it can access images from anywhere on the file system. Save the configuration file once you’ve made your changes.

GRUB BACKGROUND=/path-to-image GRUB BACKGROUND=/path-to-image GRUB BACKGROUND=/path-to-image GRUB BACKGROUND=/home/ubuntu/shanky.jpeg

The picture shanky.jpeg was already present on the system. Replace it with the name of the file you wish to use as the background picture.

2. Run the update-grub command after making the modifications to the GRUB configuration file.

The GRUB setup has to be updated. file The GRUB setup has to be updated. file

3. Check to see whether the backdrop picture you uploaded to the Grub file is functioning properly. To be sure, restart your computer and hold down the Shift key while GRUB loads. GRUB now has a backdrop picture, as you can see below.

The background picture defined in the grub configuration file is shown in the GRUB menu. The background picture defined in the grub configuration file is shown in the GRUB menu.

Using GRUB for dual-booting

One of the most useful characteristics of GRUB is that it lets you select between Windows and Linux when your device starts, a process known as dual booting. Dual-booting enables you to run both Linux and Windows on the same computer, making life simpler for IT workers who deal with various operating systems.

Due to possible security problems with automated OS recognition, the default os prober script, which automatically brings in extra operating system menu options, was deactivated as of early 2021. If you know what OS systems are installed, you may re-enable this feature using the following command.

echo GRUB_DISABLE_OS_PROBER=false|sudo tee -a /etc/default/grub && sudo update-grub

When your computer starts up after you’ve enabled dual-booting, you should see a screen that looks like the GRUB menu.

The GRUB menu enables you to log into either a Windows or a Linux instance. The GRUB menu enables you to log into either a Windows or a Linux instance.


You learnt what GRUB is in this lesson, and the article exposed you to GRUB’s booting mechanism.

You also learnt how to customize GRUB, load alternative kernels, and even Dual-boot.

What are some of the configuration parameters you’ll tweak now that you’ve mastered GRUB?

The “what is grub in linux” is a question that many people ask. GRUB stands for the GRand Unified Bootloader and it is the bootloader used by Linux operating systems. In this article, we will discuss what GRUB is and how to configure it.

Related Tags

  • grub config file example
  • editing the grub2 configuration is accomplished by:
  • edit grub config from grub command line
  • grub config file location
  • grub linux command