40

Possible Duplicate:
Why is there a discrepancy in disk usage reported by df and du?

df says 8.9G used by the partition mounted in /

:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda5       227G  8.9G  207G   5% /

However, a du in / yields a much smaller number.

:~# du -chs /
5.5G    /
5.5G    total

I was expecting a smaller number, but why is to so much smaller?

  • Which OS/filesystem? Just "UNIX" isn't very .. precise. – pst Aug 17 '12 at 23:49
24

Take a look at du vs. df difference

Here is a more thorough explanation: http://linuxshellaccount.blogspot.com/2008/12/why-du-and-df-display-different-values.html

Basically, df reads the superblock only and trusts it completely. du reads each object and sums them up.

Also, a running process can keep a deleted file open. This means the space will still be reserved and seen by df, but since du will no longer see a reference to that file in the directory tree, it cannot see those reserved blocks.

| improve this answer | |
  • The page you link to is wrong. du shows block usage by default, not file size. You have to do du -b or du --apparent-size to get the effect you describe. – Mikel Aug 18 '12 at 3:55
3

Probably df is accounting for all the space allocated for inodes and other administrative overhead, whereas du is just accounting for the space used by the files.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.