Since I am now testing VirtualBox performance, I need to clone existing guest image for multi-testing. This mini-HOWTO will guide you though the procedure for cloning a guest storage file for a new guest, under MS Windows host.
When following the official guideline and document, using VBoxManage clonehd command for disk clone, the result image is ALWAYS not functioning. Finally I figure out that a non-documented internal command is required: VBoxManage internalcommands sethduuid.
This bug is documented in VirtualBox bug ticket system #2813.
Within this artical, I am using the following system setup:
- VirtualBox: v2.1.0
- Host: MS Windows Vista Home Basic
- Guest: Debian Lenny
Official procedure for cloning disk image (not function on MS Windows host)
Cloning an existing disk image for VirtualBox is much more than a simple copy command: it is because VirtualBox assigns a unique identity number (UUID) to each disk image, which also stored inside the image. VirtualBox will refuse to work with two image that use the same number. You need some extra handling.
According to official document, what you need is the console command VBoxManage clonehd, e.g. (host with MS Windows):
"C:\Program Files\Sun\xVM VirtualBox\VBoxManage.exe" clonehd hda.vdi hdb.vdior (host with Linux):
VBoxManage clonehd hda.vdi hdb.vdi
Therefore VirtualBox will copy your disk image, assign a new UUID for it, and import to its virtual media manager. You can now use it for your new guest system.
Alternative non-documented solution
As now you understand how the vboxmanage clonehd work around, what we needed is a new-and-unique UUID for our cloned disk image. There is a non-documented internal command which target for this procedure: VBoxManage.exe internalcommands sethduuid.
So what you needed for are:
- (Optional) Shutdown your target guest before disk clone.
- Manually copy the existing disk image, e.g.
copy hda.vdi hdb.vdi - Set a new UUID for the cloned disk, e.g.
"C:\Program Files\Sun\xVM VirtualBox\VBoxManage.exe" internalcommands sethduuid hdb.vdi - Manually add this newly cloned disk image though VirtualBox "Virtual Media Manager".
- Create a new guest profile as old system, and point the primary harddisk to your newly cloned disk image.


















Unless you used snapshots
in which case you are totally out of luck.. well, I mean, unless you want to start messing with the UUID of the snapshot files and the XML that refers to them. I'm tempted, but it does cause the uncomfortable sensation that you're messing with things you shouldn't be.
You cannot clone the
You cannot clone the snapshots but you can consolidate the snapshots into the base and clone that. It's a pain, but it works.
More details here: http://geek.co.il/wp/2009/03/18/cloning-virtualbox-vm-snapshots
Thanks
Thanks for this helpfull tip, I am testing out HA using VirtualBox
YouTube video showing the process...
I've created a video walking through this process (on a Mac, but the same process would work on a PC, just using different file locations) here:
http://joshprowse.com/virtualbox-how-to-clone-copyduplicate-a-virtu
Hope this helps somebody!
thanks
thanks, I don't care what others say. This does work for me :)
Post new comment