Linux Commands

How do I change GRUB boot options

When Computers are powered on they need some operating system, the process in which the computer turns on and detects the operating system and initializes it, is called boot. The other term which is necessary to understand for us is grub, grub is the abbreviation of “GRand Unified Bootloader”, which is used in the Linux operating system to call the operating system when the computer is turned on.

When we open a boot menu, different options or settings are present there which can be used to configure the boot loader, in this write-up, we will discuss these grub boot options and how to modify them.

How do I change GRUB boot options

We have a GRUB boot configuration file at the path of /etc/default/grub, we can open it with any editor, before opening it, create the backup of this file by using the command:

$ sudo cp /etc/default/grub /etc/default/grub.bak

To confirm the execution of the above command, display the contents of /etc/default/grub.bak using:

$ cat /etc/default/grub.bak

To save the changes, update the GRUB using the command:

$ sudo update-grub

For convenience we will open it with the help of a nano text editor using the command:

$ sudo nano /etc/default/grub

The first line “GRUB_DEFAULT” is the option to set the preference of choosing the operating system if you have more than one. If you set the value of this option to “0” then it will choose the first operating system present in the boot menu and if you set it “1” then it will choose the second operating system among the list.

Another option is GRUB_TIMEOUT_STYLE which is in our case set to the hidden, which implies it will not display the boot menu until the boot menu key is pressed, if it is set to “menu”, then it will display the Grub boot menu.

The next option in the boot menu is for “GRUB_TIMEOUT”. It is for boot time; how much time will it take to boot the operating system, in our case it is set to “0” which means it will boot the operating system immediately but you can increase this time according to your requirement.

$ sudo update-grub

To add the image in the background of the boot menu, download the image of your choice and then copy it to “/boot/grub” using the command:

$ sudo cp index.jpeg /boot/grub/

Again open the configuration file of GRUB boot:

$ sudo nano /etc/default/grub

Add the following line in the file:

GRUB_BACKGROUND="/home/hammad/index.jpeg"

Save the file and exit the editor, and update the GRUB boot settings using the command:

$ sudo update-grub

The output is showing that the background image has been added, now rebooted Linux.

$ sudo shutdown now -r

Press the GRUB MENU key (Shift) to open the boot menu:

We can see that the background of the GRUB boot menu has been changed.

Conclusion

GRUB menu is useful if you have more than one operating system, it will ask you which operating system you want to run on the computer, in the Linux operating system, the operating system is booted by the GRUB boot loader. GRUB menu options can be modified through the terminal in Linux. In this write-up, we have discussed how the grub boot options are changed through the command-line in Linux. In the Ubuntu-based distributions, the configurations of the GRUB menu are stored in /etc/default/grub and they can be changed by opening the following path with the help of an editor.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.