Lxd ignores mount on /var/snap/lxd/common/lxd/storage-pools/default

My btrfs partition looks like this

@/ - the root partition
@lxd/ - the lxd storage pool

hence @lxd is not beneath / - which is important, as I want to be able to restore a snapshot without losing my lxd storage pool. So to use it, I set up /etc/fstab:

$ grep lxd /etc/fstab
/dev/mapper/ubuntu–vg-root /var/snap/lxd/common/lxd/storage-pools/default btrfs defaults,subvol=@lxd 0 2

this used to work fine until a few weeks ago, now lxd ignores that mount, that is, it’s not visible in its namespace, and it instead writes to @/var/snap/lxd/common/lxd/storage-pools/default.

My containers thus stopped working:
$ lxc start debian
Error: Common start logic: saving config file for the container failed
Try lxc info --show-log debian for more info

Did I do this wrong, what can I do to fix this?

The combination of snapd and lxd’s mount namespaces within the snap can make mounting things through /var/snap/lxd pretty tricky.

A likely more reliable solution for you would be to mount your storage pool somewhere on the host /srv/lxd or something similar. Then have the LXD storage pool use that path as its source, effectively leaving it up to LXD to ensure it’s mounted in its namespace rather than hoping that nothing broke mount propagation into the snap.

If you do reshuffle your fstab to do that, you’ll need to perform a tiny bit of database surgery to have LXD know about the new source.

You can look at the existing configuration with:

  • lxd sql global “SELECT * FROM storage_pools_config;”

And can then use something like “UPDATE storage_pools_config SET value=’/srv/lxd’ WHERE key=‘source’;” to update it.

1 Like