So far, I have found two ways to achieve this:
- Just have Dracut generate the UKIs. Then copy them to the ESP and register them with the UEFI Boot Manager using a custom script. This is what @anthonywbarone describes here.
- Let
kernel-installhandle all of this. The main piece seems to be theuki-directpackage, as described in F40 Change Proposal: Unified Kernel Support Phase 2 (System-Wide) over two years ago, with some updates a year later. Thank you @kraxel for working on this infrastructure btw!
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-firmwareorkernel-uki-virton real hardware? Do I really need to use “Discoverable Partitions”? - Does installing
uki-directreally take care of all the configuration? (No need to manually setlayout=ukiin /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 ofarch-chrootthat will set up all the necessary mounts (like/devand/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-directseem to instead use UEFI variables to store it?
CC: @fotonmoton