Solved-Why are directories in containers unavailable when they are offline and is there a way to access them while containers are offline


(Tony Anytime) #1

It seems that LXD use symlinks to link container directories to Zfs., but when lxd or a container is down there is no easy way to get to files in the container.
Are the original files available otherwise outside of LXD/LXC.


(David Negreira) #2

LXD creates a ZFS dataset for each container.
This zfs dataset is isually under /var/lib/lxd/containers/<container>/rootfs
If the zfs dataset is mounted you should be able to see it with zfs list and mount it with zfs mount

If you have snap you need to do some extra tricks to use zfs inside of the lxd namespace and see the zfs storage:
LD_LIBRARY_PATH=/snap/lxd/current/zfs-0.8/lib /snap/lxd/current/zfs-0.8/bin/zfs list
Also the storage of th containers is mounted under /var/snap/lxd/common/lxd/containers/<container>/rootfs


(Stéphane Graber) #3

We don’t mount stopped containers as every entry in your mount table makes parsing it slightly slower, so there’s no reason to keep stuff mounted when we’re not using them.


(Tony Anytime) #4

I appreciate your answer. I believe there should be a fall back mode to access containers with the them down that is more user friendly, just a thought.


(Tony Anytime) #5

Thanks, I was able to do a simple backup of my containers most important part with a simple bash file…

fs mount local/containers/$1
cp -RLv /var/lib/lxd/storage-pools/local/containers/$1/rootfs/var/ /mnt/md0/backup/$1