GRUB is the default bootloader for many Linux distributions. It is highly configurable and supports multiple operating systems, file systems, and advanced features like scripting and network booting.
/boot/grub/grub.cfg
/etc/default/grub
(used to generate grub.cfg
)sudo update-grub # Debian-based systems
sudo grub-mkconfig -o /boot/grub/grub.cfg # Other systems
sudo grub-install /dev/sdX # Replace X with the appropriate drive letter
# /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
# /boot/grub/grub.cfg (generated)
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
linux /boot/vmlinuz-5.4.0-42-generic root=UUID=xxxx ro quiet splash
initrd /boot/initrd.img-5.4.0-42-generic
}
Chainloading allows one bootloader to load another bootloader. This is useful for systems with multiple operating systems that each have their own bootloaders.
menuentry "Chainload Another GRUB" {
set root=(hd0,1)
chainloader +1
}
If GRUB fails to boot, it enters rescue mode, allowing users to manually boot the system or repair the bootloader.
set root=(hd0,1)
linux /boot/vmlinuz root=/dev/sda1
initrd /boot/initrd.img
boot