Added usb key to unlock drive

This commit is contained in:
Samy Avrillon 2025-08-15 15:07:35 +02:00
parent 0ee21f2e5d
commit 0b5ca6c6be
3 changed files with 21 additions and 3 deletions

View File

@ -21,9 +21,17 @@
"usb_storage" "usb_storage"
"sd_mod" "sd_mod"
]; ];
boot.initrd.kernelModules = [ "dm-snapshot" ]; boot.initrd.kernelModules = [ "dm-snapshot" "uas" "usbcore" "usb_storage" "ext4" "nls_cp437" "nls_iso8859_1"];
boot.initrd.luks.devices.cryptroot.device = boot.initrd.postDeviceCommands = pkgs.lib.mkBefore ''
"/dev/disk/by-uuid/c75f2769-d32f-4eed-9237-ece7e783fec3"; mkdir -m 0755 -p /key/
sleep 2
mount -n -t ext4 -o ro `findfs UUID=545bfd15-0973-4395-9d05-6c4c78a9e45c` /run/secrets/
'';
boot.initrd.luks.devices.cryptroot = {
device = "/dev/disk/by-uuid/c75f2769-d32f-4eed-9237-ece7e783fec3";
keyFile = "/run/secrets/polysaa-drive.key";
preLVM = false;
};
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;

View File

@ -9,6 +9,7 @@
}: }:
{ {
imports = [ imports = [
./secrets.nix
./locale.nix ./locale.nix
./ssh.nix ./ssh.nix
]; ];

View File

@ -0,0 +1,9 @@
{config, lib, pkgs, ...}: {
fileSystems."/run/secrets" = {
device = "/dev/disk/by-uuid/545bfd15-0973-4395-9d05-6c4c78a9e45c";
fsType = "ext4";
options = ["nofail" "noauto" "ro" "x-systemd.automount"];
};
}