Saturday, February 5, 2011

Cloning a VirtualBox vdi-file

OK,
this will be a short one. I did this with VirtualBox 4.0 on a Windows 7 64bit machine.
I had and still have a vdi-file which is simply a virtual disk that contains a virtual operating system. For me this is a virtual Windows XP SP3. I have to point out that my virtual machine did not contain any snapshots. So I don't know what happens if you try this with a virtual machine that contains one or more snapshots.
To try different software in a kind of safe environment I use virtual machines a lot. But one can not simply copy a virtual disk to another folder and use it as another virtual system because VirtualBox internaly registers the vdi-files with its UUID which is unique for every vdi-file. So you can not use two virtual systems with the same UUID with VirtualBox. The solution is to change the UUID of the copied vdi-file the following way.
First I copied the original "winxp.vdi" to "winxp-clone.vdi". Then I opened a command prompt and changed to the location "D:\Virtualdisks" where my virtual disks are stored. There I issued the command:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands sethduuid "d:\Virtualdisks\winxp-clone.vdi"
I gave the full path to be sure that everything behaves as expected. And after generating a new virtual system in VirtualBox with the same settings as the original one, I could assign the cloned vdi-file to it.

cheers