Re: can not umount rbind mounts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 12, 2011 at 11:59:10PM -0400, Mike Frysinger wrote:
> On Tuesday, April 12, 2011 23:41:23 Phillip Susi wrote:
> > mkdir /mnt/dev
> > mount --rbind /dev /mnt/dev
> > umount /mnt/dev
> > 
> > The umount fails because of the sub mounts that the recursive bind also
> > bind mounted under /mnt/dev, which you have to remove manually first.
> > When you mount with --rbind, umount should be able to reverse the
> > process, unmounting all recursively bound mounts.
> 
> yes and no ... i dont think the fact you used "--rbind" is tracked anywhere.  

Yep, it's important to understand that "bind" mounts are nothing
special from kernel point of view. 

   # mount /dev/foo /mntA
   # mount /dev/foo /mntB

is exactly the same thing like:

  # mount/dev/foo /mntA
  # mount --bind /mntA /mntB

For Linux kernel there is not any extra relation between the mountpoints.
The filesystem is connected to the two places in the VFS. That's all.

For more details see /proc/self/mountinfo. It's mount(8) disadvantage
that mtab entries use directories as a source (1st field) for bind mounts.
For example:

  /mntA /mntB  fstype  bind,options 0 0

in mtab is nonsense (e.g. /mntA could be umounted independently on /mntB).

Unfortunately many users still believe that "bind" mounts are something
special.  It's probably because mount(8) maintaining the "bind" flag in
the mtab file and because there is a special semantic for
MS_REMOUNT|MS_RDONLY|MS_BIND in kernel.


Note that MS_BIND operation allows to mount subdirectory (non-root
directory) from the filesystem, then

    mount --bind /mntA/subdir /mntB

/subdir is the root for /mntB -- this is also tracked in
/proc/self/mouninfo (4th field). It seems that

   mount -t btrfs -o subvol=subdir /dev/foo /mntB

has the same effect on btrfs.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux