Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to evaluate where my disk space on my unix server is distributed. In order to see disk space current status I'm running:
df -h

enter image description here

But when trying to evaluate what is taking the disk space and running from /

du -skh * | sort -n

enter image description here

Total space used is 956GB, but the accumulative taken space that I'm seeing in the division is less than 730GB. The numbers just don't add up. How can this be? Where is the remaining ~200GB ??

Note - Most of the used disk space is used by MySQL. One hugh InnoDB table and a couple of smaller ones.

share|improve this question
    
What file system are you using? How big is your /tmp? Do you still see this after rebooting? –  terdon Sep 11 '13 at 16:48
    
For a better du estimate, add -x to prevent crossing multiple filesystems: du -sxh /. –  SlightlyCuban Sep 11 '13 at 16:50
    
du and df use different ways to calculate sizes: linuxshellaccount.blogspot.com/2008/12/…. Large block size or lots of small/recently-deleted files could account for the discrepancy. –  SlightlyCuban Sep 11 '13 at 16:52
    
@SlightlyCuban du -sxh / shows 690GB. Does this 226GB make sense because of the different ways? When will I run out of disk-space, when du or df says so? –  Noam Sep 11 '13 at 16:53
    
@Noam possible, but 20% of the FS might be a bit much: serverfault.com/a/57103/187589. When you run out of space depends on your filesystem, block size, and how you use it, but du should be more accurate. –  SlightlyCuban Sep 11 '13 at 17:03

2 Answers 2

df is going to ask the superblock for how much space is allocated, while du is going to calculate the size of all visible files. These two different metrics will result in df -h and du -sxh / not agreeing with each other.

If you are worried about free space, du should be more accurate (provided you're not about to run out of available blocks on the filesystem).

Further explanation: http://linuxshellaccount.blogspot.com/2008/12/why-du-and-df-display-different-values.html

share|improve this answer
    
So you would say it's safe to assume I have at least 200GB free, and not 84GB like df claims? How does the superblock know how much space is allocated? Also - does the fact that most of the used disk space is used by MySQL InnoDB table matter? (mainly one hugh table, and a couple of smaller ones) –  Noam Sep 12 '13 at 11:19
    
@Noam superblock knows how many blocks are in use (blocks x block-size = space used). As the article points out, this could include some deleted things. IIRC, df is also going to exclude the space reserved for root when it reports available space. If MySQL is using many small files, that'll skew df vs du (/var/log is usually the culprit for many tiny files). –  SlightlyCuban Sep 12 '13 at 13:37

Are you running the du command as root? If not, you will not be able to enter into directories like /root because of permissions issues. So you will not add up the size of files in these directories. This may explain why this number is lower. Also, I believe the df command will show the total size of a filesystem (e.g. inode sizes + file sizes) whereas du would only show the sizes of files. This would make df have a larger number.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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