There are many reasons to change the default Grub to systemd-boot. For me, it was for a simple reason. I have my disk encrypted with LUKS2 and by default, Manjaro / EndeavourOS encrypt all the disk, including the /boot partition. Decrypting this partition takes arounds 40 seconds on a NVme drive with a 7th Gen Intel CPU, making the total boot time around 1’30. After the modification, total boot time took 30 seconds.
So after searching how to make it faster by keeping Grub, the conclusion was Grub is not the good candidate for what I want to do. I found this post on EndeavourOS forum, applied it and modified it a little.
Prerequisites
You’ll need :
- a Grub boot
- your computer connected to Internet
- 10 minutes of your time
Install systemd-boot
First, we will remove Grub. Open a terminal and type
sudo pacman -Rc grub
Now, we will create a dedicated EFI partition to replace /boot.
sudo mkdir /efi
We collect the informations about the current EFI partition
efidevice=$(findmnt /boot/efi -no SOURCE)
And we mount it
sudo umount /boot/efi sudo mount ${efidevice} /efi
Open /etc/fstab and replace /boot/efi by /efi
sudo nano /etc/fstab
It should look like this
Save with ctrl+o ctrl+x
You can now install systemd-boot
sudo bootctl install
Open
sudo nano /efi/loader/loader.conf
and remove the # before timeout
Full code :
sudo pacman -Rc grub
sudo mkdir /efi efidevice=$(findmnt /boot/efi -no SOURCE) sudo umount /boot/efi sudo mount ${efidevice} /efi
sudo bootctl install
Generate the new boot list
Now we have systemd-boot installed, but nothing is configured. It’s important you don’t reboot, or you’ll just get a black screen.
First, we will install a package that will automatically generate the entries in your mkinitcpio.
yay -S kernel-install-mkinitcpio
Now, we will generate the boot entries for the Kernels installed.
# Find the configured esp esp=$(bootctl -p) # Prepare the efi partition for kernel-install machineid=$(cat /etc/machine-id) if [[ ${machineid} ]]; then sudo mkdir ${esp}/${machineid} else echo "Failed to get the machine ID" fi # Run kernel install for all the installed kernels while read -r kernel; do kernelversion=$(basename "${kernel%/vmlinuz}") echo "Installing kernel ${kernelversion}" sudo kernel-install add ${kernelversion} ${kernel} done < <(find /usr/lib/modules -maxdepth 2 -type f -name vmlinuz)
We no longer need the /boot. Let’s do some cleanup.
sudo rm -r /boot/efi /boot/grub /boot/initramfs* /boot/vmlinuz* sudo rm /etc/mkinitcpio.d/linux.preset
Removing the preset will can mkinitcipio -P command to fail. Fix it with
sudo pacman -S linux
If you have a LUKS encrypted partition, you can remove the keyfile, as you don’t need it anymore. It’s stored in an unencrypted location and shouldn’t be used.
Edit /etc/mkinitcpio.conf and remove /crypto_keyfile.bin from FILES section
sudo nano /etc/mkinitcpio.conf
I’ve added a # at the beginning of the line to comment it, just in case I have to rollback.
Now rebuild your initramfs
sudo mkinitcpio -P
And you’re done !