Having found many tutorials on cloning just the VDI, I played around a bit and managed to duplicate the entire VM. The following procedure worked fine for me (numerous times). I've done this using VirtualBox 2.0.2 (and 1.6.6) on a Win-XP Host, with an Ubuntu Guest (not that this should matter, as the steps should remain the same).
A caveat: My need was to create a number of initially identical new VMs, so I've never done this for an older VM that has already had snapshots taken. From what I've seen, the changes creating a snapshot create in the VM configuration file would make the following procedure more difficult.
Lets say you want to duplicate ("clone") your fully installed, configured and otherwise customized BaseLine VM, to a new VM called Other.
1) Clone the VDI:
While in the VDI directory, enter from the command line -
Code: Select all
VBoxManage clonevdi BaseLine.VDI Other.VDI
Doing this from the command line is fast and simple –
Code: Select all
VBoxManage createvm -register -name Other
3) Copy the existing VM configuration:
This is done by replacing the empty configuration file with the BaseLine configuration. While in the Machines directory, enter from the command line -
Code: Select all
del Other\Other.xml
copy BaseLine\BaseLine.xml Other\Other.xml
Using text-editor, make critical changes to two lines of the Other.xml file:
a) Changing the UUID and name: At the very beginning of the file, in the Machine field, change the value of uuid attribute to the UUID created above (be careful to replace only actual value, leaving the "{" and "}" around it). Also change the name value to "Other".
b)At the bottom of the file, completely remove the hard-disk description line HardDiskAttachment. If you don't do this, you will have two VMs referring to the same VDI, and VirtualBox won't let you use the Other VM, marking it inaccessible, because the VDI it uses is already in use.
5) Finish the job:
a) Using the GUI tool, open the Virtual disk Manager (under File menu), and Add the Other.VDI to the list.
b) Now configure the Other VM - Set the Hard-disk to point to the Other.VDI.
c) If your VM had network adapters, you'll need to go into their properties, and Generate a new MAC address.
That's it! Easier than Pie, if you ask me.
Of course you'll have to start-up your VM and make any additional internal changes such as IP address (if fixed) and hostname, or whatever more your specific Guest OS requires.
I'm a complete nube at this, so if there is an easier way, or if I made any gross mistakes, feel free to correct me. If this is inappropriate, or you would rather people didn't do it, feel free to remove it.