Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a geektool 3 script to show the size of a particular VMware Fusion virtual machine. Such .vmwarevm "file" is really a packaged directory.

Get Info in Finder says the file is "52.91 GB". I run the following du command to get the file size:

> du -hs ~/Documents/Virtual\ Machines.localized/MY-PRECIOUS-7.vmwarevm | awk '{print $1}'

This du -hs command returns the file size as "49G". What accounts for the difference from what Finder reports?

Alternatively, I have tried replacing the -s option with the -d option like so:

du -hd ~/Documents/Virtual\ Machines.localized/MY-PRECIOUS-7.vmwarevm | awk '{print $1}'

This du -hd command returns the file size as "59G". What accounts for the difference between Finder, du -hd, and du -hs?

Also, this du -hd command produces no output in geektool 3. What gives?

share|improve this question
up vote 5 down vote accepted

Not an Mac OS X user but I read somewhere that Finder uses base-10 nowadays.

Could the difference be that du still uses base-2?

49.0 GiB * (1024^3 bytes / GB) = 52,613,349,376 bytes = 52.6 GB

(the small difference is because du is rounding to the nearest GB)

share|improve this answer
The base-2 version would surely be smaller, though? – Phoshi Mar 28 '10 at 15:28
@Phoshi - finder says 52.91, du says 49 – Nifle Mar 28 '10 at 15:44
Oh, right you are. I misread that second "59G". – Phoshi Mar 28 '10 at 15:59
Does anyone know how to write a script that converts du output to base 10? – flipdoubt Mar 28 '10 at 20:51

Also note that "du" returns the actual disk space used, whereas other tools will return the allocated space. Where you have sparse files these 2 values can be quite different - I have a file that has 2 TB allocated to it but it is only occupying about 200 MB of disk space.

share|improve this answer
What command-line tool that displays allocated space in OS X? – flipdoubt Mar 28 '10 at 20:22
ls will (as covered by Stephen). – Cry Havok Mar 29 '10 at 6:05

Nifle is correct. du returns base-2, Finder returns base-10, and 49GiB ≈ 52.91GB

The -d argument requires you to specify a depth. From experimenting just now, it appears if you give something besides a number for depth, it eats the argument you specified and behaves as if you did -d 0. The 59G you're getting is the size of the current directory, not the size of the vmwarevm file.

Here is the experiment I ran:

[~]$ ls -d Code

[~]$ du -h -s Code
8.3M    Code

[~]$ du -h -d 0 Code
8.3M    Code

[~]$ du -h -d Code
 38G    .           <-- this is the size of ~/

[~]$ du -h -d 0
 38G    .

You might want to read the Mac OS X du(1) manpage for more information.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.