Systemd-boot failing to boot a NixOS Warbler system due to an EFI assertion failure

Little update: After removing nouveau from the initrd modules, the initrd image has shrunken down to 29M & I’ve successfully booted using systemd-boot 257.2 without any patches!

This issue is resolved from my perspective now, but I’m willing to further investigate this & hopefully find the exact cause in systemd-boot.

Once again, thanks to both of you for the help!

1 Like

I think I have a very similar issue to OP:

system-boot: Assertion 'BS->AllocatePages(type, memory_type, n_pages, &addr) == EFI_SUCCESS' failed at ../src/boot/efi/util/h:77@malloc_pages, halting.

I’m trying to grasp the procedure of the fix or this patch, but I’m not sure if I understand these directions…

Is there an easier method to solving this problem?

I do have a few NixOS external drives as backup. I could do a live boot into an external drive to fix the drive with the broken boot.

It’s an issue with the size of your initrd being too big for systemd-boot. OP had Nvidia firmware in their initrd which was super big and unnecessary, you probably have something similar you can turn off.

And either way the issue should be fixed in systemd upstream now. So you shouldn’t need it.

But if you insist…

{ pkgs, ... }:

{
  systemd.package = pkgs.systemd.overrideAttrs (prev: {
    patches = (prev.patches or []) ++ [
      ./the-patch.patch
    ];
  });
}

I see. This happened to me on systemd 256.6, and I’m on Kernel 6.14.3, using nixos Stable and vicuna. I use the same configuration.nix file on 8 different drives/laptops, and they’re using 256.8, but this drive is still on 256.6 and I don’t know why…

{ pkgs, ... }:

{
  systemd.package = pkgs.systemd.overrideAttrs (prev: {
    patches = (prev.patches or []) ++ [
      ./the-patch.patch
    ];
  });
}

Would I input this into my configuration.nix file? Or the hardware-configuration.nix file? I’m still able to access the drive via USB live boot.

You should update your channels (if using channels) or flake lock (if using flake). In 24.11 the latest systemd version should be 256.10 already, not 256.8 or 256.6.

Do you still have an older NixOS generations before you encountered this issue? You may still be able to boot into them. If you can boot, the easiest way I’ve found to update systemd-boot is to update my flake/channels, then nixos-rebuild switch.
NixOS should automatically execute bootctl install to update systemd-boot in your ESP/boot partiton, but just in case you may want to run that command manually.

If you can’t boot & need to use a live image, you may be able to mount your ESP/boot partition (under /mnt/boot for example) and use bootctl --esp-path=/mnt/boot install to update systemd-boot that way? This is not something I’ve tried. Make sure your live image has systemd up-to-date if you do this.

Either way, after updating systemd-boot you should hopefully be able to successfully boot your system. You should then consider checking if you got a similar initrd issue as mine (i had a very large initrd because i unneccessairly included nouveau to boot.initrd.kernelModules in my nix configuration. There may be something similar in your case)

Do you still have an older NixOS generations before you encountered this issue? You may still be able to boot into them.

I only have up to three generations back, yet all three generations have 256.6 , so no luck being able to boot into any of the previous generations.

you may be able to mount your ESP/boot partition (under /mnt/boot for example) and use bootctl --esp-path=/mnt/boot install to update systemd-boot that way? This is not something I’ve tried. Make sure your live image has systemd up-to-date if you do this.

Because my Linux drive is external, and a laptop I’m using has a drive of its own, would this be the correct way to mount the boot partition?

fdisk -l

Device       Start        End    Sectors  Size Type
/dev/sdb1     2048    1050623    1048576  512M EFI System
/dev/sdb2  1050624 3907029134 3905978511  1.8T Linux filesystem

/dev/sdb1 is the EFI partition I want to fix.

sudo mount /dev/sdb1 /mnt/boot
sudo bootctl --esp-path=/mnt/boot install

Is this correct? Do I need sudo when I run bootctl?

I’m live booting from another NixOS drive, and that drive has systemd at version 256.10.

UPDATE: When I boot from another Linux Drive, I cannot mount sdb1 to /mnt/boot as mnt doesn’t exist.

When I live boot from a flashdrive with NixOS installer, I only see /mnt but no boot.