How to deal with grub error during nixos-install --flake

Hello all

Command:

cd /mnt/tmp/myconfig
sudo nixos-install --root /mnt --flake ".#someName"

Error:

copying channel...
installing the boot loader...
setting up /etc...
/etc/tmpfiles.d/journal-nocow.conf:26: Failed to resolve specifier: uninitialized /etc detected, skipping
All rules containing unresolvable specifiers will be skipped.
updating GRUB 2 menu...
Can't exec "/bin/sh": No such file or directory at /nix/store/xxxxxxxxxxxxxx-install-grub.pl line 51.
Failed to execute: /nix/store/yyyyyyyyyyyy-util-linux-2.36.2-bin/bin/blkid -o export /dev/sdb2

this line?

both store paths are available at ‘/mnt/nix/store/{xxxxx|yyy}’

part of configuration:


    fileSystems."/" =
      { device = "rpool/ROOT/nixos";
        fsType = "zfs";
      };

    fileSystems."/boot" =
      { device = "/dev/disk/by-uuid/9111-1111";
        fsType = "vfat";
      };

    fileSystems."/boot1" =
    { device = "/dev/disk/by-uuid/9222-2222";
      fsType = "vfat";
    };

    fileSystems."/nix" =
      { device = "rpool/NIX/nix";
        fsType = "zfs";
      };

    fileSystems."/home" =
      { device = "rpool/HOME/home";
        fsType = "zfs";
      };

    fileSystems."/tmp" =
      { device = "rpool/TMP/tmp";
        fsType = "zfs";
      };

    boot.supportedFilesystems = [ "zfs" ];
    boot.loader = {
      # You can probably use his one on true, but my UEFI is buggy.
      efi.canTouchEfiVariables = false;

      grub = {
        enable = true;
        version = 2;
        copyKernels = true;
        # efiSupport = true;
        # device = "/dev/disk/by-id/ata-CT1000MX500SSD1_191111111111";
        mirroredBoots = [
          {devices = [ "/dev/disk/by-id/ata-CT1000MX500SSD1_191111111111" ]; path = "/boot";}
          {devices = [ "/dev/disk/by-id/ata-CT1000MX500SSD1_192222222222" ]; path = "/boot1";}
        ];
      };
    };

    networking.hostId = "f85e9111";

Context:

I’m new to NixOS, and stuck trying to bootstrap a nixos flake config.
I cloned someones config(without grub) and tried to install it but I get an error.
Could anyone guide me in the right direction to troubleshoot it further.

  • I build my own iso: minimal + flakes + isoImage.contents myconfig + keyMap colemak, tried it with gnome-iso, same error.
  • Partitioned a disk(single & mirror) with grub boot + zfs native encryption.
  • copy the myconfig to /mnt/tmp/myconfig

My partitioning should work, I’m currently running it on a different system without flakes.
I think it has to do with grub, but I ‘need’ grub for the ‘grub.mirroredBoots’.

Should I first install a flake-less nixos and then boot it and switch it to flakes ?

2 Likes

I tried nixos-install from a flake a few months ago, i couldn’t get it to work then. Things might be different now…

This may help you… it’s not exactly your problem, but if i’m reading it right, it maybe related… at least it may get some attention.

flakes are experimental, so if you want to get up and running, it’s certainly acceptable to install your system using a non-flake configuration, and convert it flakes once the system is up and running.

When i get a moment i will try install from a flake again, and see how it rolls.

There’s certainly a lot more collective knowlege on non-flake install then flake ones…but that will change over time…

In theory it should be possible, in practice the tooling might need to be updated :-).

First thing, please everyone remember flakes are (mostly) some nice sugary syntax and tooling for handling/managing imports. At the end, the Nix derivations and build products are the same regardless of whether or not flakes were involved.

In this case, we’re building a nixos system toplevel, and in this case, the toplevel was built successfully.

What the OP has presented is instead an activation error, which usually means that something is mis-matched between the running system and the configured boot loader settings. Or that /boot isn’t mounted. Things of that nature.

In this case, I’m not very sure, but I’d suggest that maybe you’ve instructed grub to install to /dev/sdb2 and that’s maybe not correct to do so.

@Seghers, can you elaborate. What are your boot.loader settings, do you UEFI boot, etc?

1 Like

@colemickens is here, if they can’t make it work, it cannot be done!

The bios is set to legacy boot.

boot.loader:

    boot.loader = {
      # You can probably use his one on true, but my UEFI is buggy.
      efi.canTouchEfiVariables = false;

      grub = {
        enable = true;
        version = 2;
        copyKernels = true;
        # efiSupport = true;
        # device = "/dev/disk/by-id/ata-CT1000MX500SSD1_191111111111";
        mirroredBoots = [
          {devices = [ "/dev/disk/by-id/ata-CT1000MX500SSD1_191111111111" ]; path = "/boot";}
          {devices = [ "/dev/disk/by-id/ata-CT1000MX500SSD1_192222222222" ]; path = "/boot1";}
        ];
      };
    };
Can't exec "/bin/sh": No such file or directory at /nix/store/xxxxxxxxxxxxxx-install-grub.pl line 51.

Hm, I keep coming back to this, /bin/sh even exists on NixOS and presumably the util-linux store path for blkid exists too… Is there an arch mis-match somewhere? Sometimes if you execute an arm64 bnary on amd64 you get an error something similar to that.

When I run blkid, I get a different UUID for /dev/sdb2 than the one in hardware-configuratation.nix.
I run nixos-generate-config before the nixos-install
Similar UUID mismatch for /dev/sdc2

hardware-configuration.nix

   fileSystems."/boot" =
     { device = "/dev/disk/by-uuid/9111-1111";
       fsType = "vfat";
     };

   fileSystems."/boot1" =
   { device = "/dev/disk/by-uuid/9222-2222";
     fsType = "vfat";
   };

blkid output:

/dev/sda1: # thumbdrive; nixos-live
/dev/loop0: # squashfs
/dev/sda2: # thumbdrive; efiboot
/dev/sdb2: UUID="7B3D-5555" Block_size="512" TYPE="vfat" PARTLABEL="Fat32 Partition" PARTUUID="9e8xxxxxxxxxxxxxx"
/dev/sdb4: # zfs
/dev/sdc2: # boot1
/dev/sdc4: # zfs

Odd, seems like that would arise from generating the config and then re-part/re-formatting and getting new UUIDS? Anyway, hardly seems like it can be right if they don’t match. Unlikely to hurt anyway.

sudo blkid made it update the output.
/dev/disk/by-uuid already had the updated names.

blkid showed the uuid’s from a previous install.