I know of 2 ways to clone a VirtualBox machine on a linux host, one is by using the VirtualBox gui and exporting and re-importing as appliance (in the file menu of VirtualBox).

The other is by cloning only the virtual disk container files:

VBoxManage clonevdi /mnt/md1/original/root-fs.vdi /mnt/md1/cloned/root-fs.vdi

(Taken from http://forums.virtualbox.org/viewtopic.php?p=853#p858 )

Edit: this does not seem to work for VDI files that are already part of ~/VirtualBox/VirtualBox.xml, I get an error message:

ERROR: Cannot register the hard disk '/mnt/md1/original/root-fs.vdi' with UUID {96a1462b-c30a-4911-a954-d9093122f083} because a hard disk '/mnt/md1/original/root-fs.vdi' with UUID {96a1462b-c30a-4911-a954-d9093122f083} already exists in the media registry ('/home/mit/.VirtualBox/VirtualBox.xml')

I would have to create a new VM afterwards and use the cloned virtual disk containers.

Is it also possible to clone a VM by copying the virtual disk contianer files and the config files using filesystem commands and do the rest by hand?

I'd have to manually edit the ~/VirtualBox/VirtualBox.xml and insert a new disk and a new machine:

Can I just make up UUIDs or how would this work?

I would very much prefer this hardcore method of doing things as it allows me to freely and rapdily backup, restore, move or clone machines. Or ist there a better way to do this?


You can change the UUID of a vdi using the command

VBoxManage internalcommands setvdiuuid disk.vdi

or if you are using VBox V4.x at least to 4.0.10

 VBoxManage internalcommands sethduuid disk.vdi

then use the GUI import the new 'unique' disk.

If you want to clone a particular VirtualBox machine then you are probably better off making an appliance of it and then using it. To make an appliance use the GUI Export Appliance feature or the vboxmanage export command. The resultant appliance can then be imported using the GUI Import Appliance feature or the vboxmanage import command.

  • +1 million if I could. Note, in my version (4.x) this is "sethduuid", not "setvdiuuid". – mpontillo Jul 11 '11 at 19:49
  • @Mike: Cheers - updated to reflect changes – Iain Jul 11 '11 at 20:29

Or you can edit the "Virtualbox.xml" setupfile with the right uuids for the machineid. Worked great for me moving a virtual machine from one host to another (both hosts being 64-bits linux, no idea if it had worked moving to e.g. windows or mac) see http://sickel.net/blogg/?p=1581 for details.

This works even if the vboxmanager on the original host for some reason can not be run.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.