Problem when trying to remove lxd

I got the following error when trying to uninstall the installation of lxd. What reasons can make I the directory cannot be removed? (I ran the command below as root).

snap remove --purge lxd
error: cannot perform the following tasks:
- Remove data for snap "lxd" (19389) (remove /var/snap/lxd/common/lxd/storage-pools/default/containers/container-01/rootfs/var/snap/lxd/common/lxd/storage-pools/default/images/ad2e85b656959594883f3a80ff2044ee7475c9806540827c29189caffa7c9285: operation not permitted)

I solved the issue. It was because that directory is a btrfs subvolume. I delete it using btrfs subvolume delete. Then I could remove lxd.

Ah yeah, it’s often a good idea to delete all instances, images and storage pools prior to removal, otherwise snapd can get confused with things it doesn’t know how to delete…