Virtualbox, merging snapshots and base disk

I have a virtual machine with about 30 snapshots in branches. The current development path is 22 snapshots plus the base disk. The amount of files is seemingly having an impact now on IO and the dev laptop I'm using (don't know if it is host disk performance issues with the 140GB total size over a lot of fragments, or just the fact that it is hitting sectors distributed across a lot of files).

I would like to merge the current development branch of snapshots together with the base disk, but I am unsure if the following command would produce the correct outcome. I am not able to boot this disk after the procedure completes (5-6 hours).

vboxmanage clonehd "C:\VPC-Storage\.VirtualBox\Machines\CRM\Snapshots\{245b27ac-e658-470a-b978-8e62137c33b1}.vhd" "E:\crm-20100624.vhd" --format VHD --type normal

Could anyone confirm if this is the correct approach or not?


What you want to do is from the snapshots dialog, select your parent snapshot that you want to merge all snapshots afterwards to a single VDI.

From your description it sounds like this is the root of the tree.

Right click and select 'Delete Snapshot'.

This will do what you want --- it will merge all the changes from all child snapshots into a single VDI.

Additionally - cloning the disk image that is in the latest snapshot - will also merge the differencing disk with its parent (and its parent, so on, until you get to a 'normal' hard disk type).

I suspect that 'deleting a snapshot' runs the clonehd command.

Check your VM settings (specifically IO APIC enabled/disabled) and make sure they match.


If you only want to keep a single snaphot, make it your current state & then export the VM & re-import it. Exported appliances don't retain their snapshot history.

Or you could use this vboxmerge.py script to handle the merging for you. Given the number of snapshots you have, I would expect the export/import cycle to be quicker.


Here's a technique (tested on VirtualBox 4.3.4) that uses the 'Clone' command to merge and compact all the snapshots to a new VM containing a single VDI file:

  1. Rename the VM so you can reuse its current name for cloned VM (you can change the VM name from the 'Basic' tab of the 'General' settings).

  2. Right-click on the VM and run the 'Clone...' command:

    • Set the name to the VM's original name.
    • Accept the remaining defaults i.e. Clone type: 'Full clone'; Snapshots: 'Current machine state'.
  3. Delete the old VM (right-click on the VM and run the 'Remove...' command).