A lot of people keep saying that Linux does not keep information about bind mounts, so there is no way to get a list of them and their sources. Here are some examples:
from one of the the comments here:
IIRC this information is not kept anywhere: after
mount --bind
, the two copies are equivalent, there isn't one that's more “original” than the other. After all there could be no original if you'd already unmounted/mnt
.from an answer on this site:
So the only way to remember what mounts were bind mounts is the log of mount commands left in
/etc/mtab
. A bind mount operation is indicated by the bind mount option (which causes the filesystem type to be ignored). But mount has no option to list only filesystems mounted with a particular set of sets of options.from a Debian bug report:
This is intentional. Both mount points are fully equal in all ways so the kernel does not keep any flags to differentiate them.
The above is nonsense though. The tool findmnt
is able to list the source paths of bind mounts (in the form of device[source-path]
; I'm also trying to get it to list just the source path and not the device). If the Linux kernel is to maintain a bind mount, then that information has to be stored somewhere, otherwise it couldn't know that /home
is bound to /users
. So where is this data? Is it stored in some obscure region in RAM? Does findmnt
look in /proc
somewhere?
findmnt
are you running and what options are you giving it? Mine doesn't print it out like that and looking at the source code it looks to be using_PATH_PROC_MOUNTINFO
which looks to be/proc/self/mountinfo
which doesn't have this information in it either. – Bratchley Jul 13 '16 at 02:16/proc/self/mountinfo
relatively recently was restructured. I was on my RHEL6 machine before which didn't have the path info but my RHEL7 machine does and as mentioned in your link Wheezy does as well. – Bratchley Jul 13 '16 at 02:31/dev/A
is mounted at/B
and you domount --bind /B /C
, older kernels remember only/B → /dev/A
and/C → /dev/A
, they don't remember any relationship between/B
and/C
. So unmounting/B
naturally has no effect on/C
. Newer kernels remember that/C
was a bind mount of/B
, but in a way that doesn't prevent/C
from continuing to work if/B
is unmounted, I don't know exactly how. – Gilles 'SO- stop being evil' Oct 27 '16 at 20:27