On Tue, 1 Apr 2014, Mike Miller wrote:
> On Tue, 1 Apr 2014, Ben wrote:
>
>> -h will always be different from the actual disk usage, you might also 
>> want to play around with -B option too.
>
> I've done that.  Using --si -sB GB gives the same result as --si -sh. 
> Did you think that they would be different?
Thanks for the suggestions.  Now I have answers (below).
I was misusing the --si option there.  It should be used *instead* of -h, 
not in conjunction with it.  These two commands should do the same thing 
when the volume in "dir" is in the multi-gigabyte range...
du -s --si dir
du -sB GB dir
...and so should these two commands:
du -sh dir
du -sB G dir
The first pair will report 1000*1000*1000 bytes and the second will report 
1024*1024*1024 bytes.
>> What happens when you use --apparent-size option.
>> --apparent-size
>>   print apparent sizes,  rather  than  disk  usage;  although the
>>   apparent  size is usually smaller, it may be larger due to holes
>>   in ('sparse') files, internal  fragmentation,  indirect blocks,
>>   and the like
>
> I want to try that, but I'm having this problem right now:
>
> $ ls /project/guanwh
> ls: cannot access /project/guanwh: Stale file handle
Yep, you nailed it.  That was the issue.  If I use --apparent-size, the 
results are consistent.  According to supercomputing staff:
"it is not a bug, -b is implies --apparent-size, so to compare its output 
to -sm/sh you have to include --apparent-size with -sm/-sh as well.
"when the apparent size is different from the reported size it is not a 
bug in du but rather a feature of the filesystem :)"
Now I just have to figure out which is the right size for me -- apparent 
or reported.  I guess apparent sizes are the real file sizes.  In this 
example "dir" has about 10,000 files in it with about half being 5 KB and 
have about 29 MB:
$ du -s --si dir
162G    dir
$ du -s --si --apparent-size dir
143G    dir
$ du -sb dir
142038799951    dir
$ wc -c dir/* | tail -1
142037349967 total
One thing to note:  It seems that du always rounds up.  So if 1.1 GB are 
used, du will report 2 GB.
Mike