A mount point /mnt/sub
is shadowed by another mount point /mnt
. Is it always possible to access the mounted filesystem?
Root access is a given. The system is a reasonably recent Linux.
Example scenario: accessing the branches of an overlay root
The basic sequence of operations is:
mount device1 /mnt/sub
mount device2 /mnt
After this /mnt/sub
is a file on device2
(if it exists). The question is how to access files on device1
.
Some devices can be mounted twice, so mount device1 /elsewhere
would work. But this doesn't work for all devices, in particular not for FUSE filesystems.
This differs from the already covered case where a subdirectory is shadowed by a mount point, but the mount point of the subdirectory is itself visible, and a bind mount can create an unobscured view. In the example above, mount --bind / /elsewhere
lets us see the /mnt/sub
directory from the root filesystem on /elsewhere/mnt/sub
, but this question is about accessing the filesystem on device1
.
/proc/PID/cwd
for a process that was running in it before the shadowing mount. That won't do, I guess?/
./
in that scenario? It wouldn't work in general since there's no way to make sure a process is started in the old mount point, but with/
, init is a good candidate, hopefully?