LXD import not working

Currently running LXD 3.20 installed via snap. I had a power outage and afterwards I couldn’t get lxd to start. My ZFS pools looked healthy but it seemed like LXD was looking for an old storage pool that was no longer there. After fixing that and rebooting it was now complaining about the database not starting. After a bunch of google searches and troubleshooting I finally uninstalled the LXD snap and reinstalled it. The LXD daemon starts again, but I’m not able to import my containers.

I mounted the zfs location of one of my containers.
zfs mount lxd/containers/unifi

It has a mountpoint of /var/snap/lxd/common/lxd/storage-pools/default/containers/unifi
ls -lh in that directory gives
-r-------- 1 root root 2.7K Feb 2 20:54 backup.yaml
-rw-r–r-- 1 root root 1.1K Jun 27 2019 metadata.yaml
drwxr-xr-x 22 root root 22 Jun 27 2019 rootfs
drwxr-xr-x 2 root root 7 Jun 27 2019 templates

However when I run lxd import unifi I get:
Error: The container's directory "/var/snap/lxd/common/lxd/storage-pools/default/containers/unifi" appears to be empty. Please ensure that the container's storage volume is mounted

My best guess is that this is because the snap version of lxd can’t see my mounted zfs dataset inside its namespace, but from all of my google searching I didn’t seem to come across anyone else having this particular issue.

Any help would be much appreciated.

nsenter -t $(cat /var/snap/lxd/common/lxd.pid) -m will get you in the namespace.

You can then use something like mount -t zfs dataset /var/snap/... to mount it.

Normally mounting from outside the snap is propagated inside the snap but there are some cases where this unfortunately isn’t true.

3 Likes

Thank you, that worked perfectly.

Thanks Stephane! Worked for me too, although it’s weird that it showed mounted in the namespace, still gives the empty message (in the namespace) and so I mounted it (again) and then it did work (lxd import also in namespace) :slight_smile: