Cannot delete folder with rm -rf. Error: device or resource busy
187,094
Solution 1
I was having the same issue, I was trying and failing to delete
/usr/local/tomcat/data
with the error rm: cannot remove
/usr/local/tomcat/data': Device or resource busy`
until I noticed that df -h
said
/dev/vda3 20G 172M 20G 1% /usr/local/tomcat/data
that is, I had a partition mounted to that point. Mystery solved.
Solution 2
You can use lsof
or fuser
to indentify which is using this directory, something like this:
# lsof +D /var/www/html
Solution 3
It's likely that there is a process running that is using a file or files found somewhere in the tree below /var/www/html
try
lsof +D /var/www/html
to get a list of the processes using files in the tree. Sample output below shows that a bash shell with PID 8138 is using /var/www/html/iain.
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
bash 8138 iain cwd DIR 253,0 4096 1982790 /var/www/html/iain
Related videos on Youtube
Author by
Apealed
Updated on September 18, 2022Comments
-
Apealed over 1 year
I'm trying to delete /var/www/html but I'm getting this error:
rm: cannot remove `html': Device or resource busy
-
jgoldschrafe over 12 yearsLong shot, but do you have
/var/www/html
configured as a mount point for another filesystem?
-
-
Apealed over 12 yearsNothing shows up. No errors or anything.
-
user9517 over 12 yearstry
/sbin/fuser -m /var/www/html
-
Jake Levi over 2 yearsIf you want to actually unmount the partition, see advice in this comment: unix.stackexchange.com/questions/11238/…