I'm looking for a way to access the container's rootfs from the host. While I could just use the directory that was passed to lxc.rootfs, it doesn't have the mounts that the container has, so there are just empty directories instead of the mounts. Is there a way to get the same file tree as the container root?

Thanks :)

3 Answers 3


I use the following method for backup using rsync:

Using the pid of the container's init process, you can get it using

# list all hosts:
lxc-ls -f -Fname,pid

# or get pid of one host:
lxc-ls -f -Fpid mycontainer

Using this information, you can access the host's rootfs using the /proc filesystem.

cat /proc/13323/root/etc/hostname
# returns: "mycontainer"

The best solution I was able to find is to apply the same mounts both on the host and inside the container (via lxc.mount[.entry]). Mounts from the host do not transfer to the container as the container is fully isolated from the host's mounts.


The lxd storage mount location on the host can be different depending on if you use the snap package or not. The snap also uses a different mount namespace, so you have to access it via the mntns directory:

#Non snap location on host:
ls /var/lib/lxd/storage-pools/STORAGE_POOL_NAME/containers/CONTAINER_NAME/rootfs/

#Snap location on host:
ls /var/snap/lxd/common/mntns/var/snap/lxd/common/lxd/storage-pools/STORAGE_POOL_NAME/containers/CONTAINER_NAME/rootfs/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.