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: unstable fails to load luks encrypted btrfs drive #303246

Open
ozwaldorf opened this issue Apr 10, 2024 · 4 comments
Open

nixos: unstable fails to load luks encrypted btrfs drive #303246

ozwaldorf opened this issue Apr 10, 2024 · 4 comments

Comments

@ozwaldorf
Copy link

ozwaldorf commented Apr 10, 2024

Summary

After upgrading a fresh nixos install to nixos-unstable from a flake, systemd init fails to detect the btrfs partition after luks decryption

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install nixos via the latest stable installer
  2. Encrypt disk with LUKS, use btrfs for the main partition
  3. Reboot
  4. nixos-rebuild a flake that uses unstable nixpkgs, along with the newly autogenerated hardware configuration (for example, my flake)
  5. Reboot
  6. System will timeout and fail at stage 1 due to the decrypted partition not being detected

Expected behavior

The btrfs drive should be detected

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

I was able to get a working setup using ext4 as an alternative


Add a 👍 reaction to issues you find important.

@betalars
Copy link

betalars commented Apr 12, 2024

I think sharing your hardware configuration file may help here.

I am running the same setup (unstable packages and btrfs in a luks container) with no issues.

My hardware-config:

{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ "dm-snapshot" ];
  boot.kernelModules = [ "kvm-amd" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/mapper/vg--nix-root";
      fsType = "btrfs";
      options = [ "subvol=root" ];
    };

  fileSystems."/home" =
    { device = "/dev/mapper/vg--nix-root";
      fsType = "btrfs";
      options = [ "subvol=home" ];
    };

  fileSystems."/nix" =
    { device = "/dev/mapper/vg--nix-root";
      fsType = "btrfs";
      options = [ "subvol=nix" ];
    };

  fileSystems."/boot" =
    { device = "/dev/nvme0n1p1";
      fsType = "vfat";
    };


  fileSystems."/home/betalars/Data" =
    { device = "/dev/disk/by-uuid/dd7b79f0-12be-405a-aa0e-8e48362ed4f2";
      fsType = "ext4";
    };

  swapDevices =
    [ { device = "/dev/mapper/vg--nix-swap"; }
    ];

  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
  # (the default) this is the recommended approach. When using systemd-networkd it's
  # still possible to use this option, but it's recommended to use it in conjunction
  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
  networking.useDHCP = lib.mkDefault true;
  # networking.interfaces.enp41s0.useDHCP = lib.mkDefault true;

  hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

And I also have this line in my configuration.nix:
boot.initrd.luks.devices."lucks-container".device = "/dev/nvme0n1p2";

@betalars
Copy link

Also the second thing: it is reccomended to use a git repository to keep track of the changes you make to your nix configuration.

Is there maybe something else that has changed in your configuration except for the unstable packages? I really do not see how they would influence the ability to boot your system.

@ozwaldorf
Copy link
Author

ozwaldorf commented Apr 12, 2024

Check out my flake already linked in the issue description @betalars, the only difference from what's there is I had the btrfs root partition mounted to root instead of the current ext4 partition in system/hardware-configuration.nix

I tried both /dev/by-id (nixos default) and /dev/by-label in the hardware config, for the btrfs drive, both failed to come online on unstable but would on stable. Afaik it's preferable to use by id or label to avoid any possible issues with how the kernel mounts the drives (and why nixos has it as the default in the generated hardware config)

Side note: Could this be related to stateVersion? Started with 23.11, but upgraded to 24.05? Seems weird that this would only affect btrfs and not ext4 though

@betalars
Copy link

Sorry, I did not make the connection that your flake would also include the hardware config.

at this point i unfortunately have to say it works for me and I am in way over my head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants