Booting UKIs directly – what's the easiest way right now?

So far, I have found two ways to achieve this:

To paint the bigger picture: I am trying to set up a Fedora system without any extra boot stages like GRUB, systemd-boot, shim, or whatever. The firmware should just load a given kernel from the EFI System Partition and let Linux handle the rest: like locating the correct LUKS partition (by a known label), asking for the passphrase (or getting it from the TPM), then mounting one of the btrfs subvolumes found inside, and finally pivoting to it as the /.

Afterwards I will be setting up UEFI Secure Boot with custom keys (but in a less intrusive way, where instead of signing the .efi executables, their hashes are simply added to db directly). Similarly, measured boot using a TPM is not a requirement right now, but the setup needs to be eventually compatible with that. I do not plan on using any boot manager aside from the one built into the firmware, so that feature of uki-direct that puts any newly-installed kernel in BootNext and only adds it to BootOrder once it successfully boots once sounds great.

If anyone else has experience setting up Fedora like that, I’m all ears. If not, I’ll just use this topic to gather my findings. Since I’m taking notes about my setup, once I have it all working I’ll try to write a proper guide.

Here’s what I’m currently unsure of:

  • How much of this is still needed? Do I need any equivalent of virt-firmware or kernel-uki-virt on real hardware? Do I really need to use “Discoverable Partitions”?
  • Does installing uki-direct really take care of all the configuration? (No need to manually set layout=uki in /etc/kernel/install.conf` and whatnot?)
  • This suggests that leftover packages from the normal boot configuration can be removed with rpm -v --nodeps --erase $(rpm- qa | grep "^grub2-\|^os-prober-\|^grubby-"). How would I go about checking if that list is still up to date?
  • Since i’m not converting an existing, working system but modifying one just after installation, how do I go about chrooting into it again if things don’t work out as planned? Is there any equivalent of arch-chroot that will set up all the necessary mounts (like /dev and /proc)?
  • Here it’s said that if Secure Boot is on, systemd-boot drops any command line arguments passed to the kernel. Does that apply to a systemd-boot stub inside a UKI? Shouldn’t the command line be a part of the UKI and thus trusted? Why does uki-direct seem to instead use UEFI variables to store it?

CC: @fotonmoton

It’s on real hardware so I do need the ESP. Ideally I’d want the Fedora-managed kernels to stay contained in $esp/EFI/fedora/ tho, but I guess manually copying a UKI to the fallback location (as bootx64.efi) could be a decent stopgap while I’m trying to get it all to work automatically. Thanks for the idea!

I already have a similar setup working for Arch Linux. It’s not using UKIs, but it’s pretty close overall. Since the kernel and initramfs are by default installed to a predictable location inside /boot, I just have /efi/EFI/archlinux bind-mounted there. Also, while it’s kind-of hacky, the /etc/fstab and /etc/crypttab within the intiramfs tell the kernel where to look for the root filesystem.

Well, installing just uki-direct is not enough. Even after I run dnf reinstall "kernel*" to trigger any relevant DNF hooks, the ESP remains empty. I also tried installing systemd-ukify alongside it, but that didn’t change the result.

Also, I might have found some bugs (or shaky assumptions I guess). First, 99-uki-uefi-setup.install prints “WARNING: ESP not found, exiting”) unless I manually mkdir -p /efi/EFI/BOOT. Next is kernel-bootcfg --print-loader printing “GRUB 2.12”. This isn’t representative of the installed system, but that scripts treats it like that. Finally, why did Anaconda populate /boot/efi with a bunch of GRUB stuff when I explicitly picked the “Do not install the boot loader” option in the GUI? (I was using the Fedora Everything installer.)