[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Different reported sizes with df and du

From: Bob Proulx
Subject: Re: Different reported sizes with df and du
Date: Wed, 30 Oct 2002 18:21:07 -0700
User-agent: Mutt/1.4i

Thomas Preissler <address@hidden> [2002-10-21 14:24:43 +0200]:
> I have encountered a strange problem with df 4.0.

Yes, a strange problem.  I can't recreate it here.

> df shows me that a partition is nearly full. But when I use other
> programs like du or calculate it by hand, other values are shown.
>   host:~ # df -h
>   /dev/hda5             3.8G  3.4G  162M  96% /var
>   host:~ # du /var -sh
>   1.8G    /var

Almost a 2x factor of difference.  I have to ask, might part of your
data under /var be mounted on a different filesystem?

> Counting filesize by hand shows me:
>   host:~ # for s in $(find /var -printf "%s\n") ; do sum=$(echo "$sum+$s" | 
> bc); done; echo $sum
>   1904892706

Huh?  Did you miss something when posting that command?  It seems only
half constructed.

I tried a similar experiment on my system.  Here is my result.

  du -sb /var
  329510912       /var

  sum=0; for f in $(find /var -print0 | xargs -r0 ls -ld | awk '{print$5}');do 
sum=$(expr $sum + $f); done ; echo $sum

  find /var -printf "\n" | wc -l

Since du really reports in block size as reported by the filesystem
some difference would be expected.  This is typically a 512 byte chunk
on classic filesystems but will be different on newer filesystems.
Also, optimizations of storing data in the inode itself, etc.  The
above result was on ext2.

Your result seems really unaccountable.  I can't explain it.  If it
would be possible for you to help by debugging in the code it would be
much appreciated.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]