Space utilization by .nfs entries under NFS

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
 % rm foo
 % ls -A
 % rm .nfsC13B
 % ls -A

% lsof .nfsC13B
 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 *

Pin It on Pinterest