Saturday, May 23, 2009

How to duplicate / clone virtual machine on VirtualBox

To get around the limitations of VirtualBox's linear snapshots, what I decided to do was just clone the machine itself. Here's how to do it.

VirtualBox doesn't really allow you to clone a machine. However, it does have a feature to clone a disk, which is pretty much the same thing. You can then easily use the disk to build the same machine.

1) You need to merge the snapshots into the parent vdi file. To do this, turn off the machine. Open the Snapshot page of VirtualBox. If you want to include the current state, make a sapshot for it. Then, for each snapshot, select "Discard" snapshot. This will merge the changes into the parent disk.

2) Use VBoxManage.exe's clonevdi feature on the disk you want to duplicate

C:\Program Files\Sun\xVM VirtualBox>VBoxManage.exe clonevdi "C:\Users\Marky\.VirtualBox\HardDisks\XP.vdi" "C:\Users\Marky\.VirtualBox\HardDisks\XPvideo.vdi"
VirtualBox Command Line Management Interface Version 2.2.2
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Clone hard disk created in format 'VDI'. UUID: 8d143541-123e-4de0-ba2f-8f72b197a8f2

3) In VirtualBox, create a new Virtual machine and point to the cloned hard disk.

3) Start it up.
That's it. You're done!



Anonymous said...

What if the disk that you are cloning has snapshots that have been taken since the time the system was installed? I find that cloning the drive is not adequate since the subsequent snapshots are not included in the cloned vm.

Anonymous said...

I thought that the point was to clone the virtual machine, not just it's hard drive(s). How do you clone the VM configuration?

Ergec Senturk said...

thanks, it worked like a charm :)

Anonymous said...

many many thanks !

vichu said...

really great stuff..thank you for your post