How to mount an encrypted Ubuntu 20.10 ZFS file system from an Ubuntu live CD?

I also accidentally changed the keylocation property and I'm not even sure what was the original value. I have found a path like 'file:///run/keystore/rpool/system.key' but that doesn't work because

sudo zfs load-key

fails with 'Failed to open key material file'.


The actual key file was stored in a dedicated zfs volume call keystore, and it was protected by Luks encryption. That's the prompt-up on the boot screen which asks for your password.

If you would like to decrypt and mount the ZFS volumes on another machine, first, open the Luks filesystem to get the key file, for example:

$ sudo cryptsetup open /dev/zvol/rpool/keystore zfskey

It will create a new device under the /dev directory, e.g. /dev/dm-0. You can mount it via the Nautilus file manager easily. Supposedly there is only one file, i.e. system.key.

With that key file you can decrypt your ZFS pool, for example:

$ sudo cat /path/to/system.key | sudo zfs load-key -L prompt rpool

Finally, mount the ZFS volume. You might need to change the mountpoint to somewhere before actually mount the volume. For example:

$ sudo zfs get mountpoint rpool/USERDATA/username_1b23ae
#(Backup the oritional mountpoint value)
$ sudo zfs set mountpoint=/mnt rpool/USERDATA/username_1b23ae
$ sudo zfs mount rpool/USERDATA/username_1b23ae