Unable to remove container after launch fails

While trying to launch a new container, the download of rootfs failed due to Konsole crash. After that the container name appears in the listing but that of image doesn’t. I can’t delete container either.

Error: Error deleting storage volume: Failed to run: btrfs subvolume delete /var/snap/lxd/common/lxd/storage-pools/default/containers/u1: ERROR: not a subvolume: /var/snap/lxd/common/lxd/storage-pools/default/containers/u1

FWIW, host is ubuntu 20.04 and LXD was installed using snap (latest).
Can someone please help?
Thanks in advance.

Try:

nsenter --mount=/run/snapd/ns/lxd.mnt -- /snap/lxd/current/bin/btrfs subvol create /var/snap/lxd/common/lxd/storage-pools/default/containers/u1

This should create the thing that lxc delete wants to get rid of.

When I try to create subvol, I get ‘ERROR: target path already exists:’. Then when I try to either delete container u1 or subvol, I get 'ERROR: not a subvolume: ’

I can try to purge and reinstall lxd, and it may solve the issue. But I am new to LXD and am keen to learn internals.
Thanks.

Ok, so it means the path exists but not as a subvol. Can you try:

nsenter --mount=/run/snapd/ns/lxd.mnt -- rm -Rf /var/snap/lxd/common/lxd/storage-pools/default/containers/u1
nsenter --mount=/run/snapd/ns/lxd.mnt -- /snap/lxd/current/bin/btrfs subvol create /var/snap/lxd/common/lxd/storage-pools/default/containers/u1
1 Like

Thanks. Worked.