Issues with btrfs storage post transfer to new host

Greetings:

I recently moved all my LXD containers to a new host. The old host was running Debian 11 and was using LXD with a btrfs storage pool (the host was also using btrfs as the underlying filesystem). The new host is running Debian 11 also using btrfs as the underlying file system and the new LXD installation using a btrfs storage pool for storage.

I transferred the containers via the rather ham-fisted approach of tar.bz’ing the /var/snap/lxd folder and subfolders on the old host. I then deleted the same /var/snap/lxd folder and subfolders on the new host and replaced them with the same from the old host. Everything spun up wonderfully until I noticed that snapshots were not being taken. I then attempted to copy a container and received the following error:

Error: Create instance from copy: Failed to run: btrfs subvolume snapshot /var/snap/lxd/common/lxd/storage-pools/dauntless/containers/graylog /var/snap/lxd/common/lxd/storage-pools/dauntless/containers/graylog-broken: ERROR: Not a Btrfs subvolume: Invalid argument

I suspect this is because I was rather inelegant in moving containers over to the new host. Any suggestions on how to fix this issue so that I can regain full container functionality (i.e. snapshots, creating copies, and presumably other storage-related features I have not yet discovered to be not working)?

Thank you!

Hi,

You need create new btrfs subvolume. Try this:

lxc stop ${CONTAINER_NAME}
cd /var/snap/lxd/common/lxd/storage-pools/dauntless/containers/
tar --numeric-owner --xattrs --xattrs-include=’’ -cpf ${CONTAINER_NAME}.tar ${CONTAINER_NAME}
mv ${CONTAINER_NAME} ${CONTAINER_NAME}-old
btrfs subvolume create /var/snap/lxd/common/lxd/storage-pools/dauntless/containers/${CONTAINER_NAME}
tar --numeric-owner --xattrs --xattrs-include=’
’ -xpf ${CONTAINER_NAME}.tar