Nixos zfs encrypted boot installation

675 Views Asked by At

I've followed several guides[1,2,3] but cannot get this working. Grub does not prompt me for my password to unlock the disk, and instead I am greeted with this prompt:

error: no such device: 397411472d225490.
error: unknown filesystem.
Entering rescue mode...
grub rescue>

These are my configuration file:

/etc/nixos/configuration.nix:

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  boot.supportedFilesystems = [ "zfs" ];

  boot.initrd.luks.devices."nixos-root" = {
    device = "/dev/disk/by-uuid/f7b6b840-d3c3-4906-ae32-e33b43dd9c76";
    keyFile = "/root/root.key";
    allowDiscards = true;
  };

  boot.loader = {
    efi = {
      efiSysMountPoint = "/efi";
      canTouchEfiVariables = true;
    };

    grub = {
      enable = true; 
      device = "nodev";
      version = 2;
      efiSupport = true;
      enableCryptodisk = true;
      extraInitrd = "/boot/initrd.keys.gz";
      zfsSupport = true;
    };

  };

  networking.hostName = "lostpuppy";
  networking.hostId = "0261fc86";

...
}

/etc/nixos/hardware-configuration.nix:

{ config, lib, pkgs, ... }:

{
  imports =
    [ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "rtsx_usb_sdmmc" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "zroot/root/nixos";
      fsType = "zfs";
    };

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

  fileSystems."/efi" =
    { device = "/dev/disk/by-uuid/E7FC-1575";
      fsType = "vfat";
    };

  nix.maxJobs = lib.mkDefault 8;
  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
}

I hope someone can help me!

[1] https://zyradyl.moe/2019/08/04/NixOS-Part1-Basic-Setup/ (currently offline)

[2] https://elvishjerricco.github.io/2018/12/06/encrypted-boot-on-zfs-with-nixos.html

[3] https://gist.github.com/ladinu/bfebdd90a5afd45dec811296016b2a3f

0

There are 0 best solutions below