11

This question already has an answer here:

A lot of time when I delete a folder, it says cannot be deleted because of .nfs files

Error - Device or resource busy

How can I delete a folder ignoring these errors ( is there any flag in rm command) ? or I would have to find out the process using it, and first kill that process ?

In that case how can i make it work to remove entire directories ?

marked as duplicate by Gilles, mdpc, Stephen Harris, Anthon, Scott Aug 16 '16 at 7:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You could try running fuser /path/to/.nfs to check which process is using the .nfs file. – mtak May 2 '14 at 9:13
  • what difference would it make than using lsof ? – Novice User May 2 '14 at 12:22
  • For this, none I guess. But I don't understand why you're asking that. – mtak May 2 '14 at 12:25
  • 1
    I want to use some script which deletes all files/folders inside a directory, and also clear up any .nfs files present. – Novice User May 3 '14 at 4:52
  • Can you give an example of a .nfs file name? NFS commonly uses .nfs### files for internal record keeping, for example (where ### is some long string of digits). Also would be useful to know if NFS is involved, either the file system you are using is NFS mounted on your host, or if it is NFS exported to some other host. – Peter Aug 4 '14 at 1:11
5

You can remove whole folder with rm -rf . Where r = recursive and f = forcefully. See man page of rm for better understanding.

But if Error "Device or resource busy" is coming that means folder is in use by some process. So you first need to find that process and need to kill it and then you can remove folder.

  • Will rm -rf able to delete the files even if they say "Device or Resource busy" ? – Novice User May 2 '14 at 7:10
  • Yes, And just try it on your set-up and check it out. – ravibhuva9955 May 2 '14 at 7:26
  • 2
    Good suggestion. I just tried. It doesn't work. Thanks. – Novice User May 2 '14 at 7:58
  • 3
    No, you can't delete .nfsXXX files. Or more precisely, you can delete them, but they'll come back immediately. You need to close the program that has them open, and that program could be running on any client that has this directory mounted over NFS. – Gilles Aug 15 '16 at 23:29

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