Space utilization by .nfs entries under NFS

Posted by & filed under .

On linux/unix systems if you delete a file that a currently running process still has open, the file isn’t really deleted or removed . Once the process closes the file, the OS then removes the file handle and free up the disk blocks.

This process works slightly other way when the file that is open and removed is on an NFS mounted filesystem. Since the process that has the file open is running on one machine (such as a workstation in location A ) and the files are on the file server, there has to be some way for the two machines to communicate information about this file. The way NFS does this is with the .nfsNNNNNN files. If you try to remove one of these file, and the file is still open, it will just reappear with a different number. So, in order to remove the file completely you must kill the process that has it open.

You can list down these files using ‘ ls -lah ‘, the process needs to be killed in order to release space .

If you want to know what process has this file open, you can use below command

#  lsof | grep -i .nfs1234

Example :

% echo testfile > foo
% tail -f foo
testfile
^Z
Suspended
% rm foo
% ls -A
.nfsC13B
% rm .nfsC13B
% ls -A
.nfsC13B

% lsof .nfsC13B
  COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
  tail   1182 jack    0r  VREG  186,6   5 1200718   .nfsC13B%

Once you find and and killed the process that has the file open, the .nfs file will go away automatically. In the above example, when you kill the tail process i.e PID 1182 , the .nfsC13B file will disappear .

Leave a Reply

Your email address will not be published. Required fields are marked *


seven − = 1

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>