The following sequence of commands will fail on CentOS 7 (kernel version: 3.10.0-327.10.1.el7.x86_64):

[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.

These commands are the smallest example to reproduce an issue I found when I tried to rbind /dev and /proc to a sandbox, and failed when I tried to destroy the sandbox. make-rslave is necessary here, otherwise submounts under /dev/ will be unmounted, which messes up the system.

These commands work for Ubuntu 14.04 (kernel version 3.13.xx) and Fedora 23 (kernel version 4.x).

My question is, if I have to stick to CentOS 7 for some reason, how do I work around the issue and destroy the sandbox cleanly?


Try doing umount -a within the chroot environment; Then, exit and umount -l if umount -R fails.

(chroot) # umount -a
(chroot) # exit
(liveos) # 
(liveos) # umount -R /mnt/point/
(liveos) # umount -l /mnt/point/

-R, --recursive
              Recursively  unmount  each specified directory.  Recursion for each directory will stop if any unmount
              operation in the chain fails for any reason.  The relationship between mountpoints  is  determined  by
              /proc/self/mountinfo  entries.   The  filesystem  must  be  specified  by mountpoint path; a recursive
              unmount by device name (or UUID) is unsupported.

-l, --lazy
              Lazy unmount.  Detach the filesystem from the file hierarchy now, and clean up all references to  this
              filesystem as soon as it is not busy anymore.  (Requires kernel 2.4.11 or later.)
  • "None of mount, cat /proc/mounts, cat /etc/mtab ... shows any process using the directory C/b". We've done the umount -R part successfully. There is no mount left to run umount -l on - it would return "not mounted". But rmdir C/b is still returning "Device or resource busy". – sourcejedi Jan 11 at 14:27
  • Also umount -a inside a chroot is probably not a good idea! If the container root is a mount point, it will remount it read-only. unix.stackexchange.com/questions/466535/… – sourcejedi Jan 11 at 14:31

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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