VirtualBox – Cloning a VM and Hard drive
Cloning a VirtualBox VM+Drive
Step 1) Clone a Disk
in ~/Library/VirtualBox/HardDisks
VBoxManage clonevdi <existing drive> <new drive>
Example
Command
VBoxManage clonevdi WinXP-IE7.vdi WinXP-IE6.vdi
Output
Clone hard disk created in format 'VDI'. UUID: 327deab6-c228-4fdc-93cd-004a45c4fece
Step 2) Create and register an empty VM
The important element here is the ‘register’.
in ~/Library/VirtualBox/Machines
VBoxManage createvm -register -name <new name>
Example
Command:
VBoxManage createvm -register -name WinXP-IE6
Output:
UUID: c43cfacd-8c5f-46ac-9f5a-c6f8d84b6f10 Settings file: '/Users/tflynn/Library/VirtualBox/Machines/WinXP-IE6/WinXP-IE6.xml'
3) Copy the existing setup into the new setup
in ~/Library/VirtualBox/Machines
Example
cp ./WinXP-IE7/WinXP-IE7.xml ./WinXP-IE6/WinXP-IE6.xml
4) Edit the new configuration file
a) Change the Machine Name and UUID
Example
<Machine uuid="{c43cfacd-8c5f-46ac-9f5a-c6f8d84b6f10}" name="WinXP-IE6" OSType="WindowsXP" lastStateChange="2009-06-25T19:29:04Z">
b) Remove the ‘existing’ hard disk
Example
Remove
<AttachedDevice type="HardDisk" port="0" device="0">
<Image uuid="{e3fb9c99-4c33-4c05-b26d-144c38404efa}"/>
</AttachedDevice>
5) Add the new hard disk as a resource
Command
GUI > File > Virtual Media Manager > Hard Disks > Add
Example
GUI > File > Virtual Media Manager > Hard Disks > Add
WinXP-IE6.vdi
6) Attach new disk to new VM.
GUI > [VM] > Settings > Storage > [Add]
Example:
GUI > [VM] > Settings > Storage > [Add] IDE Primary Master > WinXP-IE6.vdi
7) Stop and Restart Virtual Box
You’re done! Start the new VM.