Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

In my debian 7:

$ pwd
/home/freestyler

$ mkdir old new
# mount --bind old new

then

$ mount
/dev/cciss/c0d0p9 on /home/freestyler/new type ext4(rw,noatime,nodiratime,user_xattr,barrier=1,data=ordered)

I can only see the /dev/cciss/c0d0p9, which is not the same as /home/freestyler/old

How can I get the original olddir path?

In debian 6:

the mount outpt the olddir path well:

 $ mount

/home/freestyler/old on /home/freestyler/new type none (rw,bind)
share|improve this question

1 Answer 1

up vote 1 down vote accepted

This is a bug, don't have an answer for you but here is the bug report:

mount: Bind mounts not shown as such in mount output

I was really curious about a way around this so I grabbed the debian 7 live cd and started playing around. I eventually came to this post:

Note that /etc/mtab is only useful here if it's a text file maintained by mount. Some distributions set up /etc/mtab as a symbolic link to /proc/mounts instead; /proc/mounts is mostly equivalent to /etc/mtab but does have a few differences, one of which is not tracking bind mounts.

One piece of information that is retained by the kernel, but not shown in /proc/mounts, is when a mount point only shows a part of the directory tree on the mounted filesystem. In practice this mostly happens with bind mounts:

mount --bind /mnt/one/sub /mnt/partial

In /proc/mounts, the entries for /mnt/one and /mnt/partial have the same device, the same filesystem type and the same options. The information that /mnt/partial only shows the part of the filesystem that's rooted at /sub is visible in the per-process mount point information in /proc/$pid/mountinfo (column 4). Entries there look like this:

12 34 56:78 / /mnt/one rw,relatime - ext3 /dev/foo rw,errors=remount-ro,data=ordered 12 34 56:78 /sub /mnt/partial rw,relatime - ext3 /dev/foo rw,errors=remount-ro,data=ordered

And in my testing, you may be able to extract the information you need by using:

root@debian:~# cat /proc/1/mountinfo 
14 24 0:13 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
15 24 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
16 24 0:5 / /dev rw,relatime - devtmpfs udev rw,size=10240k,nr_inodes=126630,mode=755
17 16 0:10 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
18 24 0:14 / /run rw,nosuid,noexec,relatime - tmpfs tmpfs rw,size=102704k,mode=755
20 24 11:0 / /lib/live/mount/medium ro,noatime - iso9660 /dev/sr0 ro
21 24 7:0 / /lib/live/mount/rootfs/filesystem.squashfs ro,noatime - squashfs /dev/loop0 ro
22 23 0:16 / /lib/live/mount/overlay rw,relatime - tmpfs tmpfs rw
23 24 0:17 / /lib/live/mount/overlay rw,noatime - tmpfs tmpfs rw,mode=755
24 1 0:18 / / rw,relatime - aufs aufs rw,si=993d359391edfb38,noxino
25 18 0:19 / /run/lock rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,size=5120k
26 18 0:20 / /run/shm rw,nosuid,nodev,noexec,relatime - tmpfs tmpfs rw,size=205400k
27 15 0:21 / /proc/sys/fs/binfmt_misc rw,nosuid,nodev,noexec,relatime - binfmt_misc binfmt_misc rw
29 24 0:18 / /bindmount rw,relatime - aufs aufs rw,si=993d359391edfb38,noxino
30 24 0:18 /root/old /root/new rw,relatime - aufs aufs rw,si=993d359391edfb38,noxino

From: List only bind mounts

You can also use cat /proc/$$/mountinfo or if in an application, you can use the local applications PID.

In the comments of the other question, another possible option to use is findmnt |fgrep [ or if you are just visually checking, just findmnt and you can read down the source column to see the bind mounts listed.

root@debian:~# findmnt | fgrep [
└─/root/new                                  aufs[/root/old] aufs         rw,relatime,si=993d359391edfb38,noxino
share|improve this answer
    
Thanks for providing the bug report link –  freestyler Oct 25 '13 at 12:59
    
Updated with a possible workaround for you –  Regan Oct 26 '13 at 0:18
    
Great, it works for me. –  freestyler Oct 28 '13 at 2:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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