[PLUG] df shows 33G used, but it does not add up with du

Keith Lofstrom keithl at kl-ic.com
Mon Jan 9 18:26:17 UTC 2006


On Sun, Jan 08, 2006 at 11:49:46PM -0800, Robert Anderson wrote:
> I have an xfs filesystem that shows 33G used when I run df...
> 
> [rob at mythtv ~]$ df -h /mythtv
> Filesystem            Size  Used Avail Use% Mounted on
> /dev/hda5              65G   33G   32G  52% /mythtv
> 
> However, it does not add up to 33G when I run du...
> 
> [rob at mythtv mythtv]$ pwd ; sudo du -hs
> /mythtv
> 21G     .
> 
> I'm confused. Please help. Thanks in advance.

There are lots of ways that the "file" level view differs from
the "partition" level view.  I am assuming that /mythtv is 
the mount point for a separate partition /dev/hda5 , and that 
some other disk partition is mounted on / .  If /dev/hda5 is
mounted on /, and /mythtv is merely a directory located in /,
then there is something like 12GB stored in other directories
also located in / .  But df does show /mythtv as a mount point,
so that isn't it...

Assuming that /mythtv is indeed on a separate partition, the
numbers are challenging to explain, but there are situations 
that could cause them.  Some file system types dynamically
allocate inodes and directory tables, the metatdata on a partition
that describes where stuff is.  If you had an enormous number of
very small files, the file contents (reported by du) would be
smaller than (file contents)+(metadata), which is reported by df.
However, it seems unlikely that anything labeled "XXXXtv" would
be an enormous bunch of tiny files.

Another likely possibility is a corrupt file system.  A whole
bunch of the disk may be improperly allocated to nonexistent
files.  First, do a sync.  An fsck might be called for.  

While this is not what you are reporting, it is possible to have
du report a vastly larger number than df, because of hard-linking
in files.  The backup system I use makes enormous numbers of hard
links from different filenames to the same data;  du counts all
the linked filenames separately, while df counts them only once.
So I have partitions on my backup disks that report a df value of
240GB, while du -s reports 48000GB (after a few hours of runtime).
Again, this is not happening to you, but you may see something like
it someday.

Keith

-- 
Keith Lofstrom          keithl at keithl.com         Voice (503)-520-1993
KLIC --- Keith Lofstrom Integrated Circuits --- "Your Ideas in Silicon"
Design Contracting in Bipolar and CMOS - Analog, Digital, and Scan ICs



More information about the PLUG mailing list