29

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?

marked as duplicate by Mikel, Renan, Michael Mrozek Aug 18 '12 at 11:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Aug 18 '12 at 2:35

This question came from our site for professional and enthusiast programmers.

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

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.

  • 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
2

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.

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