Friday, September 10, 2010

Cloning a VM with mutiple snapshots

As of 3.0.8 (or before) the VBoxManage clonehd command can clone any snapshot of a hard disk or clone the Current State of a hard disk. The resulting VDI file is flattened (it does not have any other snapshots attached).
You need to find the UUID of the Current State image file, or of the Snapshot image file (NOT the UUID of the snapshot!)
To clonehd the Current State of a disk:

* Open the Virtual Media Manager (Menu: File>Virtual Media Manager).
* Navigate to the hard disk you want to clone and fully expand the tree (use * key on numeric keypad).
* Find the {hexUUID}.vdi file that is attached to the VM you want to clone the Current State of.
It will be (one of) the leaf files at the end of a branch.
When you select it, the 'Attached to:' text at the bottom of the window will say:
'Attached to: ', without any (snaphot name) in brackets after it.
* Click the filename to the right of the 'Location:' displayed at the bottom of the window.
* Ctrl+C / Copy to copy the text to the clipboard, which will be something like:
(path){b6441469-5ccb-418c-8fdd-73c5e1a17314}.vdi
* Ctrl+V / Paste and extract the hexUUID value (removing the {} brackets) and run clonehd to clone it!
CODE: C:> VBoxManage clonehd b6441469-5ccb-418c-8fdd-73c5e1a17314 CloneDisk.vdi

To clonehd a snapshot of a disk:

* Find the {hexUUID}.vdi file that is attached to the VM (and Snapshot) you want to clone.
* It will be one of the files along a branch.
When you select it, the 'Attached to:' text at the bottom of the window will say:
'Attached to: ()', with (snaphot name) in brackets after it.
* Follow the instructions above for cloning the current state of a disk.



Reference:

This thread