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 C_dir
to B_dir/mount_c
and rbind B_dir
to A_dir/mount_b
:
[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
Now 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 B_dir/mount_c
to C_dir
?
Thanks.