How Do You Handle Discrepant Results from df and du Commands?

Problem scenario
You run df and du. You see different amounts of CPU space that are free versus utilized. What should you do?

Possible Solution #1
Reboot the server. Rebooting may fix the problem.

Possible Solution #2
Run this command: lsof

Some files may be open that should not be. The lsof command should help you determine if a file's utilization is lingering.

Possible Solution #3
Do you know what directory is relevant? Through iterations of du and df commands, you can often determine what directory has the discrepancy.

Run this command (but substitute /foo/bar/ with the directory path in question):

fuser -v -m /foo/bar

Possible Solution #4
Can you unmount the file system in question (e.g., with umount)? If you can unmount it, run this command: Run this command (but substitute /foo/bar with the path to the file system): fsck /foo/bar
(This was adapted from https://www.ibm.com/support/pages/causes-mismatch-between-disk-usage-reported-df-and-du.)

Possible Solution #5 (less of a df issue but more of a du and quota discrepancy)
If you are having an issue with your disk quota settings and the du command results, see this Stackexchange.com posting.

Potential root cause #1
The root cause could be that an inode has been deallocated but some aspects of the system have not been updated (possibly because another process is using a file that lost its inode).

Potential root cause #2
A hidden directory could have a files with large sizes.

Potential root cause #3
An administrator with greater privileges could have isolated some directories with files that are taking up a good deal of space.

Leave a comment

Your email address will not be published. Required fields are marked *