Why would these two commands report free space so differently? This started happening last year on several Ubuntu 18.04 VMs from time to time.
df
reports 100% used while du -smh
shows only 2.3G of the 4.0G (total) in use.
This is often followed by rsyslog
or syslog-ng
filling up /var
with error messages when the syslog server is down for maintenance.
# df -mh /var
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/new_vg-var 4.0G 3.9G 0 100% /var
# du -smh /var
2.3G /var
# fuser /var
Best Answer
Most common reasons for df to be larger than du:
du
on the entire filesystem.du -s /filesystem/*
, and you're missing the dotfiles at the top. Rerun asdu -sx /filesystem
du
cannot reach the files to determine the size. Can size them by unmounting the shadowing filesystem or often with a loop mount of the original filesystem.du
cannot access them to read any longer, but they still take space. Trylsof +aL1 /filesystem
to find the orphaned files and the process holding them open. When the process closes the file, the space will be released.Most common reason for df to be smaller than du:
du
is descending into it and counting that space as well. Rerun asdu -sx /filesystem