Bootloader
systemd-boot
systemd-boot can be used to EFI systems. While some installations default to install systemd-boot
, one can also convert from booting via GrUB to systemd-boot
.[1]
This libvirt VM first had to be switched from BIOS to EFI:[2]
$ virsh edit vm0 [...] <os firmware='efi'>
With that in place, the VM should now be an EFI system:
$ [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS UEFI
We can now prepare the migration from GrUB to systemd-boot
. For this Fedora VM:
- Move
/boot/efi
to/efi
- Install
systemd-boot
:
sudo mkdir /efi/$(cat /etc/machine-id) rm /etc/dnf/protected.d/{grub,shim}* dnf remove grubby grub2* rm -rf /boot/grub2 /boot/loader dnf install systemd-boot sdubby
Do not reboot just yet, we have to install the kernel still:
cut -d ' ' -f 2- /proc/cmdline | tee /etc/kernel/cmdline bootctl install kernel-install add $(uname -r) /lib/modules/$(uname -r)/vmlinuz dnf reinstall kernel-core
If the /efi
is not big enough to hold all the installed kernels and the rescue image, we may need to disable the latter:
mv -iv /usr/lib/kernel/install.d/51-dracut-rescue.{install,disabled}
...and the call kernel-install
again. If all goes well (and we're not stumbling across weird firmware bugs[3], we can now reboot. To enable the systemd-boot
boot menu:
bootctl set-timeout 10
GRUB 2
GRUB 2 has really replaced #GRUB Legacy now. The configuration is built by grub2-mkconfig
from the configuration files in /etc/grub.d
. A few defaults can be set in /etc/default/grub
/etc/default/grub
# Boot first entry per default GRUB_DEFAULT=0 # Disable the submenu, so that GRUB_DEFAULT can address each boot entry more easily. GRUB_DISABLE_SUBMENU=y # Wait this many seconds for the user to press a key GRUB_HIDDEN_TIMEOUT=0 # No countdown is displayed GRUB_HIDDEN_TIMEOUT_QUIET=true # Seconds to display the boot menu before booting GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` # Boot parameters GRUB_CMDLINE_LINUX="" # Special boot parameters for the GRUB_DEFAULT entry GRUB_CMDLINE_LINUX_DEFAULT="" # Select output device GRUB_TERMINAL=console # Disable "root=UUID=xxx" parameters # GRUB_DISABLE_LINUX_UUID=true # Disable recovery mode menu entries GRUB_DISABLE_RECOVERY="true"
Notes:
GRUB_DISABLE_SUBMENU
may not be available in earlier GRUB versions.[4][5]GRUB_DEFAULT
setting can also be used to boot nested configuration[6] items. For example, let's assume the following boot menu:
0) Linux 1) Previous Versions > 1.0) Linux_2 2.1) Linux_3
To boot "Linux_3", set GRUB_DEFAULT
to "Previous Versions>Linux_3". Numbers can also be used ("1>1"), but using the exact menu entry names may be more easy to read.
To activate the configuration:
sudo update-grub # Debian, Ubuntu sudo grub-mkconfig -o /boot/grub/grub.cfg # Fedora, Arch Linux
/boot/grub/grub.cfg
menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os { insmod part_gpt insmod ext2 set root='(hd0,gpt1)' search --no-floppy --fs-uuid --set 92ed9f74-dd26-4750-9e10-d376214ab13f echo 'Loading Linux...' linux /boot/vmlinuz-2.6.32-5-amd64 root=UUID=92ed9f74-dd26-4750-9e10-d376214ab13f ro echo 'Loading initial ramdisk...' initrd /boot/initrd.img-2.6.32-5-amd64 }
grub2-editenv
Some parameters can be set via grub2-editenv
:[7]
grub2-editenv - set menu_auto_hide=0
Generate grub.cfg
for a non UEFI-system:[8]
grub2-mkconfig -o /boot/grub2/grub.cfg
List all the grub.cfg
entries:
grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
Set and verify the default entry:[9]
grub2-set-default <menu entry title> grub2-editenv list
GRUB Legacy
GRUB Legacy is no longer being developed, but let's mention it for historical purposes.
title GNU/Linux root (hd0,0) kernel /boot/vmlinuz root=/dev/hda1 ro initrd /boot/initrd.img title Windows NT root (hd1,0) makeactive # Makes hd1,0 active, i.e. it modifies hd1! chainloader +1
LiLo
/etc/lilo.conf
# global lba32 large-memory # allow for initrds larger than 15MB map=/boot/lilo/map backup=/boot/lilo/boot.NNNN install=menu # text, menu, bmp prompt timeout=100 # 10s timeout for 'prompt' boot=/dev/hda default=Linux # serial=0,115200n8 # disk=/dev/sda # bios=0x80 # disk=/dev/hda # disk=0x81 # linux image=/boot/vmlinuz-2.6.26 label="Linux" root=/dev/hda1 append="" read-only # bsd/windows other=/dev/hda3 label="FreeBSD" optional
FreeBSD Boot Manager
tbd
Windows NTLDR
C:\boot.ini
[boot loader] timeout=30 default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect
Links
References
- ↑ Systemd-boot install on Fedora 32 (Updated for Fedora 39)
- ↑ virt-manager - Change firmware AFTER installation
- ↑ Regression in 252: Secure boot override does not work with some firmware
- ↑ RH#908528: Add GRUB_DISABLE_SUBMENU config option
- ↑ grub-devel: Add GRUB_DISABLE_SUBMENU option
- ↑ Set “older” kernel as default grub entry
- ↑ Unset menu_auto_hide is how to force grub2 boot-menu visibility on every boot for kernel-parameters
- ↑ Working with the GRUB 2 Boot Loader
- ↑ GRUB2: Setting default entry