Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.nfs file - wierd

Status
Not open for further replies.

dbbyleo

IS-IT--Management
Sep 10, 2002
20
0
0
US
We have a V480 box running Solaris 9 with NFS volumes on NetApp Filers.
I have these 2 directories in one of the volumes - DirA and DirOLD.
I have a daily job that
1.) deletes DirOLD
2.) renames DirA to DirOLD
3.) creates a new DirA (then backups a bunch of files from other locations into DirA)

So, basically, contents of DirOLD should look more or less like DirA from the previous day.

A couple of nights ago, the job fails at step 1. When I tried to delete DirOLD manually (rm -r DirOLD), I got a "File Exists" error. When I cd into DirOLD, I found it contained no files except for one odd file (normally I expected a whole bunch of familiar files). The one file had a name of .nfs#### (ex: .nfs1234) - I don't remember the exact numbers, but know that it started with ".nfs" and was followed by 3 to 4 digits.

When I couldn't delete the directory, I tried renaming it (to DirOLDOLD), which worked. 2 days later (when I had to time to investigatethe odd file), I found it was no longer in DirOLDOLD. At this point, I'm not sure if it disappeared as soon as I renamed the directory, or sometime after.

At any rate, does anyone know what caused this occurrence to happen?
 
From:
Q: What is this .nfs file and why can't I remove it?

Under unix, if you remove a file that a currently running process still has open, the file isn't really removed. Once the process closes the file, the OS then removes the file handle and frees up the disk blocks. This process is complicated slightly 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 bobac) and the files are on the server (such as paca), there has to be some way for the two machines to communicate information about this file. The way NFS does this is with the .nfsNNNN 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.

If you want to know what process has this file open, you can use 'lsof .nfs1234'. Note, however, this will only work on the machine where the processes that has the file open is running. So, if your process is running on bobac and you run the lsof on some other burrow machine, you won't see anything.

For example:

% echo test > foo
% tail -f foo
test
^Z
Suspended
% rm foo
% ls -A
.nfsB23D
% rm .nfsB23D
% ls -A
.nfsC23D
% lsof .nfsC23D
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
tail 1257 robh 0r VREG 176,6 5 3000753 .nfsC23D
%


So, once you have located 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, the .nfsC23D file will disappear.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top