Reduce size of guest vmdk disks with VMware Fusion 4.1.3 on OS X 10.8

When running multiple VMs, and keeping backup copies of various configs, a considerable amount of disk space can be used quickly.  The following steps have been confirmed to reduce disk usage for several virtual machine guest operating systems.

  • Oracle Linux R6 U3 64-bit
  • centOS 6.3 64-bit
  • Ubuntu 12.04 LPS 64-bit
  • openSUSE 12.1 64-bit
  • Mac OS X (multiple versions)

Oracle Linux R6 U3 and CentOS 6.3:  *these steps utilize a desktop environment and VMtools.

  1. remove any unneeded apps/packages, files, etc and empty the trash.
  2. clean up the YUM package files with (terminal commands as root):
    1. yum clean packages
    2. yum clean metadata
    3. yum clean dbcache
    4. (or) yum clean all
  3. at the command line, type “vmware-toolbox” to launch the VMware Tools GUI within the guest VM.  This is equivalent to the GUI available within Windows guests.
  4. Select the drive (partition) to Shrink.  1st the utility will prepare the drive for the shrink process and then a final dialog box will be presented to begin the shrink drive operation.

Ubuntu 12.04 LPS:  same as described for centOS and Oracle Linux, except the YUM commands are replaced with:

    1. sudo apt-get autoclean
    2. (or) sudo apt-get clean
    3. (0r) sudo apt-get autoremove

*note: Ubuntu 12.04 utilizes the Ubuntu Software Center for GUI application management (and has the annoying characteristic of only working with one selection at a time); installing the “Synaptic” package manager provides a more traditional Linux package manager.

openSUSE 12.1:  same as described for centOS and Oracle Linux, except YAST handles the package and cache cleanups (instead of yum or apt-get).  Options are available within the YAST GUI.

OS X:  10.6 Snow Leopard, 10.7 Lion, and 10.8 Mountain Lion (including servers).

  1. remove any unneeded apps, files, etc and empty the trash.
  2. using Finder, navigate to the following folders and remove unneeded fonts and dictionary files for languages you’re certain you won’t need for this VM.  Sort the folder contents by size and select the largest.  You can verify font files by opening them in the “font book” app to preview.
    1. /System/Library/Fonts/
    2. /Library/Dictionaries/
    3. /Library/Fonts/
    4. note: sometimes the system will state a font is in use and need a restart before allowing all of the deleted fonts to be emptied from the trash.
  3.  use the utility Monolingualto remove unneeded Architectures, Input Types, and Languages from OS X and installed application packages.
    1. If you know you have an app which needs to be excluded, use the Monolingual “Preference” to add the app’s location to a list of excluded directories.
    2. in the main app, use the “Languages” tab to select which languages to remove (be sure to scroll the entire list and de-select any you wish to keep).  On a fresh install of OS X 10.8 Mountain Lion, selecting all but English, French, and Spanish removed about 1.6GB
    3. use the “Input Menu” tab to select what to remove.
    4. use the “Architectures” tab to select what to remove.
    5. note: Monolingual only removes the items in the visible tab; if you desire to remove items from all three tabs, you’ll need to run it three times.
  4. use the disk utility app (within the VM) to erase free space on the disk.
  5. close the VM and exit VMware Fusion
  6. use the vmware-vdiskmanager utility to shrink the VMDK.
    1. open Finder, browse to the stored VM, right click and show package contents, locate the file “your-vm-name-here.vmdk”.
    2. open Terminal and CD to “/Applications/VMware\ Fusion/Contents/Library/”
    3. type “./vmware-vdiskmanager -k “
    4. drag the VMDK file from Finder to Terminal (this will append the file path and name to the command.
    5. In terminal, enter the command to shrink the vmdk.

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 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\ -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\” (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.