I got a new SSD and did a fresh Ubuntu 23.04 install. What I usually do, is connecting the old disk via USB and copy data over from the old disk to the new SSD.
But my old disk used encrypted ZFS. It took me some time to figure out how to mount that that so here’s what I did.
The old disk gets detected as
/dev/sda . There are 2 pools,
bpool in my case.
rpool is the one that contains my home directory and also the root directory. Let’s import that pool:
# zpool import -f rpool # zpool list NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT rpool 1.81T 1.29T 536G - - 21% 71% 1.00x ONLINE -
After the pool import, there is now the LUKS encrypted keystore available under
/dev/zvol/rpool/keystore . That keystore does contain the ZFS key for encrypting/decrypting. so let’s
luksOpen that one:
# cryptsetup open /dev/zvol/rpool/keystore rpool-keystore Enter passphrase for /dev/zvol/rpool/keystore: MY_SUPER_SECRET_PASSPHRASE
And now the newly created mapper device for the opened crypt device:
# mount /dev/mapper/rpool-keystore /mnt/ # ls /mnt/ lost+found system.key
system.key is there. Let’s load it so ZFS can use it and clean up:
# cat /mnt/system.key | sudo zfs load-key -L prompt rpool # umount /mnt # cryptsetup close rpool-keystore
zfs list the different datasets can be listed. To mount the
/home/$USERNAME database, find the right one, change the mountpoint and mount it (
/mnt/home-myuser must be created before):
# zfs list|grep home rpool/USERDATA/myuser_xq8e3k 1.22T 478G 986G /home/myuser # zfs set mountpoint=/mnt/home-myuser rpool/USERDATA/myuser_xq8e3k # zfs mount rpool/USERDATA/myuser_xq8e3k ls /mnt/home-myuser # this should show the files from your home now
That’s it. The last steps can be repeated to mount any other ZFS dataset (eg. the one for