Search This Blog

Thursday, May 27, 2010

Why is the output of du and df inconsistant for some partitions

The output of du and df command may differ in some situations . For example:
# du -sh /opt
1.5G /opt

# df -hP /opt
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol05 6.0G 5.1G 594M 90% /opt

Here du shows 1.5G utilizations , whereas df shows 5.1G utilization

This behaviour could happen sometimes when a big file is deleted from the /opt partition. The inodes for the file could be reserved by a process still in memory. Restarting the related service would solve this issue.

For confirming, check the output of:
# lsof | grep '(deleted)'

In the left side of the related output entry, you could see the program which is holding the file and its pid.

You can restart the the program if possible. If there is any problem in restarting the program, you would have to restart the system.

No comments: