0

On the docker image debian:stretch-slim, couldn't delete a specific folder on a NFS drive, using rm -rf /folder-name as root (or rm-rf * after entering the folder-name). Got the following error back:

rm: cannot remove 'test-ikmgfjhv/dev/.nfse47cf31c6b1dd52500000009': Device or resource busy
Dharman
  • 30,962
  • 25
  • 85
  • 135
StackMaster
  • 359
  • 1
  • 5
  • 22

3 Answers3

0

After a lot of searching, eventually got to the following link:
https://uisapp2.iu.edu/confluence-prd/pages/viewpage.action?pageId=123962105

Which Describes exactly why those files exist in NFS and how to handle them. As I wasn't using the same machine the process runs on (another container), so in my case, I had to work around that and first make sure the process using the file is being killed on the first machine, then try to delete it on the second one, according to the project's needs.

Dharman
  • 30,962
  • 25
  • 85
  • 135
StackMaster
  • 359
  • 1
  • 5
  • 22
0

It is possible that the .nfs file is attached to a process that is busy or running (like an open file, for example, a vim file).

For example, if the hidden file is .nfs000000000189806400000085, run this command to get the pid: lsof .nfs000000000189806400000085

this will output the PID and other info related to that file

then kill the process: kill - 9

Be aware that if the file was not saved you will lose the information.

0

While running any command if you get error like : /home/mmandi/testcases/.nfs000000e75853 :device or resource busy.

Go to the directory where this file is being shown. For e.g - In this case : /home/mmandi/testcases/

Do following :

# ls -la : This will display contents of the directory along with files starting with "."

Here it displays the .nfs000000e7585 file.

# lsof .nfs000000e7585

This will list down the PID

# Use Kill -9 PID.
Dharman
  • 30,962
  • 25
  • 85
  • 135