[How-To] Reduce the size of your OS X VMware VMDK file

When running Mac OS X within a virtual machine inside of VMware for Windows, you may have noticed that the size of the virtual hard disk (VMDK) increases, even after you’ve removed some files. This is because VMware Workstation for Windows doesn’t handle HFS+ drives/partitions/operating systems properly. Fortunately, you can reclaim all of that space with a few easy steps.

For me, I use a 10.8.2 VM primarily for iMessage while I’m on my Windows machine. So, it will fill up with iMessage attachments over time.


Terminal action

The first thing that you’ll need to do happens within the OS X VM itself. Open up Terminal, and enter the following command:

cat /dev/zero >zero.fill; sleep 1; sync; sleep 1; /bin/rm -f zero.fill

This command “zeroes” out all of the free space in preparation for the next step.

Depending on how large your VMDK is, or if it’s on an HDD or SSD, it may take some time. My 150GB VMDK, that had roughly 30GB “used” (I know that I’ve deleted about 20GB of files since the last time I did this), took about 10 minutes to finish. You’ll notice it’s finished when it says that there’s no more free space left.

Time to compact!

Time to compact!

Shut your VM down, and head to its HDD settings. Under Utilities, use the Compact option.

It's like magic!

It’s like magic!

When it’s finished, you should notice that your VM is now smaller than before.

Source: Insanely Mac

Feel free to follow Brian and Gadget Unit on Twitter.