Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd-boot-252 loading initrd renders some systems unbootable with "Error preparing initrd: Bad Buffer Size" (suspected broken EFI implementation) #227431

Closed
ethorsoe opened this issue Apr 21, 2023 · 9 comments
Labels
0.kind: bug Something is broken

Comments

@ethorsoe
Copy link

Describe the bug

When selecting any boot entry that has separate initrd entry (not linux parameter initrd) boot fails with
Error preparing initrd: Bad Buffer Size

systemd/systemd#25911

Steps To Reproduce

Steps to reproduce the behavior:

  1. upgrade to nixos-23.05 with boot.loader.systemd-boot.enable on a system with certain kind of EFI.
  2. system is unbootable for all generations, for our case EFI edit command does not work either, maybe related

Expected behavior

System boots

Notify maintainers

@NixOS/systemd

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.24, NixOS, 23.05 (Stoat), 23.05.20230419.645bc49`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.13.3`
 - nixpkgs: `/etc/tuxnix/channels/nixpkgs`

Workaround

boot.loader.systemd-boot.extraInstallCommands = ''
      extraInstallCommands = ''
        for i in /boot/loader/entries/nixos-generation-*.conf; do
          initrd="$(sed -n '/^initrd / {s/.* //;p}' "$i")"
          sed -i '/^initrd / d; /^options / s|$| initrd='"$initrd|" "$i"
        done
      '';
@ethorsoe ethorsoe added the 0.kind: bug Something is broken label Apr 21, 2023
@ethorsoe
Copy link
Author

Broken system details

[    0.000000] efi: EFI v2.80 by American Megatrends
[    0.000000] efi: ACPI=0xa8d99000 ACPI 2.0=0xa8d99014 SMBIOS=0xa9b23000 SMBIOS 3.0=0xa9b22000 MEMATTR=0x9ff25018 ESRT=0xa25d2998 RNG=0xa8913018 INITRD=0x9ff3ec18 
[    0.000000] SMBIOS 3.3.0 present.
[    0.000000] DMI: Supermicro Super Server/H12DSi-N6, BIOS 2.3 10/21/2021

@RaitoBezarius
Copy link
Member

@ElvishJerricco Did we get somewhere regarding that?

@ElvishJerricco
Copy link
Contributor

ElvishJerricco commented May 22, 2023

This is a bug in some firmwares. When an initrd is too big, the file reading APIs provided to the boot loader by the firmware fail in weird ways. The kernel knows to work around this when loading initrds passed on the cmdline by reading the initrd in chunks, but systemd-boot does not implement this workaround when loading large files currently. Until recently, systemd-boot has always passed the initrd to the kernel via the cmdline, but in systemd/systemd#22550 (first released in v253 I believe), they changed it to use LINUX_INITRD_MEDIA, which requires systemd-boot to load the file itself.

The fix is systemd/systemd#25948, which has not been merged upstream, although it appears to be approved. If we want to fix this in NixOS, we can include that patch, but again it's not even merged upstream yet, so I don't know if that's considered acceptable.

Another workaround is to revert the behavior indirectly by putting initrd in the options line of the entry file instead of in an initrd line.

@dawidd6
Copy link
Contributor

dawidd6 commented May 22, 2023

The upstream PR is now merged!

@RaitoBezarius
Copy link
Member

If we can cleanup things before branch-off regarding this, that'd be awesome.

@ElvishJerricco
Copy link
Contributor

Should we wait for a stable backport from upstream, or include the patch in nixpkgs for the time being?

@RaitoBezarius
Copy link
Member

Should we wait for a stable backport from upstream, or include the patch in nixpkgs for the time being?

In all the cases, a systemd rebuild will have to go through staging, so I'd say: we can afford one or two days and do the patch thing for the next staging-23.05.

@RaitoBezarius RaitoBezarius pinned this issue Jun 2, 2023
@alyssais alyssais changed the title >systemd-boot-252 loading initrd renders some systems (suspected broken EFI implementation) unbootable with "Error preparing initrd: Bad Buffer Size" systemd-boot-252 loading initrd renders some systems unbootable with "Error preparing initrd: Bad Buffer Size" (suspected broken EFI implementation) Jun 4, 2023
@arianvp
Copy link
Member

arianvp commented Jun 5, 2023

This fix has landed in staging-23.05. Should be available after the staging cycle

@arianvp
Copy link
Member

arianvp commented Jun 5, 2023

https://nixpk.gs/pr-tracker.html?pr=235770 tracks when it lands. If you still have issues please let me know!

@arianvp arianvp closed this as completed Jun 5, 2023
@RaitoBezarius RaitoBezarius unpinned this issue Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

5 participants