Home Ubuntu How To Configure GRUB2 Boot Loader Settings In Ubuntu

How To Configure GRUB2 Boot Loader Settings In Ubuntu

By sk
Published: Updated: 167.5K views

In this tutorial, we will learn what is GRUB2, and how to configure GRUB2 Boot Loader settings in Ubuntu Linux systems. We can configure the settings either by directly editing the grub configuration file using any text editor or using any GUI applications like Grub-customizer.

What is GRUB2?

GRUB2, stands for GRand Unified Bootloader, is default boot loader for most Linux operating systems. GRUB boot loader is the first program that runs when the computer starts.

GRUB is responsible for loading and transferring control to the operating system Kernel. And then the Kernel takes charge, and initializes the rest of the operating system.

I tested the steps given below guide on Ubuntu 16.04 and 18.04 LTS desktops, however these instructions might work on all Linux operating systems that uses GRUB2 boot loader.

1. Configure GRUB2 Boot Loader settings in Ubuntu

Like I already said we can configure boot loader settings from command line or GUI.

Let us see the command line way first.

Warning: The default configuration file for GRUB2 is /boot/grub/grub.cfg. You shouldn't edit or modify this file, unless you are much familiar with GRUB2. This is the main file to boot into the Linux OS. Any misconfiguration in this file may lead you to end up with broken Ubuntu system. So, don't touch this file!

The /boot/grub/grub.cfg file is automatically generated by grub-mkconfig using templates from /etc/grub.d and settings from /etc/default/grub. Any changes you made in in /etc/default/grub file will be reflected to the GRUB2.

First, backup the /etc/default/grub file before making any changes.

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

The contents of typical grub file will look like below.

$ cat /etc/default/grub

Sample output:

# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)

# Uncomment to disable graphical terminal (grub-pc only)

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux

# Uncomment to disable generation of recovery mode menu entries

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

Whenever you made any changes in this file, you must run the following command to apply the changes to the GRUB2.

$ sudo update-grub

Let us do a few tweaks in the GRUB2 boot loader.

Download - Free eGuide: "22 Useful Tweaks To Make Ubuntu Feel Like Home"

1.1. Select default OS (GRUB_DEFAULT)

Open /etc/default/grub file using any text editor, for example nano.

$ sudo nano /etc/default/grub

Find the line "GRUB_DEFAULT". We can select the default OS to boot using this option. If you set the value as "0", the first operating system in the GRUB boot menu entry will boot. If you set it as "1", the second OS will boot, and so on.

Set default OS in Grub file in Ubuntu

Set default OS in Grub file in Ubuntu

Also, if you have more than one OS in your system, you can boot the last operating system using the value GRUB_DEFAULT=saved. Whenever you reboot the system, the last operating system will start boot. Please note that you should add a line GRUB_SAVEDEFAULT=true to make this trick work.

Configure grub to boot last operating system

Configure grub to boot last operating system

You can also specify the name of the operating system's entry to boot a particular OS. For example, if there is an entry called "Lubuntu 16.04 LTS" in the BOOT menu, you can use GRUB_DEFAULT="Lubuntu 16.04 LTS" to boot Lubuntu by default. Be mindful that you should specify the value within the quotes.

Don't forget to update the changes made in grub file by running the following command:

$ sudo update-grub

1.2. Set OS timeout (GRUB_TIMEOUT)

By default, the selected entry from the boot menu will start to boot in 10 seconds.

You can increase or decrease this timeout setting. If the value is "0", the default OS will immediately start to boot. If the value is "5" , the boot menu will appear for 5 seconds, so that you can select which OS you want to load when the system starts.

Set Grub timeout value

Set Grub timeout value

1.3. Change GRUB background image

To change the GRUB background image, you need to copy your preferred image to /boot/grub/ location.

$ sudo cp ostechnix.png /boot/grub/

You can use JPG/JPEG format images as well. But GRUB supports only 256 color JPG/JPEG image formats only. So, it is better to use PNG format images.

Alternatively, you can directly mention the image file path in /etc/default/grub file like below.

$ sudo nano /etc/default/grub

Add the following line:


Replace the image path with your own.

Once you made the necessary changes in the GRUB file, Save and close it.

To apply the changes, you must run the following command:

$ sudo update-grub

You should see the following output:

Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found background image: ostechnix.png
Found linux image: /boot/vmlinuz-4.15.0-23-generic
Found initrd image: /boot/initrd.img-4.15.0-23-generic
Found linux image: /boot/vmlinuz-4.15.0-20-generic
Found initrd image: /boot/initrd.img-4.15.0-20-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin

Reboot and check whether the changes are working or not.

Change GRUB background image

Change GRUB background image in Ubuntu

Suggested read:

2. Configure GRUB2 Boot Loader settings Using Grub-customizer

Some of you may not comfortable with commandline. If you're one of them, you can use a graphical tool called "Grub-customizer" to configure Grub2 and Burg boot loaders.

Using Grub-customizer, we can,

  • Edit, remove, rename and re-arrange boot menu entries,
  • Hide or show boot menu,
  • Change default boot entry,
  • Change text color of boot menu entries,
  • Change boot menu background image,
  • Increase or decrease boot time,
  • Edit kernel parameters,
  • Reinstall Grub into Windows MBR.

Grub-customizer has an official PPA for Ubuntu and its derivatives such as Linux Mint. You can add it and install Grub-customizer by running the following commands one by one:

$ sudo add-apt-repository ppa:danielrichter2007/grub-customizer
$ sudo apt update
$ sudo apt install grub-customizer

Once installed, launch it from Dash or Menu. Here is how Grub-customizer default interface looks like.

grub-customizer interface

grub-customizer interface

As you can see in the above screenshot, Grub-customizer have the following threes tabs.

  • List configuration,
  • General settings,
  • Appearance settings.

In List configuration, you can edit, delete, rename, and re-arrange(move) boot menu entries. For example, to rename a menu entry, just right click on it, choose Rename and enter the name of your choice.

Similarly, to move an entry, choose it, right click and then click Move up or Move down. You can also  use UP/Down arrows in the menu bar to move entries.

Edit boot menu entries in grub-customizer

Edit boot menu entries in grub-customizer

After making the changes, click on the Save button on the menu bar.

In General settings section, we can,

  • Change default boot entry (can use useful when dual-booting),
  • Boot into last booted entry i.e boot the last operating system,
  • Show/hide boot menu visibility,
  • Change boot menu delay,
  • Change kernel parameters.
grub-customizer general settings

grub-customizer general settings

In Appearance settings, we can,

  • Change font for boot menu entries,
  • Set font color,
  • Set background image and so on.
grub-customizer appearance settings

grub-customizer appearance settings

Do not forget to hit the Save button after making any changes.

There is also an additional section called "Advanced settings" in the right bottom side of Grub-customizer interface. In the advanced settings section, you can quickly add, remove, enable/disable and edit values for various boot loader settings such as GRUB_DEFAULT, GRUB_TIMEOUT, GRUB_MENU_PICTURE and a few more.

grub-customizer advanced settings

grub-customizer advanced settings

Again, I warn you - do not edit or modify GRUB2 settings in production systems. I recommend you to test these settings in any virtual machine and then apply them in your personal desktop.

Suggested read:


You May Also Like


BobDodds October 14, 2018 - 9:07 pm

grub-customizer wants un-installable packages as pre-requisite.

I don’t have any problem editing a text file, /etc/default/grub, and this info was just what I needed to save default, load saved.

Jim September 27, 2019 - 5:08 pm

I have grub-customizer installed on my Ubuntu Mate 18.04. You can also use a PPA to install it. As for un-installable packages that can happen with any package due to dependencies that haven’t been updated for the version of the OS you are running. Usually when that happens eventually the packages are updated, so try again before you do an upgrade.

Neil April 8, 2019 - 7:18 am

I tried to use “nano” without success. It took a couple of tries for me to discover that the cursor doesn’t blink. Eventually I discovered that by moving the cursor over the value I wanted to change highlighted it to the end of the line. I was trying to change a zero to a four. I wound up with three fours at the beginning of the file. After fruitless searching I used “gedit” which worked as expected. I saved my file, did the update and tested it. All was well.

Ketim October 22, 2019 - 3:43 am

I like the background image. Can you share it?

sk October 22, 2019 - 12:35 pm

I deleted that image. My apologies.

PrisonMike July 20, 2020 - 2:26 pm

I followed all the CLI instructions. I got no error. But the GRUB settings didn’t change. At all. I added BG image, beep on grub load, change of default boot OS, no change occurred. I rechecked the grub file and it confirmed that all the changes I made to the file were noted.

Robert Christian October 27, 2020 - 3:18 am

I used gedit. worked fine. Thank you so much.


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More