server
Could DF have a different value than DU?
02/12/2011
df = disk free
du = disk usage
On linux this two commands are used to show the disk space.
Since some days ago my server had the /root partion quite full, I looked around in it but I couldn't find the really big directory with anomaly files to purge. Usually I use du to determine the space in the single directory and df only for the total hds space.
Today I noted about 3gb of difference between the two methods.
I understood, finding two good posts on the internet that this could be happen due a deletion of files still in use by some applications.
For example, I've a big log file and I decide to delete it brutally without restarting the log processor application.
The file appears deleted, you can't see it anymore in the file system, du doesn't calculate it, but in effect it still persists on our hard disk
The next command will show all the files marked as deleted
lsof | grep "deleted"
as noted in the attached screen-shots I had a couple of very big log files that I thought were already deleted.
Using the next command I'll see the pid of each process that still uses those files.
lsof | grep "deleted" | awk '{print $2}'
Restart the process and you'll see your 'lost space' again :)
That's All
DU - DF [usage notes]
[root@machine var]#
du -sh
4.3G /var
[root@machine ~]#
df -h
File system Dim. Usati Disp. Uso% Montato su
/dev/sda2 92G 4,3G 83G 5% /