Try to recreate deleted container storage already exists

I think the following shows my lxc container pool has been disturbed by a garbage collect of zsyctl - or perhaps a restore. Unfortunately they share rpool

I would like to move lxc storage to a new zfs dataset. Can someone help me with the commands and lxd init process please.

There is only one container I’d like to preserve. Is there way of exporting it , and importing to new storage? I have a work-around if necessary


lxc launch ubuntu:20.04 --profile default --profile nvidia-cuda $c1
Creating julia-cuda
Error: Failed instance creation: Failed creating instance from image: Failed to run: zfs clone rpool/lxd/images/cea91a28441af36f088f3ae8b637499061518ea2d83c7560a2f7f33d74298968@readonly rpool/lxd/containers/julia-cuda: cannot create 'rpool/lxd/containers/julia-cuda': dataset already exists
› : ~/development/lxc/lxc-x11
[1] % lxc delete -f $c1                                                  
Remove julia-cuda (yes/no): yes
Error: not found

Can you show zfs list -t all?

its a big list so I restricted to rpool

zfs list -t all rpool
rpool   156G  64.6G       96K  /

zfs list -t all | grep julia-cuda

I think I may have crowded zsyctl with containers, and system state storage when wrestling with nvidia and CUDA drivers

~# zfs list -t all | grep julia-cuda
rpool/lxd/containers/julia-cuda                                                                                 10.7G  64.6G     11.1G  /var/snap/lxd/common/lxd/storage-pools/default/containers/julia-cuda
rpool/lxd/containers/julia-cuda@snapshot-base                                                                   26.3M      -      808M  -
rpool/lxd/containers/julia-cuda@snapshot-base2                                                                  1.59M      -      913M  -
rpool/lxd/containers/julia-cuda@snapshot-julia                                                                  1.76M      -     1.08G  -
rpool/lxd/containers/julia-cuda@snapshot-CUDA-build-pre                                                         27.2M      -     1.28G  -
rpool/lxd/containers/julia-cuda@snapshot-CUDA-deb-network-installer                                             50.9M      -     1.30G  -
rpool/lxd/containers/julia-cuda@snapshot-CUDA-toolkit-installed                                                 1.47M      -     7.79G  -
rpool/lxd/containers/julia-cuda@snapshot-CUDA-toolkit-installed-stopped-container                               1.62M      -     7.79G  -
rpool/lxd/containers/julia-cuda@snapshot-CUDA-versioninfo-working-julia                                         26.7M      -     10.0G  -
rpool/lxd/containers/julia-cuda@snapshot-CUDA-julia-working                                                      148K      -     11.1G  -

Ok, so the container doesn’t seem to exist inside of LXD’s database but still exists on disk. If you just want it gone to be recreated, you’ll need to zfs destroy -R rpool/lxd/containers/julia-cuda

If you instead want to recover that container and have it show up in LXD, then you’ll need to do something like nsenter --mount=/run/snapd/ns/lxd.mnt mount -t zfs rpool/lxd/containers/julia-cuda /var/snap/lxd/common/lxd/storage-pools/default/containers/julia-cuda followed by lxd import julia-cuda

Hi Stephane,
I’m happy to delete the container’s dataset.
Good to know about the import process.

If I create another dataset, can I reconfigure lxd to use that as its default?