Summary: What to do when df and du show different space usage.
Date: Around 2011
Refactor: 21 February 2025: Checked links and formatting.
It happened to me today. Df shows 90% full, du shows just about 10% in use. So how does this happen? If the files are deleted (by rm command for example) while they are being opened or used by a Linux program / process, the evil of “open file descriptor” problem arises and confuse the Linux file system on reporting the real figure of used disk space or free disk space available.
In order to resolve the fake “disk space full” problem, i.e. to reclaim “used disk space”, you need to kill or terminate the “defunct process” - in this case, the rm command that turns to be defunct process while the files are being used.
Once these defunct processes are terminated, the “open file descriptor” problem will be resolved, and both the du and df commands will agree to report the real file system used disk space or free disk space!
How to find out and terminate or kill the defunct processes that cause open file descriptor problem, in order to resolve the difference of used disk space in du and df command?
For this particular scenario, the lsof command (list open file command) is great to show light:
lsof | grep "deleted" or lsof | grep "theprocessyouknowthenameof"
If it's a daemon, restart it (if possible), or kill the process. Problem solved!