LXD storage pool dissapear

lxd --version
2.21

I try to install v3.0 from snap and migrate
=> Updating the storage backends
error: Failed to update the storage pools: Failed to run: zfs list -H -t all -o name,mountpoint -r : cannot open ‘’: invalid dataset name
I remove snap and reboot server after that service lxd failed with error
Error creating database: failed to begin transaction: unable to open database file
I copy lxd.db.bak to lxd.db and try to start lxd service
Failed to set new ZFS mountpoint: cannot open 'lxd/containers/container name': dataset does not exist

zpool list
no pools available

When i try to start lxd
lvl=warn msg=“Incorrectly applied “storage_api” patch. Skipping storage pool initialization as it might be corrupt.” t=2018-04-23T22:16:08+0200
lvl=warn msg=“Database already contains a valid entry for the storage pool: lxd.” t=2018-04-23T22:16:08+0200
lvl=warn msg=“Storage volumes database already contains an entry for the container.” t=2018-04-23T22:16:08+0200
lvl=warn msg=“Failed to set new ZFS mountpoint: cannot open ‘lxd/containers/communal-stud’: dataset does not exist\n.” t=2018-04-23T22:16:08+0200

So to try to get this right, you did:

  • Existing LXD 2.21 install as deb
  • Installed the snap
  • Ran lxd.migrate, got an error after most of the migration ran
  • Removed the snap

If that’s the case, then you most likely lost all the LXD data when you removed the snap…
We could have pretty trivially made you recover from the lxd.migrate failure and gotten you onto the snap, but removing the snap made it wipe /var/snap/lxd/common/lxd where all your data was.

Can you paste find /var/lib/lxd/ to see what’s left there?
The zpool error most likely comes from the fact that you used a loop-based ZFS disk, which would have been stored in /var/lib/lxd/disks/ but is most likely gone now…

ll /var/lib/lxd/disks/
total 187663048
drwx------ 2 root root 4096 Jul 23 2017 ./
drwxr-xr-x 13 root root 4096 Apr 23 23:56 …/
-rw------- 1 root root 193273528320 Apr 23 17:26 lxd.img
resul of find http://paste.ubuntu.com/p/Gh95pd7MM2/

i try to import zfs.img (zpool import -d /var/lib/lxd/disks/ -a)
root@lxd1:~# zpool list
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
lxd 179G 59.3G 120G - 56% 33% 1.00x ONLINE -
and lxd service failed with errors
lvl=warn msg=“Incorrectly applied “storage_api” patch. Skipping storage pool initialization as it might be corrupt.” t=2018-04-24T00:20:58+0200
lvl=warn msg=“Database already contains a valid entry for the storage pool: lxd.” t=2018-04-24T00:20:58+0200
lvl=warn msg=“Storage volumes database already contains an entry for the container.” t=2018-04-24T00:20:58+0200
lvl=warn msg=“Failed to set new ZFS mountpoint: cannot open ‘lxd/containers/communal-stud’: dataset does not exist\n.” t=2018-04-24T00:20:58+0200
lvl=warn msg=“Storage volumes database already contains an entry for the container.” t=2018-04-24T00:20:58+0200
Maybe i need to change something in database?
root@lxd1:~# sqlite3 /var/lib/lxd/lxd.db 'SELECT * FROM storage_pools;'
1|lxd|zfs|
root@lxd1:~# sqlite3 /var/lib/lxd/lxd.db 'SELECT * FROM storage_pools_config;'
69|1|size|35GB
70|1|source|lxd

What does zfs list -t all show you?

And to see what LXD expects:

  • sqlite3 /var/lib/lxd/lxd.db SELECT * FROM storage_volumes;

http://paste.ubuntu.com/p/KJSt4gvHNn/

1|communal-stud|1|0|
2|guided-ladybird|1|0|
3|organic-earwig|1|0|
4|pleased-dingo|1|0|
5|94c5b2293c540683421c41ae2090e4248df0d90021fb6e15f6f33264cbdba624|1|1|

I cleaned the database of these containers, delete these from containers and storage-poos/lxd/containers dirrs and start lxd. after that i mount all lxd containers partitions and lxd import. And all works)