Asked on serverfault but didn't get enough attention, so reposted here, with the hope some people here know the answer.
There is another question discussing about umounting rbind mounts, but the solution has unwanted effect. Consider the following directory layout:
. ├── A_dir │ └── mount_b ├── B_dir │ └── mount_c └── C_dir
Now I bind
B_dir/mount_c and rbind
[hidden]$ sudo mount --bind C_dir B_dir/mount_c [hidden]$ sudo mount --rbind B_dir A_dir/mount_b [hidden]$ mount | grep _dir | wc -l 3
umount A_dir/mount_b will fail, which is not surprising. According to the answers everywhere on the web, we need to
umount A_dir/mount_b/mount_c first then
umount A_dir/mount_b. However,
umount A_dir/mount_b/mount_c will also unmount
B_dir/mount_c, which is unwanted:
[hidden]$ sudo umount A_dir/mount_b/mount_c [hidden]$ mount | grep _dir | wc -l 1
Now my question is, how do I unmount
A_dir/mount_b but leaving
B_dir unaffected, i.e. there is still a bind
EDIT: this problem doesn't seem to appear in Ubuntu. More specifically, it works fine on my Ubuntu 14.04 but not working on Fedora 23 and CentOS 7. Why there is the difference and what's the work around for Fedora and CentOS?
EDIT: some more information on the actual problem that I am trying to solve. I tried to create a sandbox and used
--rbind to mount the
/proc to the sandbox. When destroying the sandbox, it seems I can't cleanly destroy it because unmounting
<sandbox-root>/dev/pts in FC23 and CentOS7 will unmount
/dev/pts, after which my shell and SSH connections hang and I have to reboot the machine. That's why I am asking if there is a way to unmount the --rbind mounts without affecting submounts.