When I do a

rm -rf directory

It says a message like :

rm: can't delete directory/.nfs0000000008547f6500007f62
ressource occupied 

and I don't know why.


Your system is probably using NFS. The NFS client implementation creates these directories when a file is removed, but still in use by an application.

From http://nfs.sourceforge.net/#faq_d2:

A. Unix applications often open a scratch file and then unlink it. They do this so that the file is not visible in the file system name space to any other applications, and so that the system will automatically clean up (delete) the file when the application exits. This is known as "delete on last close", and is a tradition among Unix applications.

Because of the design of the NFS protocol, there is no way for a file to be deleted from the name space but still remain in use by an application. Thus NFS clients have to emulate this using what already exists in the protocol. If an open file is unlinked, an NFS client renames it to a special name that looks like ".nfsXXXXX". This "hides" the file while it remains in use. This is known as a "silly rename." Note that NFS servers have nothing to do with this behavior.

After all applications on a client have closed the silly-renamed file, the client automatically finishes the unlink by deleting the file on the server. Generally this is effective, but if the client crashes before the file is removed, it will leave the .nfsXXXXX file. If you are sure that the applications using these files are no longer running, it is safe to delete these files manually.

The NFS version 4 protocol is stateful, and could actually support delete-on-last-close. Unfortunately there isn't an easy way to do this and remain backwards-compatible with version 2 and 3 accessors.

If you restart the applications or the server, you can delete those files (because they will not be in use anymore), unless new ones are created in the mean time.

  • Could it come from a session variable in memory ?
    – Mantisse
    Jun 28 '16 at 7:11
  • This can be a pretty hairy problem on an NFS volume since multiple systems can have that directory mounted, and you'd need to find out which program on which system has that file held open. You may need to hop around on multiple systems and use lsof to find if there's a local program running, holding that file.
    – P. Heffner
    Jun 28 '16 at 17:48
  • As of the commands colulmn of lsof, I have ssh as I use a remote terminal over ssh, sftp-server, sshd and lsof PIDS while runinng lsof command but no single pid indicating a program that could be running unexepectedly.
    – Mantisse
    Jun 28 '16 at 23:40
  • However, the file is in a directory in which there has been oauth2 authentication with PHP, but nothing in memory but a session id.
    – Mantisse
    Jun 28 '16 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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