Wednesday, July 16, 2014

Compacting VMware Disks and Avoiding Snapshots

I use VMware Fusion to test my products on different versions of Mac OS X. This has worked very well over the years. Every time I installed a new version of the OS, I would make a snapshot, and I ended up with a tree of them. At first, snapshots were relatively space-efficient. If space got tight, I would delete all but the leaf snapshots, i.e. Mac OS X 10.7.5, 10.8.5, and the current stable and pre-release versions of 10.9 and 10.10.

I thought this was the smart way of doing things, using snapshots to let VMware efficiently manage the storage and share the bits that hadn’t changed among multiple OS versions. Unfortunately, I got to the point where VMware was using 108 GB of disk space to store only 27 GB of data. My MacBook Pro’s SSD was almost full. I thought it would be a simple matter to compact the virtual disk and reclaim the unused space. However, after some research, it looks to me like there is no good way to do this.

The General tab in the VMware settings showed that none of the disk space in my virtual machine was reclaimable. I found a post in the VMware forums that describes how to compact a virtual machine, but the first step is to delete all of your snapshots. If I were going to do that, I might as well start a new virtual machine!

Surprisingly, there does not seem to be any way to export a snapshot as a new virtual machine. I think the best I could do is to boot from each snapshot and clone the disk to a drive or disk image outside of VMware. Unfortunately, there also does not seem to be a way to create a new virtual machine from an existing drive (except that of a Windows PC). There are some command-line tools for creating a new virtual disk from a mounted volume, but I kept getting errors like “Failed to convert disk: You do not have access rights to this file (0xd).” Since the virtual machines are just clean OS installations, I decided it would be easier to just built new virtual machines by reinstalling each OS version.

Because snapshots don’t work with compaction, I decided to create wholly separate virtual machines for each major OS version. If necessary, I can copy the .vmwarevm packages in the Finder to manage my own heavyweight snapshots.

It is then possible to compact the virtual disks:

  1. From the Virtual Machine menu, choose Install VMware Tools.

  2. A disk will mount in the virtual machine. Run the installer that’s on it.

  3. In Terminal (in the virtual machine) enter the command:

    sudo /Library/Application\ Support/VMware\ Tools/vmware-tools-cli disk shrink /
  4. This will take a while, and the OS will complain about running out of disk space, but eventually it will finish and reboot.

After installing Mac OS X 10.7 and using the Mac App Store to update to 10.7.5, my virtual machine was using 18.2 GB. After the above procedure, it shrunk to 9.8 GB.

For another virtual machine, I installed Mac OS X 10.8 and updated to 10.8.5 with the combo updater. This brought it to 15.4 GB, which shrunk to 7.1 GB.

I have not yet built my 10.9 and 10.10 virtual machines, but it seems clear that the total of four independent ones will not be much more than the 27 GB with snapshots for each major version. Duplicating a virtual machine package in the Finder is actually not much slower than saving a snapshot. And I should no longer have problems with virtual machine bloat, since virtual machines without snapshots can be compacted. So I now believe that there is no compelling reason to use snapshots the way I had been using them. Using separate virtual machines also means that I can run multiple instances simultaneously.

Update (2014-08-18): For reasons I don’t understand, VMware started reporting the error “The parent virtual disk has been modified since the child was created,” even though I thought I had made fully independent copies of my virtual machines via the Finder. I am now using the Create Full Clone command, which hopefully will work better.

8 Comments RSS · Twitter


@michael Thanks for sharing that info. That really limits the usefulness of snapshots, to just short-term temporary setups.

I have another more general question for you, as I need to set up a similar workflow: any particular reason to choose VMWare over Parallels? I know you typically look into things quite carefully, so I was wondering if you had investigated the option and if so, how you decided between the two.


@charles I plan to keep one long-term snapshot in each VM of its clean state. So then I can install my app, do some tests, and revert. Otherwise, I plan to only use them for temporary setups, e.g. while working through a particular case with a customer.

I used Parallels before VMware had a Mac version, and it was fine. When VMware came out, I switched to it because it was faster. From what I’ve heard, Parallels is very good now, but I don’t like their business practices.


Felix Schwarz suggests that another way I could have rebuilt my snapshots as separate virtual machines is to make multiple copies of the big virtual machine in the Finder. For each copy, restore one (different) snapshot, delete all the snapshots, and then compact. This would temporarily use a lot of disk space, but it would not require rebuilding the contents of each virtual machine.


You can also "go to" a particular snapshot, then clone the VM from there. This works for me in other VMware products. Just make sure you have a snap of where you were.


@Bob I have not been able to find any “clone” feature in VMware Fusion Tech Preview. I found what looks like a description of this feature, but it’s not clear to me how it differs from copying the virtual machine in the Finder. Does it not copy the other snapshots?


@VMwareFusion suggested that I use the “Clean Up Virtual Machine” button. As far as I can recall, that button has always been disabled for me, and the graph below it has always showed that no space was reclaimable.


[…] Copy and open a Mac OS X 10.11 VM, drag the installer app to its Finder, then run installer. (Then, optionally, delete the installer, empty the trash, and compact.) […]


[…] Fusion 8.5.8 works with macOS 10.13, but the compaction feature fails. Apparently version 10 will be released soon. [Update (2017-09-27): VMware Fusion 10 is now […]

Leave a Comment