Systemd-boot automatic update with systemd-boot-manager

Hi there,

recently I tried to switch from grub to systemd-boot, since grub took too long time for me until the boot started. Installing systemd-boot was fairly easy and everything work perfectly. Then I found systemd-boot-manager to update the systemd-boot files as well as the kernels after pacman installs. The problem: My EFI partition is /boot/efi, the kernels are installed unter /boot.

If I use systemd-boot in this condition, no boot entry would be generated since the tool searches in the EFI partition (/boot/efi) for kernels, does not find one and creates no entry therefore. In my case it indeed removes the exising entry which would have made my system unbootable hadn’t I still installed grub as a fallback.

My proposal would be to use kernel-install from systemd which works perfectly. If additional configuration from sdboot-manage.conf shall be applied, the generated loader/entries/* files could be adapted by e.g. sed with the options.

Regards, Sven

systemd-boot-manager was created by @dalto. He’s not as active here as he once was, so perhaps share your proposal in an issue or create a merge request.

1 Like

To use systemd-boot - you must mount the $esp partition at either /boot or /efi. (systemd-boot - ArchWiki)

That means you will have to change your fstab mount directive

1 Like

I responded more fully on gitlab but to me kernel-install is an alternative to what systemd-boot-manager does. It provides similar automation in a very different way.

mkinitcpio is what is putting your kernels in /boot. You need to either use a hook/script to move them to the right place or override the mkinitcpio presets to put them in the right place to begin with.

While using /efi or /boot is the recommended convention, it isn’t a requirement. You can run systemd-boot from /boot/efi if you want to. It is, however, a very odd thing to do.


Well, it may be odd, but is some sort of “traditional” since other distributions like ubuntu mount the EFI partition that way.

It makes sense if those distros use grub or some other bootloader which keeps the kernels separate from the esp. It makes less sense if you are using systemd-boot where the kernels need to be in the efi partition.

But, either way, it should work if that is your preference.

That being said, I like kernel-install too, especially for multi-booting. Getting it working smoothly and in an automatic was on Arch-based distros has been some fun. It definitely isn’t ideal out-of-the-box because of the Arch reliance on the kernels/initrams being in a consistent location.

Thanks - I appreciate your contribution.

From my reading on systemd-boot it only accept configuration in ESP/loader which makes it necessary to mount the $esp at /boot (or another location)

As the systemd specification mandates the /loader directory to be in the root of the $esp this indirectly mandates a directory separate from the filesystems root.

The Arch bootctl binary defaults to /boot or /efi - but can be told to look elsewhere and your sdboot-manage script is coded to use those locations - right?

Ubuntu uses GRUB as boot loader and therefore the ESP is mounted at /boot/efi - because that is a location grub can understand.

With systemd you can even skip mounting the system devices. If they are setup using the correct partition type UUID it will be loaded automagically.

And I just got a lot of info to digest - just by reading the BootLoaderSpec

bootctl detects esp. It doesn’t need to be in /efi or /boot. It also supports /boot/efi

My scripts use bootctl to detect esp.

For example,

$ bootctl -p

I forgot that bootctl command - thank’s for reminding me :wink:

1 Like

@dalto it doesn’t seem to bee working for me, no matter where I mount /efi. esp can’t be /boot because it’s too small, so I’m using XBOOTLDR

[root@manjaro-gnome /]# bootctl --esp-path=/boot/efi --boot-path=/boot install
Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/efi/EFI/systemd/systemd-bootx64.efi".
Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/efi/EFI/BOOT/BOOTX64.EFI".
Random seed file /boot/efi/loader/random-seed successfully written (512 bytes).
Created EFI boot entry "Linux Boot Manager".
[root@manjaro-gnome /]# bootctl -p                                             
[root@manjaro-gnome /]# rm -rf /boot/loader                                    
[root@manjaro-gnome /]# sdboot-manage gen                                      
[root@manjaro-gnome /]# ls /boot/efi/loader/entries                            
[root@manjaro-gnome /]# sdboot-manage update                                   
Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/efi/EFI/systemd/systemd-bootx64.efi".
Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/efi/EFI/BOOT/BOOTX64.EFI".
[root@manjaro-gnome /]# ls ls boot/efi/loader/entries                          
ls: cannot access 'ls': No such file or directory
[root@manjaro-gnome /]# ls  boot/efi/loader/entries
[root@manjaro-gnome /]# ls /boot                                               
efi				    intel-ucode.img
initramfs-5.10-x86_64-fallback.img  linux510-x86_64.kver
initramfs-5.10-x86_64.img	    vmlinuz-5.10-x86_64

The problem is that xbootldr didn’t exist when I initially wrote systemd-boot-manager and support for that has never been added.

I created and edited new config file Manjaro.conf in /boot/efi/loader/entries.
Then I copied all imgs and vmlinuz from /boot into /boot/efi/EFI/ManjaroBoot. It worked fine.
But my change is gone after pacman update.
I do not know how to change pacman’s hook.

If you want to manage your own entries, you can simply uninstall systemd-boot-manager or disable it.

However, I would warn you that your approach is going to have some challenges going forward.

When your kernels update, the files in /boot/efi/EFI/ManjaroBoot won’t get updated. The same thing as new kernels are installed.

If you explain what you are trying to accomplish by doing that, maybe we can offer an alternative.

You can add what you want to change in the file /etc/sdboot-manage.conf so that every time the boot loader update, it will add the options accordingly.

1 Like

systemd-boot-manager with this config /etc/sdboot-manage.conf does not work for me, because I am using /boot/efi not /boot or /efi.

Has anybody found a solution to the above problem.
I have esp path at /efi and boot path too at /efi:

➜  ~ bootctl --print-esp-path    
➜  ~ bootctl --print-boot-path

Kernel images are kept at /boot and if i change boot path to /boot it gives me an error:

➜  ~ sudo bootctl --esp-path=/efi --boot-path=/boot install 
Block device node of "/boot" is invalid.

it should be sudo bootctl --esp-path=/efi install

initramfs-5.13-x86_64.img and all other .img files are kept in /boot so I have to externally supply the source of img files by --boot-path=/boot.

I think bootctl can not access /boot as ext4 in the same partition of / or I am wrong.
But you can copy img files into /boot/efi/. But the files are not updated in /boot/efi or there is no automation of update. Or you create new bash-script and write own command to update them.

That is why I switch back to GRUB.

When you use systemd-boot - your EFI parition must be mounted at /boot or /efi but not both and not /boot/efi