As pointed out, Ubuntu 20.04–21.10 uses luks volume on a zfs volume that is a child of rpool to store a 256-bit key which is used to unlock the zfs pool rpool
If you do have the passphrase:
cryptsetup luksChangeKey /dev/zvol/rpool/keystore
Enter passphrase to be changed:
Enter new passphrase:
Verify passphrase:
If you do not have the passphrase:
What you want to do is to store this key protected by a different known passphrase
- If the luks volume is open, this is possible
- If the luks volume is not open, and you do not have a system.key file, it’s game over reinstall
- We cannot change or remove the passphrase, but it is possible to create a new luks container with a known passphrase and store the accessible system.key there
The key can be displayed on a running system:
od --address-radix=x --format=x1 /run/keystore/rpool/system.key
0000000 4a 19 54 d0 b6 ac 38 a7 0d 41 f3 02 c7 05 db 82
0000010 03 18 d5 d5 cb dc 3c e9 71 0e b6 a8 1b 87 25 68
0000020
basically this is what should be done:
zfs create -oencryption=off -V500m rpool/keystore2
cryptsetup luksFormat /dev/zvol/rpool/keystore2
WARNING!
This will overwrite data on /dev/zvol/rpool/keystore2 irrevocably.
Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for /dev/zvol/rpool/keystore2:
Verify passphrase:
cryptsetup open /dev/zvol/rpool/keystore2 k2
Enter passphrase for /dev/zvol/rpool/keystore2:
mkfs --type ext4 /dev/mapper/k2
mkdir --parents --mode=700 /mnt/f/k
mount /dev/mapper/k2 /mnt/f/k
cp --archive --no-clobber /run/keystore/rpool/system.key /mnt/f/k
umount /mnt/f/k
cryptsetup close k2
Reboot from a different installation, like Ubuntu desktop usb media, that has the appropriate zfs command, then something like:
zpool import
pool: rpool
id: 2704475622193776801
# may list some useful ids if you already have an rpool
zpool import 2704475622193776801 rpool2
zfs rename rpool2/keystore rpool2/keystore-nopwd
zfs rename rpool2/keystore2 rpool2/keystore
In charge of things again