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

"nixos-rebuild build-vm-with-booloader" with systemd-boot is broken again #107255

Closed
bjornfor opened this issue Dec 20, 2020 · 6 comments · Fixed by #107275 or #108504
Closed

"nixos-rebuild build-vm-with-booloader" with systemd-boot is broken again #107255

bjornfor opened this issue Dec 20, 2020 · 6 comments · Fixed by #107275 or #108504
Labels
0.kind: bug Something is broken 0.kind: regression Something that worked before working no longer 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Milestone

Comments

@bjornfor
Copy link
Contributor

bjornfor commented Dec 20, 2020

Describe the bug
nixos-rebuild build-vm-with-booloader on a NixOS configuration with systemd-boot as bootloader (the default for NixOS installs on UEFI systems) fails with this error:

insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
mount: /sys/firmware/efi/efivars: mount point does not exist.

I checked that the efivarfs.ko.xz file exists, so what's missing in the kernel since it reports "No such device"?

Steps to reproduce

$ cat >configuration.nix << EOF
{
  fileSystems."/".device = "/dev/sda1";
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
}
EOF

$ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
building Nix...
building the system configuration...
these derivations will be built:
  /nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv
  /nix/store/7dkqw00frhzfqjzn4w7fnwirldhs48bl-run-nixos-vm.drv
  /nix/store/yaw9kch9adk6xi1qzki98jcricxyz9l8-nixos-vm.drv
building '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' on 'ssh://nix-remote-build@bforsman.name'...
Formatting '/nix/store/1bzy8vqdv2bmib7qi658anc9kf7w7b6f-nixos-boot-disk/disk.img', fmt=qcow2 cluster_size=65536 compression_type=zlib size=62914560 lazy_refcounts=off refcount_bits=16
cSeaBIOS (version rel-1.13.0-48-gd9c812dda519-prebuilt.qemu.org)

iPXE (http://ipxe.org) 00:03.0 CA00 PCI2.10 PnP PMM+1FF8EEF0+1FEEEEF0 CA00

Booting from ROM...
loading kernel modules...isable)... ock
mounting Nix store...
mounting host's temporary directory...
starting stage 2 (/nix/store/rq2ishkgykpx4szwk5w8zcjk1jbp8svx-vm-run-stage2)
Creating new GPT entries in memory.
Setting name!
partNum is 0
Setting name!
partNum is 1
The operation has completed successfully.
mkfs.fat 4.1 (2017-01-24)
insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
mount: /sys/firmware/efi/efivars: mount point does not exist.
[    1.908328] reboot: Power down
builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
error: build of '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' on 'ssh://nix-remote-build@bforsman.name' failed: builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 1
cannot build derivation '/nix/store/7dkqw00frhzfqjzn4w7fnwirldhs48bl-run-nixos-vm.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/yaw9kch9adk6xi1qzki98jcricxyz9l8-nixos-vm.drv': 1 dependencies couldn't be built
error: build of '/nix/store/yaw9kch9adk6xi1qzki98jcricxyz9l8-nixos-vm.drv' failed

This happens with nixos-20.09 and nixos-unstable, but not nixos-20.03. (Just change the nixos-rebuild command above.)

Expected behavior
The build succeeds, like it did before (on nixos-20.03).

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Notify maintainers

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@bjornfor bjornfor added 0.kind: bug Something is broken 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 0.kind: regression Something that worked before working no longer labels Dec 20, 2020
@bjornfor
Copy link
Contributor Author

bjornfor commented Dec 20, 2020

Disabling systemd-boot efi settings from configuration.nix results in

[...]
mkfs.fat 4.1 (2017-01-24)
insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
updating GRUB 2 menu...
[...]

So the insmod error is the same, but now the init script doesn't die on mount: /sys/firmware/efi/efivars: mount point does not exist.

@bjornfor
Copy link
Contributor Author

Ah, the default value of boot.loader.efi.canTouchEfiVariables is false, and with that value it actually succeeds. So it's not really the systemd-boot part of the config that is broken.

@bjornfor
Copy link
Contributor Author

Oh, this comment recommends NOT to set boot.loader.efi.canTouchEfiVariables = true, because it can wear out the NVRAM: NixOS/nixos-hardware#134 (comment)

@bjornfor
Copy link
Contributor Author

Ah, the default value of boot.loader.efi.canTouchEfiVariables is false, [...]

Well, except that nixos-generate-config sets it to true, so it is enabled by default for NixOS EFI installs.

@FRidh FRidh added this to the 21.03 milestone Dec 20, 2020
@bjornfor
Copy link
Contributor Author

bjornfor commented Dec 20, 2020

Interestingly, the nixos systemd-boot test uses virtualisation.useEFIBoot = true. That results in success!

@bjornfor
Copy link
Contributor Author

bjornfor commented Dec 20, 2020

Now the question is, where to set virtualisation.useEFIBoot = true (or mkDefault config.boot.loader.systemd-boot.enable)?

I see at least these places where conditionally adding it could make sense:

bjornfor added a commit to bjornfor/nixpkgs that referenced this issue Dec 21, 2020
`nixos-rebuild build-vm-with-bootloader` currently fails with the
default NixOS EFI configuration:

  $ cat >configuration.nix <<EOF
  {
    fileSystems."/".device = "/dev/sda1";
    boot.loader.systemd-boot.enable = true;
    boot.loader.efi.canTouchEfiVariables = true;
  }
  EOF

  $ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
  [...]
  insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
  mount: /sys/firmware/efi/efivars: mount point does not exist.
  [    1.908328] reboot: Power down
  builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
  [...]

Fix it by setting virtualisation.useEFIBoot = true in qemu-vm.nix, when
efi is needed.

And remove the now unneeded configuration in
./nixos/tests/systemd-boot.nix, since it's handled globally.

Before:
* release-20.03: successful build, unsuccessful run
* release-20.09 (and master): unsuccessful build

After:
* Successful build and run.

Fixes NixOS#107255
bjornfor added a commit to bjornfor/nixpkgs that referenced this issue Dec 21, 2020
`nixos-rebuild build-vm-with-bootloader` currently fails with the
default NixOS EFI configuration:

  $ cat >configuration.nix <<EOF
  {
    fileSystems."/".device = "/dev/sda1";
    boot.loader.systemd-boot.enable = true;
    boot.loader.efi.canTouchEfiVariables = true;
  }
  EOF

  $ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
  [...]
  insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
  mount: /sys/firmware/efi/efivars: mount point does not exist.
  [    1.908328] reboot: Power down
  builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
  [...]

Fix it by setting virtualisation.useEFIBoot = true in qemu-vm.nix, when
efi is needed.

And remove the now unneeded configuration in
./nixos/tests/systemd-boot.nix, since it's handled globally.

Before:
* release-20.03: successful build, unsuccessful run
* release-20.09 (and master): unsuccessful build

After:
* Successful build and run.

Fixes NixOS#107255

(cherry picked from commit 39fad29)
bjornfor added a commit that referenced this issue Dec 21, 2020
`nixos-rebuild build-vm-with-bootloader` currently fails with the
default NixOS EFI configuration:

  $ cat >configuration.nix <<EOF
  {
    fileSystems."/".device = "/dev/sda1";
    boot.loader.systemd-boot.enable = true;
    boot.loader.efi.canTouchEfiVariables = true;
  }
  EOF

  $ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
  [...]
  insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
  mount: /sys/firmware/efi/efivars: mount point does not exist.
  [    1.908328] reboot: Power down
  builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
  [...]

Fix it by setting virtualisation.useEFIBoot = true in qemu-vm.nix, when
efi is needed.

And remove the now unneeded configuration in
./nixos/tests/systemd-boot.nix, since it's handled globally.

Before:
* release-20.03: successful build, unsuccessful run
* release-20.09 (and master): unsuccessful build

After:
* Successful build and run.

Fixes #107255

(cherry picked from commit 39fad29)
@vcunat vcunat reopened this Dec 24, 2020
bjornfor added a commit to bjornfor/nixpkgs that referenced this issue Jan 8, 2021
(The first version of this change, in commit 39fad29, broke
`nix-build -A nixosTests.installer.simpleUefiSystemdBoot`. This is the
2nd version, which hopefully does not break anything.)

`nixos-rebuild build-vm-with-bootloader` currently fails with the
default NixOS EFI configuration:

  $ cat >configuration.nix <<EOF
  {
    fileSystems."/".device = "/dev/sda1";
    boot.loader.systemd-boot.enable = true;
    boot.loader.efi.canTouchEfiVariables = true;
  }
  EOF

  $ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
  [...]
  insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
  mount: /sys/firmware/efi/efivars: mount point does not exist.
  [    1.908328] reboot: Power down
  builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
  [...]

Fix it by setting virtualisation.useEFIBoot = true when needed.

Before:
* release-20.03: successful build, unsuccessful run
* release-20.09 (and master): unsuccessful build

After:
* Successful build and run.

Fixes NixOS#107255
bjornfor added a commit that referenced this issue Jan 8, 2021
(The first version of this change, in commit 39fad29, broke
`nix-build -A nixosTests.installer.simpleUefiSystemdBoot`. This is the
2nd version, which hopefully does not break anything.)

`nixos-rebuild build-vm-with-bootloader` currently fails with the
default NixOS EFI configuration:

  $ cat >configuration.nix <<EOF
  {
    fileSystems."/".device = "/dev/sda1";
    boot.loader.systemd-boot.enable = true;
    boot.loader.efi.canTouchEfiVariables = true;
  }
  EOF

  $ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
  [...]
  insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
  mount: /sys/firmware/efi/efivars: mount point does not exist.
  [    1.908328] reboot: Power down
  builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
  [...]

Fix it by setting virtualisation.useEFIBoot = true when needed.

Before:
* release-20.03: successful build, unsuccessful run
* release-20.09 (and master): unsuccessful build

After:
* Successful build and run.

Fixes #107255
bjornfor added a commit that referenced this issue Jan 10, 2021
(The first version of this change, in commit 39fad29, broke
`nix-build -A nixosTests.installer.simpleUefiSystemdBoot`. This is the
2nd version, which hopefully does not break anything.)

`nixos-rebuild build-vm-with-bootloader` currently fails with the
default NixOS EFI configuration:

  $ cat >configuration.nix <<EOF
  {
    fileSystems."/".device = "/dev/sda1";
    boot.loader.systemd-boot.enable = true;
    boot.loader.efi.canTouchEfiVariables = true;
  }
  EOF

  $ nixos-rebuild build-vm-with-bootloader -I nixos-config=$PWD/configuration.nix -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-20.09.tar.gz
  [...]
  insmod: ERROR: could not insert module /nix/store/1ibmgfr13r8b6xyn4f0wj115819f359c-linux-5.4.83/lib/modules/5.4.83/kernel/fs/efivarfs/efivarfs.ko.xz: No such device
  mount: /sys/firmware/efi/efivars: mount point does not exist.
  [    1.908328] reboot: Power down
  builder for '/nix/store/dx2ycclyknvibrskwmii42sgyalagjxa-nixos-boot-disk.drv' failed with exit code 32
  [...]

Fix it by setting virtualisation.useEFIBoot = true when needed.

Before:
* release-20.03: successful build, unsuccessful run
* release-20.09 (and master): unsuccessful build

After:
* Successful build and run.

Fixes #107255

(cherry picked from commit 72d906a)
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 0.kind: regression Something that worked before working no longer 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Projects
None yet
3 participants