Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

(asked it on ServerFault but decided this place is more appropriate for this question)

share|improve this question
The command your using is the command you want to use there isn't a faster way. – Ramhound May 3 '13 at 10:51
What about exporting the whole VM? Will its vdi contain what i want? – Andrey Regentov May 3 '13 at 11:16
You should try it. In the end any other method is still going to take awhile because of the size of the Virtual Machine. – Ramhound May 3 '13 at 11:25
up vote 29 down vote accepted

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.

share|improve this answer
thx but it doesn't work on my setup, it says the image would already exist. Did you forget the --existing? – Andy Apr 15 '14 at 15:07
if you already have thedisk-full.vdi file on disk then please first change the name in command to something like thedisk-full-new.vdi. – Andrey Regentov Apr 16 '14 at 2:36
The fullpath needs to be the one that is registered in VirtualBox, of course. Symbolic links wont work, since VBox needs to look up all Snapshots – Andy Oct 26 '14 at 20:47
not sure what does the tail do, do you mean "tail -1"? – eckes Oct 22 '15 at 15:12

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).

share|improve this answer

You can try to export to OVF and then import back the generated file.

As explained here:

OVF cannot describe snapshots that were taken for a virtual machine. As a result, when you export a virtual machine that has snapshots, only the current state of the machine will be exported, and the disk images in the export will have a "flattened" state identical to the current state of the virtual machine.

As result you will have a cloned VM with the current state without other snapshots.

share|improve this answer
I ask about vdis because cannot export machine - it was broken (inaccessible state after host reboot), and all that I had was the bunch of VDIs - disk and about fifty snapshots. – Andrey Regentov May 10 '13 at 5:03

That operation means reading and writing very large files in the same physical disk. The only way you can speed that up is to put those files in different disks changing the paths in your VBoxManage command. If the machine has only one disk, you could use an external USB drive or even a disk in another machine via a network share (depending on the speed of your network)

share|improve this answer
Typically network is orders of magnitude slower than internal HDD interface, so this probably wouldn't make the process faster. – Andrey Regentov May 8 '13 at 10:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .