September 4, 2009

Cloning a Virtual Harddrive - VirtualBox

I use VirtualBox to allow me to run multiple OS on one machine. It is a powerful virtualization product, with rich features. It is an Open Source Software. It runs on Windows, and supports all of Windows OS'es, Linux, Solaris, OpenBSD, just to name a few.

One feature that I use a lot is the cloning feature. Here's what I do.
1. Create a new virtual machine
2. Create a new virtual hard drive ( this will be my template )
3. Install the OS ( Windows XP Pro, for example )
4. Update the OS with the latest patches, etc.
5. Install any additional software necessary

Once complete, I open up a command prompt and navigate to the VirtualBox folder. I type the following command and then hit Enter:

VBoxManage clonehd "sourceTemplate.vdi" "newCloneDisk.vdi"

You will replace the VDI names in quotes with the path and filename where the source is located and where you want it to clone to. It will do it's thing and will return to the command prompt once it completes.

I then return to VirtualBox and do the following steps:
1. Create a new virtual machine
2. Here, I would select an existing virtual harddisk, in this case, I would select the newly cloned VDI.

I also found that there is another way of cloning. I have not yet tried this out myself ( I will try this the next time I need to clone ) but here it is anyway.

First copy the VDI file ( or your template ) using Windows Explorer. Name the copy to what you want. Open up a command prompt and navigate to the VirtualBox folder. Type:

VBoxManage internalcommands setvdiuuid "newCloneDisk.vdi"

You will replace the VDI names in quotes with the path and filename where you want the new VDI to clone to.

I hope this helps. If someone has already used the second option, please let me know how you like it, if you ran into any issues, etc. Thanks.

UPDATE: The second option works and it is a whole lot faster to complete.

No comments: