BTRFS delete old subvolumes created by lxd

Hi,

I want to delete a couple of subvolumes that lxd made, unfortunately I can’t get to them.
I’ve already deleted all the containers.

e.g:

# btrfs su li -a /
ID 263 gen 78168 top level 5 path <FS_TREE>/var/snap/lxd/common/lxd/storage-pools/default

but:

# ls -l /var/snap/lxd/common/lxd/storage-pools/default
total 0

I think maybe the mountpoint is in an other namespace?!
How to delete them?

Thanks Frank

That last one is the storage pool itself, so you’d need to use lxc storage delete to delete the entire pool.

I deleted the storagepool.
But the subvolumes were not deleted :slight_smile:

# btrfs su li -a /
ID 263 gen 78168 top level 5 path <FS_TREE>/var/snap/lxd/common/lxd/storage-pools/default
...
ID 309 gen 78183 top level 263 path <FS_TREE>/var/snap/lxd/common/lxd/storage-pools/default/containers/samba-ad
ID 310 gen 78183 top level 263 path <FS_TREE>/var/snap/lxd/common/lxd/storage-pools/default/containers/samba-fs
ID 501 gen 78168 top level 263 path <FS_TREE>/var/snap/lxd/common/lxd/storage-pools/default/images/690801402e1d4e02c07ba2d1a29bb9a9b4825f037c12ccad8cb4d062d2450d2c
ID 502 gen 78183 top level 263 path <FS_TREE>/var/snap/lxd/common/lxd/storage-pools/default/images/feb719d316040ef23b5236fc32168a9d6d69c0baeaba30aa46916fc2069b5be6

nsenter --mount=/run/snapd/ns/lxd.mnt /snap/lxd/current/bin/btrfs subvol delete /var/snap/lxd/common/lxd/storage-pools/default/... should work

# nsenter --mount=/run/snapd/ns/lxd.mnt /snap/lxd/current/bin/btrfs subvol delete /var/snap/lxd/common/lxd/storage-pools/default/ ERROR: cannot access subvolume /var/snap/lxd/common/lxd/storage-pools/default/: No such file or directory
# nsenter --mount=/run/snapd/ns/lxd.mnt ls -l /var/snap/lxd/common/lxd/storage-pools/
total 0

Have you any idea? I think i “played” to mouch with btrfs.

Sounds like LXD cleaned up its stuff then, maybe try mounting the btrfs device on /mnt or something to see its content through there?

Yes: # mount /dev/sda4 /mnt -o subvolid=5

I was able to delete every subvolume without:
# btrfs su delete /mnt/var/snap/lxd/common/lxd/storage-pools/default
Delete subvolume (no-commit): '/mnt/var/snap/lxd/common/lxd/storage-pools/default'
ERROR: Could not destroy subvolume/snapshot: Operation not permitted

Any idea?

OK after reboot i was able to delete the last subvolume.

THANKS