Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
Which OS/filesystem? Just "UNIX" isn't very .. precise. –  pst Aug 17 '12 at 23:49
add comment

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

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

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.

2 Answers

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, du does not always respect the block size of the hard drive. So if you have a typical 4 KB block, but a file only has 1 KB of data in it, df may see that 4 KB of disk space is used, while du may only see 1.

Update: du vs df output mentions that running processes may keep deleted files open.

share|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
add comment

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.

share|improve this answer
add comment