0% found this document useful (0 votes)
52 views

How To Configure GRUB2 Boot Loader

This document discusses how to configure the GRUB2 boot loader settings in Ubuntu. It begins by explaining what GRUB2 is and its role in booting Linux systems. It then provides instructions for editing the /etc/default/grub file to change settings like the default operating system, timeout, and background image. Key steps include making backups, editing values like GRUB_DEFAULT and GRUB_TIMEOUT, copying images to /boot/grub/, and running update-grub to apply changes. Examples of tweaks include booting the last used OS, increasing the timeout, and setting a custom background.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

How To Configure GRUB2 Boot Loader

This document discusses how to configure the GRUB2 boot loader settings in Ubuntu. It begins by explaining what GRUB2 is and its role in booting Linux systems. It then provides instructions for editing the /etc/default/grub file to change settings like the default operating system, timeout, and background image. Key steps include making backups, editing values like GRUB_DEFAULT and GRUB_TIMEOUT, copying images to /boot/grub/, and running update-grub to apply changes. Examples of tweaks include booting the last used OS, increasing the timeout, and setting a custom background.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

How To Configure GRUB2 Boot

Loader Settings In Ubuntu

As you probably know, GRUB2 is default boot loader for most Linux


operating systems. GRUB stands for GRand Unified Bootloader. GRUB
boot loader is the first program that runs when the computer starts. It 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. In this tutorial, let me show you how to configure GRUB2
Boot Loader settings in Ubuntu system. 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.
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.
Configure GRUB2 Boot Loader
settings
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. If you do anything
wrong with this file, then you will surely be end up with broken 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_DEFAULT=0

GRUB_HIDDEN_TIMEOUT=0

GRUB_HIDDEN_TIMEOUT_QUIET=true

GRUB_TIMEOUT=10

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


echo Debian`

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

GRUB_CMDLINE_LINUX=""

# 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 ...)

#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefef
ef"
# Uncomment to disable graphical terminal (grub-pc
only)

#GRUB_TERMINAL=console

# 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'

#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass


"root=UUID=xxx" parameter to Linux

#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu


entries

#GRUB_DISABLE_RECOVERY="true"

# 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. 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.
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.
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 could 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

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.

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:

GRUB_BACKGROUND="/home/sk/ostechnix.png"

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
done
Reboot and check whether the changes are working or not.

Change GRUB background image in Ubuntu


https://www.ostechnix.com/configure-grub-2-boot-loader-settings-ubuntu-16-04/

You might also like