Cannot delete lxc container

Hello,

After doing a copy of a remote container to local: lxc copy hostname:container-name/snapshot local:container-name and i do lxc list i do see that the container was created.

And now I’m trying to delete the container but this is the output error:

Error: Error deleting storage volume: Failed setting subvolume writable “/var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name”: Failed to run: btrfs property set -ts /var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name ro false: ERROR: failed to get flags for /var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name: Invalid argument.

I also do ls -lh /var/snap/lxd/common/lxd/containers/ all my other containers (copy-containers) are there but not the container that i’m trying to delete.

To mentioned that this happened when i interrupted the copying process from the remote host since the btrfs processes were demanding 100% io and causing some issues. And it indeed created something that i can see when i list the containers.

When i try to run again: lxc copy hostname:container-name/snapshot local:container-name the output says:
Error: Failed instance creation: Add instance info to the database: This instance already exists

Thanks in advance for any help!

sudo lxc delete --force ConataineName

Hello @Juan_Esteban_Nichoy,

Thank you for the quick response and after running the command the output is the same:

Error: Error deleting storage volume: Failed setting subvolume writable “/var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name”: Failed to run: btrfs property set -ts /var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name ro false: ERROR: failed to get flags for /var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name: Invalid argument

Does /var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name exist?
If not, does /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name exist?

If either exist, try to delete it and then try lxc delete -f ContainerName again.

Hello @stgraber,

That did the trick! Thanks a lot for your support.

I also encounted Error: Error deleting storage volume: Failed deleting subvolume. lxc delete container failed. The force flag failed too. Deletion succeeded after I removed /var/snap/lxd/common/lxd/storage-pools/my-pool as the superuser.

I suspect allocating the minimum pool size of 1GB is related. I have not confirmed this directly.

I am getting the same issue on one of the containers and on trying to delete the /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name using rm -rf command as a superuser, it gives the following error:

Read-only file system

Is there anything that I am missing here? I am unable to delete the container or its contents.

Please show lxc storage show Pool-1.

And lxc info container-name

Hi @tomp , please find below the output for requested info:

config:
size: 25GB
source: /var/snap/lxd/common/lxd/disks/pool1-vol.img
description: ""
name: pool1-vol
driver: btrfs
used_by:
- /1.0/instances/pool1-instance
status: Created
locations:
- none
Name: pool1-instance
Status: STOPPED
Type: container
Architecture: x86_64
Created: 2021/07/15 00:58 CEST
Last Used: 2021/08/03 12:06 CEST

Its likely that /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name or a directory above it is marked as a BTRFS readonly subvolume.

Try doing:

sudi btrfs property set -ts /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/Pool-1/containers/container-name ro false