Bootctl fails to install after hibernate on system76

See nixos/systemd-boot: bootctl fails to install after hibernate on system76 · Issue #515191 · NixOS/nixpkgs · GitHub

building the system configuration...
Failed to read EFI boot order: Invalid argument
Traceback (most recent call last):
  File "/nix/store/jzs1byj1ss0h3y76n23q1cxggi4rv13w-systemd-boot/bin/systemd-boot", line 452, in <module>
    main()
    ~~~~^^
  File "/nix/store/jzs1byj1ss0h3y76n23q1cxggi4rv13w-systemd-boot/bin/systemd-boot", line 435, in main
    install_bootloader(args)
    ~~~~~~~~~~~~~~~~~~^^^^^^
  File "/nix/store/jzs1byj1ss0h3y76n23q1cxggi4rv13w-systemd-boot/bin/systemd-boot", line 339, in install_bootloader
    installed_out = run(
                    ~~~^
        [f"{SYSTEMD}/bin/bootctl", f"--esp-path={EFI_SYS_MOUNT_POINT}", "status"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        stdout=subprocess.PIPE,
        ^^^^^^^^^^^^^^^^^^^^^^^
    ).stdout
    ^
  File "/nix/store/jzs1byj1ss0h3y76n23q1cxggi4rv13w-systemd-boot/bin/systemd-boot", line 58, in run
    return subprocess.run(cmd, check=True, text=True, stdout=stdout)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/qwb5ygz9k8gs5ql9bpxbrsrv12r1icgm-python3-3.13.12/lib/python3.13/subprocess.py", line 577, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/nix/store/y2rzx7s3kr3v95rsrl2141s8vaa4mkjf-systemd-258.5/bin/bootctl', '--esp-path=/boot', 'status']' returned non-zero exit status 1.
activating the configuration...
reloading user units for brian...
restarting sysinit-reactivation.target
the following new units were started: NetworkManager-dispatcher.service
Done. The new configuration is ⏎                                                                    

It would appear to work despite the error. But if I leave it like that, it looks like important boot files get garbage collected and the system becomes unbootable.

I find it hard to believe that I am the only one having this issue?

Should I replace systemd-boot with grub again? That seemed to be fine. I don’t understand why this would be required though.

That’s nicely weird. Can you run the bootctl command manually and reproduce the error? I’d hope it would emit some useful error messages, but if not strace-ing it might yield some clues.

If it really is failing to read efi vars after suspend, that could end up being a kernel or bios bug :frowning:

I saw this post, which looks similar: Bootctl assertion failed after hibernation

But have updated and retested several times since that was posted, and it hasn’t helped.

At present “sudo bootctl --esp-path /boot status” works fine.

Probably should retest nix deploy sometime, but don’t want to have to reboot the computer again right now, and as above if I don’t reboot the computer and fix I risk having an unbootable system. Will try again tomorrow.

LLM suggested patching nixos/modules/system/boot/loader/systemd-boot/systemd-boot-builder.py; but so far that has not helped, and I have reverted.

Unrelated, the error messages are very different.

Have you tested the exact same bootctl binary? I.e. /nix/store/y2rzx7s3kr3v95rsrl2141s8vaa4mkjf/bin/bootctl, and after you switch into the broken config? An strace really would be helpful, if you can’t reproduce it we’ll have to patch the activation script.

Just to make sure I got this clear, you want me to:

  1. Run nixos-rebuild switch and reproduce the error.
  2. Run “bootctl --esp-path /boot status”, by hand, see if it fails.
  3. If that does fail, run above command via strace.
  4. Reboot onto new broken config.
  5. Take note of the full store path that bootctl comes from.
  6. Run “bootctl --esp-path /boot status”, by hand again.
  7. If that does fail, run above command via strace.

Have I got this correct?

It’s a different error message but it also seems like a very similar failure mode. Looks like probably this error code, which is similar in class to ones we’ve seen before from systemd, which is also similar to the issues linked in the other discourse thread. I think it’s safe to say it’s the same basic category of issue: efivarfs is doing something weird after hibernation and it’s causing bootctl to bug out.

That’s pretty surprising. systemd-boot-builder.py shouldn’t ever cause existing entries to become unbootable, even when there’s a bootctl failure. This part might be a NixOS bug.

Well, if my hypothesis is correct, you are indeed experiencing an unusual behavior of efivarfs, which could be due to a hardware-specific bug that no one else may have dealt with yet.

2 Likes

That’s the idea, but rather than just “by hand” - assuming you can’t reproduce it the first time around - use the full binary path, just in case it’s a bug with a specific version.

@ElvishJerricco is likely correct and this is an efivarfs thing, but it’d be nice to confirm what bootctl is up to when it bugs out. That’d hopefully give more of a clue as to what to do to prevent it bugging out.

1 Like

Tried it today. Computer been through numerous hibernate cycles. This time no dramas.

Tried again with “–install-bootloader” added to the nixos-rebuild, still no issues.

Nor can I get bootctl to complain.

Would like to think it is fixed somewhere. Have thought that before, and been wrong. Maybe this time… Fingers crossed.

For record, based on my notes, when I updated last was:

2026-03-20 bootctl failed; (nixpkgs 2026-03-20)

2026-04-20 bootctl failed; (nixpkgs 2026-04-10)

2026-05-16; bootctl worked (nixpkgs 2026-05-06)

So there might possibly have been something in nixpkgs 2026-04-10 that solved the problem?

Sounds more like a hard/firmware issue, like @ElvishJerricco suggests. Maybe you didn’t fully reboot but hibernate before previous attempts, or you booted into Windows or something.

If you see it again, try to get an strace on it.

I’d also suggest a firmware update, those can sometimes help with this kind of thing.