You can recreate above scenario in your Linux system as follows:
First, note down /home file system output:
# df -h /home
# du -s -h /home
Now create a big file:
# cd /home/user
# cat /bin/* >> demo.txt
# cat /sbin/* >> demo.txt
Login on other console and open file demo.txt using vi text editor:
# vi /home/user/demo.txt
Do not exit from vi (keep it running).
Go back to another console and remove file demo.txt
# rm demo.txt
Now run both du and df to see the difference.
# df -h /home
# du -s -h /home
Login to another terminal and close vi.
Now close the vi and the root cause of the problem should be resolved, the du and df outputs should be correct.
If the apllication holding the file discriptor can not be found a reboot will also correct the problem.
Applies To
https://www.walkernews.net/2007/07/13/df-and-du-command-show-different-used-disk-space/ - df will say that the disk space is free when only the process which accesses it got terminated - du will only say the files which are having inode entry, - so the df and du will not match normally, - use lsof command to find that when there is difference.