Interview Prep/Linux/Filesystem Hierarchy, Inodes & Links

How do mount namespaces and bind mounts let one directory appear in two places?

AdvancedConceptFilesystem Hierarchy, Inodes & Links
Answer

A bind mount attaches an existing directory tree at another mount point; both paths refer to the same inodes.

sudo mount --bind /data/www /var/www
sudo mount -o remount,bind,ro /var/www   # make the view read-only
findmnt /var/www

Mount propagation (shared, slave, private) controls whether mounts made under one copy appear in the other or in other mount namespaces. Container volumes and Kubernetes hostPath are built on bind mounts.

All Linux questions Roadmap: Linux

More on Filesystem Hierarchy, Inodes & Links