Error: Failed initializing storage pool "lxd"

Hello,
since a while my LXD service is not starting. I’m on debian 10 and LXD is installed with snap.

When I try to run it by hand, here is what I get :

sudo /usr/bin/snap run lxd.daemon
=> Preparing the system (21902)
==> Loading snap configuration
==> Setting up mntns symlink (mnt:[4026532582])
==> Setting up kmod wrapper
==> Preparing /boot
==> Preparing a clean copy of /run
==> Preparing /run/bin
==> Preparing a clean copy of /etc
==> Preparing a clean copy of /usr/share/misc
==> Setting up ceph configuration
==> Setting up LVM configuration
==> Setting up OVN configuration
==> Rotating logs
==> Setting up ZFS (0.7)
==> Escaping the systemd cgroups
====> Detected cgroup V1
==> Escaping the systemd process resource limits
==> Disabling shiftfs on this kernel (auto)
==> Detected kernel with partial AppArmor support
=> Re-using existing LXCFS
=> Starting LXD
WARN[12-13|14:05:02] - Couldn’t find the CGroup hugetlb controller, hugepage limits will be ignored
WARN[12-13|14:05:02] - Couldn’t find the CGroup memory swap accounting, swap limits will be ignored
WARN[12-13|14:05:02] Instance type not operational type=virtual-machine driver=qemu err=“vhost_vsock kernel module not loaded: Failed to run: modprobe -b vhost_vsock: modprobe: ERROR: could not insert ‘vhost_vsock’: Device or resource busy”
EROR[12-13|14:05:02] Failed to start the daemon err=“Failed initializing storage pool "lxd": Failed to run: zpool import lxd: cannot import ‘lxd’: no such pool available”
Error: Failed initializing storage pool “lxd”: Failed to run: zpool import lxd: cannot import ‘lxd’: no such pool available

This is the list of my zpools :

sudo zpool list -v
NAME SIZE ALLOC FREE EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
default 46,5G 9,15G 37,3G - 28% 19% 1.00x ONLINE -
/var/snap/lxd/common/lxd/disks/default.img 46,5G 9,15G 37,3G - 28% 19%

The default zpool is the correct one I guess, this is the list of zfs storages (I cropped the list):

zfs list -t all
NAME USED AVAIL REFER MOUNTPOINT
default 9,15G 35,9G 24K none
default/containers 8,23G 35,9G 24K none
default/containers/bacula 3,00G 35,9G 3,13G /var/snap/lxd/common/lxd/storage-pools/default/containers/bacula

Has a migration failed or something similar?
Thank you for your help,
M.

Install sqlite3 and then show:
sqlite "SELECT * FROM storage_pools" /var/snap/lxd/common/lxd/database/global/db.bin
sqlite "SELECT * FROM storage_pools_config" /var/snap/lxd/common/lxd/database/global/db.bin

thank you for your answer.
here it goes :

$ sudo sqlite3 /var/snap/lxd/common/lxd/database/global/db.bin “SELECT * FROM storage_pools;”
4|default|zfs||1
5|lxd|zfs||1

$ sudo sqlite3 /var/snap/lxd/common/lxd/database/global/db.bin “SELECT * FROM storage_pools_config;”
7|4|1|source|/var/snap/lxd/common/lxd/disks/default.img
8|4|1|zfs.pool_name|default
9|4|1|size|50GB
12|5|1|source|lxd/lxd
13|5|1|volatile.initial_source|lxd/lxd
14|5|1|zfs.pool_name|lxd/lxd

Right, so according to LXD you do have two storage pools, default and zfs.

The zfs one which fails to start is configured to use lxd/lxd as its source, so sounds like you had a zfs zpool at some point (not created through LXD itself) with a lxd dataset in it which was used by LXD.

If you know for a fact that nothing actually uses that pool in LXD, then you can put DELETE FROM storage_pools WHERE name='zfs' in /var/snap/lxd/common/lxd/database/patch.global.sql and LXD will delete the pool and anything that depends on it on next startup.

Otherwise, you should figure out what that lxd zpool was and get it back online so LXD can use it.

I guess you mean default and lxd. I’ll try to remove the lxd one.

It worked by removing the lxd zpool from the database and then starting LXD :

$ cat /var/snap/lxd/common/lxd/database/patch.global.sql
DELETE FROM storage_pools WHERE name='lxd'

Thank you very much for your help Stéphane :slight_smile:
Cheers,
M.