• update-grub


  • /etc/default/grub

  • /etc/default/grub.d

  • /etc/grub.d/

  • /boot/grub/grub.cfg

Further Reading

Introduction to GRUB

GRUB is short for the GRand Unified Bootloader. It’s the program responsible for bringing Linux off of the hard disk or other boot medium and into RAM. If you’re familiar with Linux you’ve seen GRUB many times but perhaps never interacted with it. Usually you don’t have to unless it’s an emergency. GRUB has a BASH-like command shell that can be activated by pressing any key when you see the GRUB boot menu.

GRUB Configuration

GRUB is configuredin various places. Here’s a map:

Location Purpose
/etc/default/grub The GRUB configuration file. All configuration goes here.
/etc/default/grub.d/* Files that override /etc/default/grub. This is where pluggable GRUB configuration goes.
/etc/grub.d/* Shell scripts that build /boot/grub/grub.cfg
/boot/grub/grub.cfg The GRUB configuration that's used at boot time. You might say the real configuration. This file is generated from the configuration options in /etc/default/grub and /etc/default/grub.d/*.

On your Vagrant box GRUB's /etc/default/grub is this:

# 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`
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0"

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

Settings in /etc/default/grub must be legal BASH assignments. The pound sign (#) is the comment character in BASH so options that are after a # are ignored. Most of the things that are easy to tune are located here. The GRUB boot menu is generated when you run the command:

# sudo update-grub

That command uses the scripts located in /etc/grub.d:

$ ls -l /etc/grub.d/
total 76
-rwxr-xr-x 1 root root  9791 Nov 28 16:19 00_header
-rwxr-xr-x 1 root root  6258 Jan 24  2018 05_debian_theme
-rwxr-xr-x 1 root root 12512 Nov 28 16:19 10_linux
-rwxr-xr-x 1 root root 11082 Nov 28 16:19 20_linux_xen
-rwxr-xr-x 1 root root 11692 Nov 28 16:19 30_os-prober
-rwxr-xr-x 1 root root  1418 Nov 28 16:19 30_uefi-firmware
-rwxr-xr-x 1 root root   214 Nov 28 16:19 40_custom
-rwxr-xr-x 1 root root   216 Nov 28 16:19 41_custom
-rw-r--r-- 1 root root   483 Nov 28 16:19 README

Notice that the file names have numbers. This is because they’re run in order: 00 first and 99 last. GRUB cannot see into complex Linux partitions (like LVM) so the /boot partition is usually formatted with the ext4 filesystem. When you run update-grub GRUB’s generated configuration is placed into /boot/grub/grub.cfg. Notice the warning at the top of /boot/grub/grub.cfg:

# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
 set have_grubenv=true