Many people use Linux as their secondary operating system in the dual-boot environment along with Windows, Mac OS, and others. When you install Linux along with any operating system, it replaces the bootloader of that OS with its own known as GRUB.
Nowadays many Linux distributions use GRUB2 as a bootloader. As we all know – “The main beauty of Linux is its customization capabilities” even if it means customizing bootloader. You can change the default OS value, choose how long to count before booting into default OS. You can even set the background image of your choice.
Here we have demonstrated it on Kali Linux and also, we have tested it on Ubuntu. This procedure is basically same for all distributions of Linux. So, let’s learn some basics.
GRUB2 Manual Basics
There used to have a file named menu.lst which was being used to configure GRUB settings in the past. But, the procedure is now different with GRUB2, it doesn’t use menu.lst file, instead it uses a configuration file called grub.cfg. You can found it in /boot/grub folder, but it cannot be used to configure the GRUB settings.
It is a configuration file which GRUB uses for its own purpose. It gets created when you run update-grub command. The main file which can be used to configure settings of GRUB is stored in /etc/default/grub file. When you edit this file then only the update gets applied to GRUB2. When you run update-grub command, the settings file gets combined with the scripts resulting in the configuration file called grub.cfg.
While booting, the bootloader uses grub.cfg configuration file and behaves accordingly. So, it is necessary to run update-grub command to apply changes to GRUB2 bootloader. Let’s learn how to configure GRUB2.
Configuring GRUB File
Configuring this file is pretty easy. In order to configure it, first, you will have to open it in a text editor. If you want to do it using terminal, open terminal or press Alt + F2 and type command:
gksu gedit /etc/default/grub
After it opens, you can see, the grub file is short and therefore easy to edit. Here, the only thing you need to do is change the values and save the changes made. If any of the lines below doesn’t appear in your file, you can always add it on a new line.
Here are some of the things you can configure using grub file:
- Change the Default OS: You can see the line which reads GRUB_DEFAULT=0 by default its value is 0. That means GRUB2 is considering the first entry values in your boot list as default. If you want to use your second boot entry as default then change the value to 1, to use 3rd entry change value to 2 and so on.
- You can also set value GRUB_DEFAULT=saved which instructs bootloader to boot the last OS you chose each time you boot. In order for it to work, you will also need to add another line – GRUB_SAVEDEFAULT=true. You can also assign a name to a default OS from your boot OS list. For example, if you have a boot list entry as Windows 10 (loader) you can assign it as – GRUB_DEFAULT=”Windows 10 (loader)”.
- Change GRUB Menu Timeout: It is nothing but an amount of time after which the GRUB automatically boots default operating system. During this time, you can either choose any of the operating systems to boot or leave it be to automatically boot. It is usually 5 seconds. Find the line which reads GRUB_TIMEOUT=5 change its value according to your choice. If you don’t want GRUB to automatically boot any OS then set GRUB_TIMEOUT=-1, the -1 value indicates infinite time, which means GRUB will always wait until you choose an OS to boot.
- Change the Background Image: In order to change the background of GRUB, you need to add an extra line – GRUB_BACKGROUND=”path” here, replace the path with actual image path. For example – GRUB_BACKGROUND=”/root/Downloads/wall.png”.
It will be best if you choose a png image instead of jpg or jpeg image. Because, GRUB only supports jpg/jpeg image that is limited only up to 256 colors, png image have no such restrictions.
Save the Changes You Made
After editing the /etc/default/grub file, just save the file and exit. After that, open terminal and run command:
This command will make necessary changes to the grub.cfg file, which GRUB will uses while booting.
Now, you can reboot your computer and see the changes take effect. This isn’t the list of all things you can change in GRUB. There are lots of other things which you can do. But, we have only explained some of the common settings which can be changed.
If you have any question regarding the above procedure, feel free to comment it down below. We would be happy to help.