Just a heads up. I mixed up the path and source while setting up a new container. Following that i deleted the container, and it wiped out the data directory on the host.
I had backup so was not an issue.
# lxd --version
3.12
Just a heads up. I mixed up the path and source while setting up a new container. Following that i deleted the container, and it wiped out the data directory on the host.
I had backup so was not an issue.
# lxd --version
3.12
Hi!
This is important and probably needs to be fixed.
I suppose you created a disk device with lxc config device add mycontainer disk ...
?
I could not get it to happen.
Can you adapt the following so that it becomes a reproducible example of the issue that you faced?
$ lxc launch ubuntu:18.04 mycontainer
Creating mycontainer
Starting mycontainer
$ mkdir /tmp/IMPORTANT
$ touch /tmp/IMPORTANT/important.txt
$ lxc config device add mycontainer mydisk disk source=/tmp/IMPORTANT/ path=/tmp/IMPORTANT
Device mydisk added to mycontainer
$ lxc stop mycontainer
$ lxc delete mycontainer
$
I added the config directly using vim, ‘lxc config edit mycontainer’ and the image was centos/7.
I still cannot replicate.
How does the disk device look in the configuration? This is how it looks, when created with lxc config device add mycontainer...
.
devices:
mydisk:
path: /tmp/IMPORTANT
source: /tmp/IMPORTANT/
type: disk
Like this,
devices:
eth0:
nictype: bridged
parent: vlan100br
type: nic
sharework:
path: /mnt/data
source: /mnt/data/Work
type: disk
I think i mixed up the path and source, but dont remember what it was unfortunately.
I could not find a reference in the LXD source code for removing files, relating to disk
devices.
The disk
device is for mounting FROM the host TOWARDS the container.
The source
is always on the host, and must exist. The path
is always in the container. Reference: https://lxd.readthedocs.io/en/latest/containers/#type-disk Also, you have not mentioned using any of the fancy disk
parameters.
My assumption is that the files might have gotten erased from within the container for some reason.
Another way to make files dissapear, is if you mount over them. The directory may appear empty, but when you unmount, the files will reappear.
Yeah, LXD has no logic to recursively delete files attached through a disk device, that’s on purpose as there’s no cases where we’d want such files to get deleted.