In the previous step, we looked at /etc/default/grub
, which is the primary configuration file for GRUB. However, this file is not directly used by GRUB during the boot process. Instead, the settings in /etc/default/grub
are used to generate the actual GRUB menu configuration file, which is located at /boot/grub/grub.cfg
.
The /boot/grub/grub.cfg
file is automatically generated by the update-grub
command (or grub-mkconfig
). It contains the menu entries that you see when the computer starts, allowing you to choose which operating system or kernel to boot.
Important: You should never manually edit the /boot/grub/grub.cfg
file. Any changes you make will be overwritten the next time update-grub
is run. Always modify /etc/default/grub
and then run sudo update-grub
to apply your changes.
Let's view the contents of the /boot/grub/grub.cfg
file using the cat
command.
Type the following command in your terminal and press Enter:
cat /boot/grub/grub.cfg
You will see a much longer and more complex output compared to /etc/default/grub
. This file contains the detailed configuration for each boot menu entry, including the kernel path, initrd path, and kernel command-line parameters.
#
## DO NOT EDIT THIS FILE
#
## 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 ###
...
#### END /etc/grub.d/00_header ###
#### BEGIN /etc/grub.d/05_debian_theme ###
...
#### END /etc/grub.d/05_debian_theme ###
#### BEGIN /etc/grub.d/10_linux ###
...
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' {
recordfail
...
linux /boot/vmlinuz-*-generic root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ro quiet splash $vt_handoff
initrd /boot/initrd.img-*-generic
}
...
#### END /etc/grub.d/10_linux ###
#### BEGIN /etc/grub.d/20_linux_xen ###
...
#### END /etc/grub.d/20_linux_xen ###
#### BEGIN /etc/grub.d/30_os-prober ###
...
#### END /etc/grub.d/30_os-prober ###
#### BEGIN /etc/grub.d/30_uefi-firmware ###
...
#### END /etc/grub.d/30_uefi-firmware ###
#### BEGIN /etc/grub.d/40_custom ###
...
#### END /etc/grub.d/40_custom ###
#### BEGIN /etc/grub.d/41_custom ###
...
#### END /etc/grub.d/41_custom ###
You can scroll through the output to see the different menu entries and their configurations. Look for lines starting with menuentry
. These define the options that appear in the GRUB boot menu.
This file is complex, and you don't need to understand every line right now. The key takeaway is that /boot/grub/grub.cfg
is the file GRUB actually uses, and it's generated from /etc/default/grub
and scripts in /etc/grub.d
.
Click Continue to move on.