Wednesday, December 11, 2024

Switch Fedora 41 from GRUB2 to systemd-boot

Fedora uses GRUB2 boot loader by default. I want to switch to systemd-boot. Below are the steps. All executed with sudo.

Run ls /sys/firmware/efi to ensure the system was booted in EFI mode. Stop if the path does not exist.

Run bootctl status to confirm that system-boot was not the boot loader.

Run df -h to ensure the EFI system partition's free space is larger then /boot's used space.

dnf install -y systemd-boot

mkdir /efi

nano /etc/fstab
Move the /boot/efi mount point to /efi. Remove the line of /boot.

systemctl daemon-reload

umount /boot/efi

umount /boot

mount /efi

mkdir /efi/$(cat /etc/machine-id)

bootctl install

cat /proc/cmdline | cut -d ' ' -f 2- | tee /etc/kernel/cmdline

nano /etc/kernel/install.conf. Put these two lines
BOOT_ROOT=/efi
layout=bls

kernel-install add $(uname -r) /lib/modules/$(uname -r)/vmlinuz 

dnf reinstall kernel-core 

Reboot. Run bootctl status to confirm that system-boot is the boot loader.

If everything works, delete grub.

rm /etc/dnf/protected.d/{grub,shim}*

dnf remove grubby grub2\* memtest86\*