RHCSA – Understanding GRUB2


By the end of this article you should be able to answer the following questions:


You can find all my latest posts on medium.

What is that brief menu called that's displayed briefly during machine bootup, prompting you to select a kernel version?

The grub menu

What is config file you can edit to customize this menu's behaviour, e.g. the timeout period?


What is the directory's content that you can also edit to customize this menu's behaviour, e.g. the timeout period?


What is the command to preview your potential new grub configuration?

$ grub2-mkconfig | less

What is the command to persistantly apply your changes?

$ grub2-mkconfig > /boot/grub2/grub.cfg

The GRUB menu

The grub menu is something that get’s displayed briefly when your machine is booting up, and it looks like this:


A important task you may need to do is access the grub menu to edit the GRUB parameters to enter the rescue or emergency target.

This is useful if you need to access your machine in rescue mdoe or emergency mode (scroll down to line start with “linux16”, go to the end of line, type systemd.unit={target-name}.unit).

Configuring GRUB

GRUB is short for the “Grand Unified Bootloader” and it is the very first linux related component that is activated when powering up a machine.

The main config file for grub is:


However you’re not supposed to edit this file directly. Instead you edit this file indirectly by first editing the following:

  • /etc/default/grub # this is a file
  • /etc/grub.d

Any change here can then be fed into the grub2-mkconfig which will generate output that can be piped into /boot/grub2/grub.cfg.

First we preview the new configuratons:

$ grub2-mkconfig | less

You can control the GRUB’s behaviour via the GRUB2’s main config file:

$ cat /etc/default/grub
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_CMDLINE_LINUX=" crashkernel=auto vconsole.font=latarcyrheb-sun16 vconsole.keymap=uk rhgb quiet"

Here the 2 main settings are, GRUB_TIMEOUT – which sets how long the grub menu is displayed before disappearing, and, GRUB_CMDLINE_LINUX, this lists all the arguements that are passed through the kernel while the machine is booting. Here you can remove the “rhgb quiet” in order to get more verbose output when the machine is loading up.

Note, you can also create grub config files in the following directory too:

$ ls -l /etc/grub.d/
total 64
-rwxr-xr-x. 1 root root  8698 Jun 30  2014 00_header
-rwxr-xr-x. 1 root root  9517 Jun 30  2014 10_linux
-rwxr-xr-x. 1 root root 10275 Jun 30  2014 20_linux_xen
-rwxr-xr-x. 1 root root  2559 Jun 30  2014 20_ppc_terminfo
-rwxr-xr-x. 1 root root 11110 Jun 30  2014 30_os-prober
-rwxr-xr-x. 1 root root   214 Jun 30  2014 40_custom
-rwxr-xr-x. 1 root root   216 Jun 30  2014 41_custom
-rw-r--r--. 1 root root   483 Jun 30  2014 README

However it is very unlikely that you will need to do anything in this directory.

Once you have made any changes to grub configurations, you need to run the following command:

$ grub
grub2-bios-setup       grub2-macbless         grub2-mkpasswd-pbkdf2  grub2-render-label
grub2-editenv          grub2-menulst2cfg      grub2-mkrelpath        grub2-script-check
grub2-file             grub2-mkconfig         grub2-mkrescue         grub2-set-default
grub2-fstest           grub2-mkfont           grub2-mkstandalone     grub2-sparc64-setup
grub2-glue-efi         grub2-mkimage          grub2-ofpathname       grub2-syslinux2cfg
grub2-install          grub2-mklayout         grub2-probe            grubby
grub2-kbdcomp          grub2-mknetdir         grub2-reboot

This command essentially updates the MBR with the new grub configurations, e.g. new timeout value.

Hence if you made any changes to the main grub config file, then you need to run the grub2-mkconfig command, to get it loaded into the mbr:

$ grub2-mkconfig > /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.4.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-3cf91f1bd95c4bbfbccf8ee2b5424021
Found initrd image: /boot/initramfs-0-rescue-3cf91f1bd95c4bbfbccf8ee2b5424021.img

This will update the main grub.cfg file. This is a file that you’re not supposed to update directly. Instead you use grub2-mkconfig to generate an updated file /boot/grub2/grub.cfg for you.