User:Douglarek/Tutorials/Use systemd-boot
Current status of systemd-boot (as of 2024.11.24):
- UEFI-only support (likely by design)
- ESP discovery limited to one partition; unable to boot other systems installed on different ESP partitions
- Fewer dependencies compared to grub, built-in systemd support
- For Gentoo, manual kernel entry creation is unnecessary, sys-kernel/installkernel handles this automatically
This guide assumes ESP partition mounted at /efi, systemd as init system, and current grub bootloader. Adjust steps according to specific system configuration. The following steps outline migration from grub to systemd-boot.
Adding systemd-boot Support
Edit /etc/portage/packages.use/installkernel (or appropriate USE file location), remove all grub-related entries, add systemd-boot:
sys-apps/systemd boot # Add systemd boot support
sys-kernel/installkernel systemd-boot dracut # Automatic boot entry generation during kernel compilation
Applying USE Flag Changes
root #
emerge -avuDU @world
This will recompile systemd and installkernel.
Verifying UEFI Mode
user $
ls /sys/firmware/efi/efivars
If the system is in UEFI mode, this command will succeed. If it fails, boot into UEFI mode using a LiveCD and perform the following operations from there.
Installing systemd-boot to ESP Partition
root #
bootctl install
Created "/efi/EFI/systemd". Created "/efi/EFI/BOOT". Created "/efi/loader". Created "/efi/loader/entries". Created "/efi/EFI/Linux". Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/efi/EFI/systemd/systemd-bootx64.efi". Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/efi/EFI/BOOT/BOOTX64.EFI". Random seed file /efi/loader/random-seed successfully written (32 bytes). Successfully initialized system token in EFI variable with 32 bytes. Created EFI boot entry "Linux Boot Manager".
Listing Boot Entries
root #
bootctl list
If no boot entries are found, proceed to the next step.
Configuring Kernel and Adding Boot Entries
root #
emerge -a --config sys-kernel/gentoo-kernel
Use appropriate kernel package. Verify boot entries using
bootctl list
again.Configuring Kernel Parameters (Optional)
Edit /etc/kernel/cmdline:
quiet splash
Changes require regenerating boot entries by above step.
Configuring Boot Options (Optional)
Edit /efi/loader/loader.conf:
timeout 3
This change takes effect immediately.
Enabling Automatic systemd-boot Updates
root #
systemctl enable --now systemd-boot-update.service
Portage hooks can also be used.
Cleaning Up Unused Directories and Dependencies
root #
rm -rf /boot/*
root #
rm -rf /efi/EFI/gentoo
root #
emerge -W grub
root #
emerge -ac
The GRUB_PLATFORMS="efi-64"
entry in /etc/portage/make.conf can also be removed if present. Reboot to use systemd-boot.