kexec is broken with lanzaboote #143
Labels
No labels
bug
dependency
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
review-next
security
stub
tool
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: raito/lanzaboote#143
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I am trying to reboot via kexec my computer using
systemdctl kexec
. This used to work just fine with normal nixos, but I am trying out lanzaboote (very cool btw :)) and it is not working at all anymore.I now get this error.
Is there something I can do to fix this, or is kexec just something that is broken right now?
Can you show the command line that used to work for you before?
I'm pretty sure kexec doesn't support UEFI binaries. You need to specify the kernel directly for
--load
. It's one of thebzImage
files inEFI/nixos
.It looks like you are right about the UEFI binaries, when I disable lanzaboote, it runs load with one of those bzImage files and it works well.
So it seems like when lanzaboote is enabled it tries to load a UEFI binary for some reason.
Looked into it and it seems like kexec has yet to add support for Unified Kernel Images1. As lanzaboote only emits UKI's onto your ESP that one won't work, as a workaround try to use the kernel and init path provided by
/nix/var/nix/profiles/system/boot.json
or the other systems/generations.https://www.spinics.net/lists/kexec/msg30939.html ↩︎
I ran into this same problem a few weeks ago. If no kernel is manually loaded for kexec, systemd will try to load the one in the default boot loader entry. Run
bootctl status | grep linux:
, and it will show which kernel systemd will try to kexec into.The solution seems to be to enable/run the
prepare-kexec.service
service, which will run a NixOS provided script to correctly setup kexec.It looks like systemd can either parse the systemd-boot conf to determine the linux kernel to kexec or it just looks in
$esp/EFI/Linux
, which is where it is getting the lanzaboote image fromI did look into the systemd source code though and noticed there is a functionality to allow other bootloaders to specify this sort of information:
https://github.com/systemd/systemd/blob/v253/src/shared/bootspec.c#L1154-L1159
So we could just synthesize a
/run/boot-loader-entries
with fake systemd-boot config for the correct kernels/initrds and thensystemctl kexec
would also work as expectedThis service is already enabled, but for some reason it doesn't get run automatically.
I meant enable as in run on startup, like the
systemctl enable
command, so on NixOS you would setsystemd.services."prepare-kexec".wantedBy = [ "multi-user.target" ];
I added to my configuration and the problems are fixed!
This seems like something that should be sent to NixOS upstream by pinging the @NixOS/systemd team.
If someone can retest kexec on master, let me know. I will try to write test for it before.