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>
I have two disks, first has /boot for EFI, and zroot zpool for / and /tmp, second has zhome zpool for /home.
Both zpools are encrypted, with zroot prompting for passphrase on boot, and zhome using key file stored on /.
It took a few tries to get it working, especially as the generated hardware-configuration.nix had entries for /zroot and /zhome mounts that seem to throw errors. Had to comment them out.
Grub’s enableCryptodisk doesn’t work with LUKS2, unfortunately. Only LUKS1.
@ianmjones I’m assuming your /boot isn’t encrypted? Pretty sure neither grub nor systemd-boot support reading encrypted ZFS datasets to find the kernel and initrd.
On my installation /boot is supposed to be encrypted, and lives on the root partition, if I understand correctly. Is there a way to know if I am using LUKS1 or LUKS2? Thanks.
UPDATE: This does not work with LUKS 2, because Grub does not support reading from it. At least on NixOS, LUKS 2 is now the default. I have not updated this post to show how to force it to use LUKS 1, and I’m not sure that’s a good idea anyway. I’m moving my system back to a normal /boot because of this and because Grub takes absolutely forever to decrypt the disk. Grub also has issues with new ZFS feature flags on occasion, and I’m not willing to take that risk.
So I guess I am doomed? Do I need to start all over from scratch, or is there an easy way to change to a normal /boot at this point?
If that /efi partition is big enough, you could repurpose it as a /boot partition and have the efi directory be on that partition at /boot/efi. Dunno if you could just downgrade to LUKS1, or what the risks of that would be.
200M is common, but 512M is definitely better. People who keep lots of old NixOS generations around tend to fill up 200M with a bunch of excess kernels and stuff.
I wish I’d taken notes of how I finally got it working, it was while ago now!
I believe that the following statement in the wiki article was key to my success…
Note that at the moment one can only use passphrases ( keylocation=prompt ) for pools that are mounted as the root fs.
So Ideally when you create the second encrypted zhome pool with zpool, you should specify keylocation as a file that is created at the root of the zroot pool that does use the passphrase prompt on boot.
If I remember correctly, I did it wrong at first, using keylocation=prompt, but later fixed it because zroot was ok, I just got messages that zhome couldn’t be mounted. I then created my /zhome.key file, manually mounted the zhome pool and used zfs change-key ... to fix it up, once I’d read that above phrase a million times!
So, maybe something like this is better after creating and mounting zroot on /mnt and creating the key file?
My zhome.key file in / (a.k.a. /mnt/zhome.key during setup), is just a plain file that simply contains the passphrase (password) that I was asked for when I initially screwed things up.