VMware Fusion: Shrinking the disk image of an OS X guest vm.

Reducing the size of a guest OS X vm’s vmdk file(s) requires a few steps.  For a Windows OS guest VM, there is a tools utility with a simple GUI.  Unfortunately there is not an equivalent tool for the Mac guest VM (even when vmtools are installed).

This technique was tested and confirmed on OS X 10.7.4 using VMware Fusion 4.1.3  It assumes your guest vm’s disk is not pre-allocated, and the vm does not have any snapshots. The host machine is a MacBook Air 13″ 2012 with the virtual disk images stored on an external drive over USB 3.

Space constraints on the Macbook Air are the primary reason I’m shrinking these disk images.  Saving disk space consumed by backups is the second reason.

1) Prepare the disk image for shrinking by using the guest vm’s Disk Utility.app to “Erase Free Space” (the simple, fast zero’ing will suffice).  For a disk image using 15 to 20GB, this may take five to ten minutes. When complete, shut down the vm and close the VMware Fusion app.

2) Using Finder, confirm the location of your guest vm’s vmdk files.

3) Open Terminal and type /Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -k, followed with a space and the path to your VM’s disk image.  The “\” is necessary to tell Terminal about the space between VMware and Fusion.

* As an alternative to typing the entire command with parameters, you may find it easier to “build” the command in Terminal using these steps:

  • Open Terminal
  • CD to “/Applications/VMware\ Fusion.app/Contents/Library/” (hint: use TAB completion with the CD command)
  • and then type “./vmware-vdiskmanager -k”
  • and then add the path to your virtual disk by locating the file in Finder and dragging it into Terminal. Terminal will then append the file’s path to the command, potentially saving you a lot typing.  This is

If you’ve successfully entered the command, Terminal will display “ Shrink: xx% done.” until the operation is complete (about 10 minutes for a 15GB disk image stored on an external drive).

My results:

  • VM #1 before: 13.5GB zipped to 10.9GB, after: 6.9GB zipped to a 4.9GB archive
  • VM #2 before: 16.7GB zipped to 12GB, after: 11.4GB zipped to a 7.1GB archive
  • Total physical disk savings of ~24GB for two working VMs and zipped archives.
Advertisements

3 thoughts on “VMware Fusion: Shrinking the disk image of an OS X guest vm.

  1. FYI: Don’t skip the step of using the “Disk Utility.app” to erase free space. The VMware disk shrink process will still run, but it won’t accomplish anything. I verified this by “testing” with a couple OS X Mountain Lion Server VMs yesterday.

    OK, actually, I verified it by forgetting that step and having to start over when the shrink process didn’t recover any space.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s