Grub

Configuring grub for a multi OS system
Main grub configuration file is /etc/default/grub
Default Entry = Last Saved
1GRUB_SAVEDEFAULT=true
2GRUB_DEFAULT=saved
Note :
- Comment out entries such as
GRUB_DEFAULT=0
for this to take effect- This does not work if
/boot
partition is in btrfs or lvm filesystem
Detect other bootable OSes
Activate os-prober
1GRUB_DISABLE_OS_PROBER=false
Console
For a TUI,
1GRUB_TERMINAL=console
Update grub.cfg
On Debian
1sudo update-grub
On Arch/Fedora (Even Debian)
1sudo grub-mkconfig -o /boot/grub/grub.cfg
Add custom entry
Note : Place custom grub entries in /etc/grub.d/ not in /etc/default/grub.d/
To add custom menus and submenus edit the file /etc/grub.d/40_custom
Examples
Standard
1# "Shutdown" menu entry
2menuentry "System shutdown" {
3 echo "System shutting down..."
4 halt
5}
6
7# "Restart" menu entry
8menuentry "System restart" {
9 echo "System rebooting..."
10 reboot
11}
12
13# "UEFI Firmware Settings" menu entry
14if [ ${grub_platform} == "efi" ]; then
15 menuentry 'UEFI Firmware Settings' --id 'uefi-firmware' {
16 fwsetup
17 }
18fi
Chainloading a different EFI paritition
1if [ "${grub_platform}" == "efi" ]; then
2 menuentry "Debian on Different SSD" {
3 savedefault
4 insmod part_gpt
5 insmod fat
6 insmod chain
7 search --no-floppy --fs-uuid --set=root AB12-CD34
8 chainloader /EFI/debian/grubx64.efi
9 }
10fi
Windows grub entry
1menuentry 'Windows Boot Manager (on /dev/nvme0n1p1)' --class windows --class os $menuentry_id_option 'osprober-efi-541A-B5FD' {
2 savedefault
3 insmod part_gpt
4 insmod fat
5 search --no-floppy --fs-uuid --set=root 541A-B5FD
6 chainloader /EFI/Microsoft/Boot/bootmgfw.efi
7}