BTRFS space not freed after deleting containers

Hi all,

I recently deleted all the LXD containers using the default BTRFS storage and the space used by the storage did not shring (according to both lxc storage info default and du -h /var/snap/lxd/common/lxd/disks/default.img there was no impact on the used space).

@stgraber explains here LXD deletes the container after the storage space is not released · Issue #5690 · lxc/lxd · GitHub that ZFS pools never shrink. Is it also true for BTRFS pools?

Thanks a lot in advance.

What’s du -sch /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/default getting you?

I believe btrfs is normally mounted with discard which should cause freed blocks to be released through the loop driver causing the underlying file to shrink.

Ah, the pool is a sparse file too, so ls -lh /var/snap/lxd/common/lxd/disks/default.img will show you its allocated (maximum) size but not its used size, for that, run du -h /var/snap/lxd/common/lxd/disks/default.img

I have a similar issue, I just deleted a large container (600GB), however
sudo lxc storage info lxd_storage_pool_01
sudo zfs list
give that there is very little free space. (there should now be >600Gb as of my thinking)
Thank you for your help.