GRUB - Grand Unified Boot Loader
GRUB's responsibility in the boot process
GRUB2 Installation
There may come a time where you need to install or reinstall GRUB2 on a system. Depending on whether your system is booting via BIOS or UEFI, you'll need to use a slightly different method;
-
BIOS
The below command can be used to install GRUB2 on a BIOS system (using MBR disks format)
grub2-install [options] /dev/sdXOption Function --modules modulenames Reload specified kernel modules
--install-modules modulenamess Install only the specified modules and dependencies. -
UEFI
GRUB2 Configuration, Customisation, and Options
/etc/grub.d - This directory stores configuration scripts that define boot entries for GRUB2. Scripts within this directory are used to build the grub.cfg file;
daniel@jump:~$ ls -l /etc/grub.d
total 136
-rwxr-xr-x 1 root root 10627 Dec 18 2022 00_header
-rwxr-xr-x 1 root root 6260 Dec 2 2022 05_debian_theme
-rwxr-xr-x 1 root root 18683 Dec 18 2022 10_linux
-rwxr-xr-x 1 root root 43031 Dec 18 2022 10_linux_zfs
-rwxr-xr-x 1 root root 14387 Dec 18 2022 20_linux_xen
-rwxr-xr-x 1 root root 13369 Dec 18 2022 30_os-prober
-rwxr-xr-x 1 root root 1372 Dec 18 2022 30_uefi-firmware
-rwxr-xr-x 1 root root 700 May 17 2023 35_fwupd
-rwxr-xr-x 1 root root 214 Dec 18 2022 40_custom
-rwxr-xr-x 1 root root 215 Dec 18 2022 41_custom
-rw-r--r-- 1 root root 483 Dec 18 2022 README
If you wanted to add a custom script or feature to grub, you could do that within this directory by either adding a new file, or updating an existing file.
/boot/grub - This directory stores the actual GRUB2 configuration files used during boot;
daniel@jump:~$ ls -l /boot/grub
total 2380
drwxr-xr-x 2 root root 4096 Jan 27 2024 fonts
-rw-r--r-- 1 root root 712 Jan 27 2024 gfxblacklist.txt
-rw-r--r-- 1 root root 9028 Jun 4 06:18 grub.cfg
-rw-r--r-- 1 root root 1024 Jul 4 2024 grubenv
drwxr-xr-x 2 root root 12288 Jan 27 2024 i386-pc
drwxr-xr-x 2 root root 4096 Jan 27 2024 locale
-rw-r--r-- 1 root root 2392289 Jan 27 2024 unicode.pf2
/etc/default/grub - This file contains the GRUB2 display menu settings that are read by the /etc/grub.d scripts.
There are also 2 commands to note for GRUB configuration:
grubby
-
Function:
grubbyis a command-line tool that allows you to directly manipulate individual GRUB2 menu entries on your system. It provides functionalities for:- Setting the default boot entry
- Adding, removing, or modifying existing entries
- Changing boot order
- Viewing information about current entries
-
Focus:
grubbyoperates on individual boot entries within the existing GRUB2 configuration.
Generating or regenerating the grub.cfg file
grub2-mkconfig
grub2-mkconfig (or sometimes shortened to update-grub2 on some systems) is a utility used to regenerate the GRUB2 configuration file (grub.cfg) located in /boot/grub. It reads configuration scripts from the /etc/grub.d directory.
No Comments