Hi Martin-Éric, hi Lionel, thanks to both of you.
Martin-Éric: so on your system the entry is created (amd64, ESP on /boot/efi). Does "Memtest86+" show up in the systemd-boot menu, and does it start correctly?
Lionel: thanks for the pointer to the .osrel section.I don't really like the current approach, where the postinst generates the entry and copies the image, but I don't want to replace it with something fragile either, and whatever is used should handle the various setups (ESP on /efi, /boot or /boot/efi, XBOOTLDR, the different architectures, systemd-boot installed after memtest86+).
So I did some more research and tests, again with the help of an LLM, to look for alternatives. So far I haven't found anything that looks optimal to me, and I'm afraid some compromise will be needed somewhere. This is what I found.
Copying the image can't be avoided, since systemd-boot only loads entries and images from the ESP or the XBOOTLDR partition; what can be avoided is generating the entry.
I also had it look for similar packages in Debian (sid), to see whether and how they deal with this, and memtest86+ seems to be the only package, apart from the boot loaders themselves (systemd-boot, shim-signed, refind), that writes to the ESP for systemd-boot from its maintainer scripts. The EFI tools similar to memtest86+:
- efi-shell-x64 (and the other efi-shell-*), ipxe, efibootguard: they only ship the .efi file (in /usr/share/efi-shell-x64/, /usr/lib/ipxe/ and so on), with no maintainer scripts, so copying it to the ESP is left to the user. For the shell, systemd-boot adds an entry by itself, but only if it finds \shellx64.efi in the root of the ESP; - xen-hypervisor: the postinst only runs update-grub, nothing for systemd-boot;
- fwupd: its maintainer scripts don't touch the ESP;- grml-rescueboot: postinst and postrm only run update-grub, the GRUB entries come from /etc/grub.d/42_grml. The EFI part is in update-grml-rescueboot, run by the user, which builds $ESP/EFI/tools/grml.efi with ukify (meant to be started from the UEFI shell, not from the systemd-boot menu), finding the ESP with `bootctl --print-esp-path` and falling back to /efi, /boot and /boot/efi.
With the .osrel section the image could be copied to $BOOT/EFI/Linux/ as a Type #2 entry, with no generated .conf at all. I checked it against systemd 262.2 (current sid), building memtest86+ 9.00 for x86_64 and running bootctl on a test directory used as ESP (I haven't tried an actual boot yet):
- systemd-boot itself only requires .osrel for Type #2 entries (src/boot/boot.c), so the entry should show up as "Memtest86+ v9.00", both on the ESP and on XBOOTLDR; - bootctl instead requires both .osrel and .linux (pe_is_uki() in src/shared/pe-binary.c), so `bootctl list` and `bootctl status` print "Parsed PE file '.../EFI/Linux/memtest86+x64.efi' is not a UKI." 256 times, once per possible profile; - `bootctl link` (new in 261), which would copy the image and write the entry by itself, refuses anything that is not a UKI; - Type #2 entries are sorted by the os-release ID, so "memtest86plus" is compared with the distribution ID used by the kernel entries: if loader.conf has no default, on a system with ID=ubuntu memtest would come first and become the default entry. On Debian, bootctl install usually writes "default <machine-id>-*", so it shouldn't happen there.
For the rest, `bootctl --print-boot-path` gives XBOOTLDR if present and the ESP otherwise (systemd-boot's own postinst and update-grml-rescueboot use `bootctl --print-esp-path`), and the image to copy could be chosen from the systemd-boot binary actually installed in EFI/systemd/ (x64, ia32, aa64, loongarch64), instead of hardcoding paths and architectures.
So the Type #2 entry looks like the right direction, but with the current bootctl it comes with those error messages, which is part of the compromise I mentioned; I think the bootctl part should be raised with systemd upstream: either bootctl accepting EFI images with only .osrel, as systemd-boot already does, or `bootctl link` accepting plain EFI applications. Until something is decided the current mechanism stays.
Anyway, this is not an in-depth analysis yet, only an initial one, mostly to see some of the possibilities; I'd also like to hear what the other maintainer and other people think about it before deciding anything.
Lionel, do you know if this was already discussed with the systemd developers, or if anyone tested the .osrel section with systemd-boot in the meantime?
Bye, Fabio
OpenPGP_signature.asc
Description: OpenPGP digital signature

