<div dir="ltr"><div>"apparent size" is the "ls -l" size of the file. <br><br>which is the "rght" size for you to use is dependent on what you're trying to do. <br><br>Apparent size is nearly useless for managing disks -- which is usually what you use du for. <br>
<br>Say my disk has blocks that are 1KB. If I have a file with the nothing but the letter 'A' in it, that will have an apparent size of 1 byte. But because the smallest block size on my disk is 1KB, that 1 byte file will USE 1 KB of disk space no matter what because the physical data has to be recorded in a block and that block will then be marked 'used.'<br>
<br>As an aside, imho, the 'apparent size' option is really a terrible option to include in 'du' and is a violation of the unix philosophy because it has explicitly NOTHING to do with disk management. But that's neither here nor there. <br>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 4, 2014 at 2:29 PM, Mike Miller <span dir="ltr"><<a href="mailto:mbmiller+l@gmail.com" target="_blank">mbmiller+l@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Tue, 1 Apr 2014, Mike Miller wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, 1 Apr 2014, Ben wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-h will always be different from the actual disk usage, you might also want to play around with -B option too.<br>
</blockquote>
<br>
I've done that.  Using --si -sB GB gives the same result as --si -sh. Did you think that they would be different?<br>
</blockquote>
<br></div>
Thanks for the suggestions.  Now I have answers (below).<br>
<br>
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...<br>
<br>
du -s --si dir<br>
du -sB GB dir<br>
<br>
...and so should these two commands:<br>
<br>
du -sh dir<br>
du -sB G dir<br>
<br>
The first pair will report 1000*1000*1000 bytes and the second will report 1024*1024*1024 bytes.<div class=""><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What happens when you use --apparent-size option.<br>
--apparent-size<br>
  print apparent sizes,  rather  than  disk  usage;  although the<br>
  apparent  size is usually smaller, it may be larger due to holes<br>
  in ('sparse') files, internal  fragmentation,  indirect blocks,<br>
  and the like<br>
</blockquote>
<br>
I want to try that, but I'm having this problem right now:<br>
<br>
$ ls /project/guanwh<br>
ls: cannot access /project/guanwh: Stale file handle<br>
</blockquote>
<br></div>
Yep, you nailed it.  That was the issue.  If I use --apparent-size, the results are consistent.  According to supercomputing staff:<br>
<br>
"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.<br>
<br>
"when the apparent size is different from the reported size it is not a bug in du but rather a feature of the filesystem :)"<br>
<br>
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:<br>

<br>
$ du -s --si dir<br>
162G    dir<br>
<br>
$ du -s --si --apparent-size dir<br>
143G    dir<br>
<br>
$ du -sb dir<br>
142038799951    dir<br>
<br>
$ wc -c dir/* | tail -1<br>
142037349967 total<br>
<br>
<br>
One thing to note:  It seems that du always rounds up.  So if 1.1 GB are used, du will report 2 GB.<div class="HOEnZb"><div class="h5"><br>
<br>
Mike<br>
______________________________<u></u>_________________<br>
TCLUG Mailing List - Minneapolis/St. Paul, Minnesota<br>
<a href="mailto:tclug-list@mn-linux.org" target="_blank">tclug-list@mn-linux.org</a><br>
<a href="http://mailman.mn-linux.org/mailman/listinfo/tclug-list" target="_blank">http://mailman.mn-linux.org/<u></u>mailman/listinfo/tclug-list</a><br>
</div></div></blockquote></div><br></div>