[CentOS] Question about cleanly unmounting slave bind mounts

Sat Feb 27 06:42:08 UTC 2016
likan_999.student at sina.com <likan_999.student at sina.com>

Hi,

I asked the question on stackexchange (http://unix.stackexchange.com/questions/264931/centos-7-unable-to-cleanly-umount-a-bind-mount-using-rbind-and-rslave) and CentOS 7 bug report (https://bugs.centos.org/view.php?id=10414) but didn't get any useful response, so I am thinking if I can get some help here.

The problem arose when I tried to rbind mount /dev and /proc to a chroot  sandbox and to unmount it, I have to set the mount to slave so that  unmounting submounts of <sandbox-root>/dev (e.g. /dev/pts) won't  unmount submounts of /dev.  This works for other distributions such as  Fedora 23 and Ubuntu 14.04, but under CentOS 7, umount succeeds but the  directory can't be removed.  For some reason, I have to stick to CentOS  7, so I wonder if there is a work around for it.

The steps to reproduce:
[hidden]$ mkdir -p A B/a C/b
[hidden]$ sudo mount --bind A B/a
[hidden]$ sudo mount --rbind B C/b
[hidden]$ sudo mount --make-rslave C/b
[hidden]$ sudo umount C/b/a
[hidden]$ sudo umount C/b
[hidden]$ rmdir C/b
rmdir: failed to remove ‘C/b’: Device or resource busy

None of mount, cat /proc/mounts, cat /etc/mtab, sudo lsof, sudo fuser C/b  shows any process using the directory C/b; stat C/b shows it is  different inode than B, meaning it has already been unmounted  successfully.

The kernel version is 3.10.0-327.10.1.el7.x86_64.

Any suggestion is welcomed.附件(0个)全部下载超大附件(0个)