Macos – Why do Finder and du report different file size

dufindergeektoolmacosvmware-fusion

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?

Best Answer

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)

Related Question