Rmdir failed due to "Device or resource busy"

There are many similar issues, such as "Device or resource busy." But I think my problem is different from them.

I use mount -bind to bind a directory

mount --bind /tmp/origin /tmp/mount

and then you can run it successfully

umount /tmp/mount

And then if I call rm right away

rm -rf /tmp/mount

I may get an error message Device or resource busy. If I wait 2 ~ 3 seconds and then call rm, this may succeed.

So it’s very strange here. I'm trying to use

lsof +D /tmp/mount

did not see anything.

I also use fuser -vm /tmp/mount, I don’t see any process holding this folder.

I compare /proc/mountsbefore umount /tmp/mountand after umount /tmp/mount. /tmp/mountalready deleted.

stat /proc/mounts umount /tmp/mount umount /tmp/mount. , , /tmp/mount .

sync && echo 2 > /proc/sys/vm/drop_caches , .

Ubuntu 14.04, CentOS 6.6. .

+4
4

@g-v . , . CLONE_NEWNS, fork-. CLONE_NEWNS MESOS-3349

. umount , - CLONE_NEWNS, , . , call rmdir EBUSY.

, . LWN 159092

+1

, , , .

  • un-mount

    sudo umount /your_path
    
  • mout /etc/fstab

    sudo nano /etc/fstab
    
  • sudo reboot
    
  • sudo rm -rf /your_path
    
+7

, Linux:

  • . close() umount() EBUSY, . . : 1, 2.
  • Umounting . , .

sync && echo 2 > /proc/sys/vm/drop_caches , .

. sync(8):

Linux sync ; , . reboot(8) halt(8) , sync(2).

/proc/sys/vm/drop_caches, . :

.

, umounting .


, umounting , ​​ EBUSY , .

, : P


PS.

, man , sync(8) Linux. sync(2), :

According to the standard specification (for example, POSIX.1-2001), it sync()plans recordings, but may return before the actual writing. However, since version 1.3.20 Linux is really waiting. (This still does not guarantee data integrity: there are large caches on modern disks.)

+4
source
  • check

    df -h
    
  • then

    sudo umount /path
    
0
source

Source: https://habr.com/ru/post/1606153/


All Articles