Hi all.
I’ve been looking for a while now, but seem unable to find a way to achieve what I’m looking to do.
i’m looking to unlock luks devices, where one luks device is the root filesystem, and has the keyfile for unlocking the remaining drives.
On Debian this was something I was able to achieve by creating a /etc/crypttab
file, and it would manage the dependencies correctly.
My block devices look like this:
NAME FSTYPE MOUNTPOINT
sda
└─sda1 crypto_LUKS
└─data_disk1_crypt xfs /data/data_disk1
sdb
├─sdb1 vfat /boot/efi
├─sdb2 ext2
├─sdb3 crypto_LUKS
│ └─root LVM2_member
│ ├─nexus--vg-root ext4 /data/debian_root
│ ├─nexus--vg-swap_1 swap [SWAP]
│ └─nexus--vg-nixos_root ext4 /
└─sdb4 ext4 /boot
sdd
└─sdd1 crypto_LUKS
└─data_disk2_crypt xfs /data/data_disk2
sde
└─sde1 crypto_LUKS
└─data_disk3_crypt xfs /data/data_disk3
sdf
└─sdf1 crypto_LUKS
└─parity_disk1_crypt xfs /data/parity_disk
nixos-generate-config
generated a hardware-configuration.nix
which contains
filesystems."/data/data_disk1" = {
device = "/dev/disk/by-uuid/eea269a4-81fb-49cd-883d-44d4070cba00";
fstype = "xfs";
};
boot.initrd.luks.devices."data_disk1_crypt".device =
"/dev/disk/by-uuid/2b7c47cb-a425-4493-8d7d-4227537a40d5";
I attempted to add the keyfile by extending this in my own configuration:
boot.initrd.luks.devices."data_disk1_crypt" = {
device = "/dev/disk/by-uuid/2b7c47cb-a425-4493-8d7d-4227537a40d5";
preLVM = true;
keyFile = "/root/keyfile";
};
But this caused my machine to be unable to boot, since it was unable to locate the keyFile
.
I found this post which seems to be asking the same thing, and the answer was to set preLVM
to false. This doesn’t seem to fix this for me, I attempted this change, and after providing my passphrase for on a reboot saw this error (hand transcribed here, so forgive typos, I can’t copy-paste over IPMI):
Verifying passphrase for /dev/disk/by-uuid/2644f599-e320-4c60-bc1a-bc0d4cba7d46... - success
starting device mapper and LVM...
3 logical volume(s) in volume group "nexus-vg" now active
Waiting 10 seconds for key file /root/keyfile to appear............. - failure
/root/keyfile is unavilable
What is the recommended way forward? Is there a way to achieve what I’m doing easily via the configuration options available? My other idea is to define these mounts via systemd units, and see if I can figure out how to define systemd units to unlocks the luks drives.
- Is that a reasonable approach?
- Will I need to patch future
hardware-configuration.nix
files sincenixos-generate-config
will keep generating entries for these filesystems when I rerun it?
Thank you for your time!