[CentOS] du vs df size difference

Robert Nichols rnicholsNOSPAM at comcast.net
Wed Sep 30 22:46:27 UTC 2009


Ryan Pugatch wrote:
> Hi all,
> 
> Curious issue.. looking in to how much disk space is being used on a 
> machine (CentOS 5.3).  When I compare the output of du vs df, I am 
> seeing a 12GB difference with du saying 8G used and df saying 20G used.
> 
> # du -hcx /
> 8.0G    total
> 
> # df -h /
> Filesystem            Size  Used Avail Use% Mounted on
> /dev/xvda3             22G   20G  637M  97% /
> 
> I recognize that in most cases du and df are not going to report the 
> same but I am concerned about having a 12GB disparity.  Does anyone have 
> any thoughts about this or reason as to why there is a big difference? 
> I have read a few articles online about it and none have really shown 
> such a large difference.

I see similar differences even when I:

     a) Boot from a rescue CD,
     b) Freshly fsck the file system to be tested,
and c) Mount that file system read-only.

I suspected the discrepancy might be due to the space used for the
ext3 journal, but I also see it on a freshly created ext2 file system:

     # mount -r /dev/hda8 /mnt/tmp
     # du -s /mnt/tmp; df /mnt/tmp
     20      /mnt/tmp
     Filesystem           1K-blocks      Used Available Use% Mounted on
     /dev/hda8             13638436     33824  12911812   1% /mnt/tmp

So, there's a 33+MB difference on a fresh, empty ext2 file system.

Looking at the file system with debugfs, I find inode 7 is a regular
file of size 4299210752 and a block count of 67608.  That's a huge
sparse file.  A little research shows that this is the "resize inode"
that reserves space for future GDT blocks so that the file system can
be expanded in place.

-- 
Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.




More information about the CentOS mailing list