Flexibility when deleting a LXD container


(Daniel Clavijo Coca) #1

Hello, is it possible to delete a contaier without deleting its rootfs? I know lxd stores a container rootfs is /var/lib/lxd/containers/container_name/rootfs.

Another good question would be if I can tell LXD where to load rootfs from, other than that default location?


#2

So, you want LXD to consider a specific container to be deleted (gone) but still keep the rootfs files intact?
The direct method would be to mess up with the LXD internal configuration so that LXD does not know of that container anymore. However, is that what you want to do?
The alternatives would be to take a snapshot and publish the image (to your local and private LXD installation), therefore a proper copy is maintains in /var/lib/lxd/images/

Regarding the second question, the rootfs for each container can be found in /var/lib/lxd/containers/.
It is not clear what you are aiming here. Do you just want LXD to use a different storage pool for some containers?


(Daniel Clavijo Coca) #3

No I don't want to trick LXD, I'm just looking for a way to delete the container while keeping its rootfs. In LXC you could tell the hipervisor to load the rootfs from a specific directory with the -P argument, however in LXD there's the source option under the disk type devices, but that parameter cannot be used for rootfs disk. It seems LXD always expect to find the rootfs mounted on /var/lib/lxd/containers/container_name/rootfs and I'm thinking in the possibility of launching a container from a different rootfs something like this, with -R being the rootfs argument.

lxc start container1 -R /tmp/rootfs1

I'm pretty sure you cannot do this using the CLI, but I don''t know if via the API it's possible. It would be like creating a container, via the CLI you always need to start the container from a base image, but with the API you can create a container wiht an empty rootfs.


(Eric Wolf) #4

I realize this is an old topic, but I think you’re just looking for multiple/different storage-pools?