Quickest way to merge all snapshots in VirtualBox?
I have vdi with quite a number of snapshots taken from it - say, 50 or 70 snapshots. I want to have one plain vdi with a current state. These snapshots take way too much disk space and are not needed as snapshots.
I know that if I call
VBoxManage clonehd thedisk.vdi thedisk-full.vdi
(50-70 times) VBoxManage clonehd {uuid-of-snapshot}.vdi thedisk-full.vdi --existing
I will get what I want. But it takes very very long time (more than 5 hours given my hardware and 16G initial disk size).
And, of course, I tried VBoxManage snapshot delete
and it is strange: doesn't work on stopped machine, can fail on running machine and when it fails once, it will fail all subsequent calls.
Is there a way to make plain vdi from a number of snapshots - quicker?
$ VBoxManage --version
3.2.14r75509
(asked it on ServerFault but decided this place is more appropriate for this question)
Solution 1:
Found the solution. It is as simple as the last step from the commands I wrote here. I.e.
VBoxManage clonehd fullpath/{uuid-of-last-snapshot}.vdi thedisk-full.vdi
So I should clonehd only the last snapshot, not every snapshot from the chain. And it is thousands percent faster.
The uuid can be found from VBoxManage list hdds | grep VmName | tail
In the GUI (on Windows), select the VM, select Snapshots from the top right, right click on the snapshot you want, select Clone..., and select Full Clone in the dialog.
Solution 2:
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:
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).
-
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'.
Delete the old VM (right-click on the VM and run the 'Remove...' command).