Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
    
I'm not familiar with VirtualBox, but doing this on VMWare ESXi can take a long time to remove snapshots. A deleted a 6-month old snapshot the other day and it took about an hour. –  Mark Henderson May 3 '13 at 5:46
    
What do you think, should I ask it on StackOverflow instead? –  Andrey Regentov May 3 '13 at 9:12
    
No, not Stack overflow; it's for programming. Virtual box is probably a better fit for Super User –  Mark Henderson May 3 '13 at 9:17
    
Ok, if I find good answer there it will be doubled here. –  Andrey Regentov May 3 '13 at 9:44

2 Answers 2

up vote 6 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

Thank you everybody!

share|improve this answer

You could use the clonevm command and make a clone of the VM on an external or secondary drive. If you don't specify a snapshot and don't specify a mode then the current state configuration will be saved as the one and only state in the new VM. You then import the cloned VM into virtualbox.

The documentation is kind of confusing regarding the mode as it states "If machine is selected (the default), the current state of the VM without any snapshots is cloned." What this means is the cloned VM will not have the snapshot tree but it WILL merge all the snapshot VDIs into the base VDI (otherwise when you imported the new VM it wouldn't work).

For example, I had created a VM with two drives (C @ 50GB and D @ 250GB) and had about 30 snapshots where the data on drive D changed significantly between snapshots. My coworker needed a copy of the VM on his machine as well, but wasn't concerned about the snapshots. So I ran the following command:

VBoxManage.exe clonevm "D:\VirtualMachines\DevEnvironment\DevEnvironment.vbox" --basefolder "G:\CopyOfVM\" --options keepallmacs --options keepdisknames

Edit: Not sure if you have to give the full path to the VM as the docs say you just need to give a name (and I'm running come other commands so I cannot test right now). In this case that would just be: DevEnvironment

Note: No snapshot, mode or name specified so those all default. In this case "G" was an external HDD. You may not want those options. You especially should be careful with the second option (keepdisknames) in that, you'll have to remove the original VM before importing the clone.

In 4.2.10 (not sure about 3.2.14) you can delete intermediary snapshots between the current state and the first snapshot within the GUI and VBOX will automatically merge the differences between each snapshot. Sometimes you get errors if you ever did a restore and broke the "linear" tree, but you just have to delete any VDI in the Virtual Media Manager that is not attached to anything.

Hope this is helpful. Good Luck!

share|improve this answer
    
Thanks. Unfortunately, there is no clonevm in Virtualbox 3.2.14. And deleting intermediary snapshots is not faster and everything i wrote in question under VBoxManage snapshot delete. I found the solution and it surely is much much faster than deleting every intermediary snapshot. –  Andrey Regentov May 10 '13 at 5:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.