‘df’ command VS ‘du’ command

On a mail server, I had a strange problem on ext3 partition. When I saw output of ‘df’ command, partition was Use% at 95% (size of 8 Go) but only 2 Go if I use ‘du’ command. And I have only 15.000 files on this partition according “find | wc -l” hack (then no block-size problem). Solution is in Linux ext3 FAQ :

The standard cause for this is some user process keeping a deleted file open. When this happens, the space is not visible via ‘du’, since the file is no longer visible in the directory tree. However, the space is still used by the file until it is deallocated, and that can only happen once the last process which has the file open either closes its file descriptor to the file, or the process exits. You can use the lsof program to try to find which process is keeping an open file. Usually it’s some log file, or some large data base file which gets rotated out, but some older process are still keeping the log file open.

Then I discovered ghost files with :

# lsof | grep “(deleted)”

In my case, an amavis daemon didn’t close an old and big log file.
I closed this process and now ‘df’ command say me Use% at 20%.

Then ‘df’ command win ;-)
End of alert.

Comments are closed.