For anyone who encounters the same situation, here is my successful solution. I needed a few days to find out the right steps and their ordering, fighting various error messages.
Recovery containers from a damaged drive, assuming you managed to backup/dump the zfs partition on a second HDD that is now in a new machine with Ubuntu 20.04, goes as follows:
sudo snap install lxd && sudo apt install zfsutils-linux
installs the necessary stuffsudo adduser $(whoami) lxd && newgrp lxd
adds you to the lxd group granting you permissions to manage LXDsudo zpool import
prints a list of available volumes to import, remember a long number at the top, e.g. 1234567890123456789sudo zpool import -d /dev -f -R / 1234567890123456789 default
imports the volume, note that long number copied from the listing in the previous step
– if you just want to read the files, you can also add-o readonly=on
but that will not allow you to import any container
– i chose-R /
since the mountpoints for all containers were already correctly specified as/var/snap/lxd/common/lxd/storage-pools/default/containers/container_name
(afterzpool import
just check byzfs list
otherwise export and import again with a new path (or just reboot)
– the last argument is the pool name, use the same as you had on the old machine- Maybe you need to call
lxc info
once, not sure but it will do no harm anyway. - create any profiles you used in the old setup, e.g. X11
sudo zfs mount default/containers/container_name
sudo lxd import --force container_name
sudo zfs unmount default/containers/container_name
- repeat 7. - 9. for all containers you need to recover
lxc list
should now show all recovered containers, note that after starting their IP address will not be assigned. Now you may either export
the containers, re-install lxd (now finally calling lxd init
as well) and import the images again or you may follow the suggestions over here to initialize network and storage manually:
Fingers crossed for your recovery!