A common use of Virtual Machines is to test and run stuff till they are trashed. The magic is that each VM can be brought back up in no time with combination of save points (A.K.A Snapshots in VirtualBox) or easily clone and bring up multiple VM images to have two or more machines with the exact same configuration and state.
In VirtualBox however this is not easy to do. There is no GUI option to clone or copy a snapshot or virtual hard drive in VDI format.
A simple copy and pasting of the .vdi file DOES NOT WORK!
Alas command line to the rescue! Using VBoxManage command it can clone a VDI file and can be easily added to the Virtual Media Manager and to be used in place or in another VM. As long as the setup is similar to the original VM it should work.
First thing I had to do was add VBoxMange.exe to the Windows path. To do this locate the VirtualBox install directory. By default this is installed to
Copy the path to clipboard and open up System Properties: Right Click My Computer > Properties > Advanced system settings
Go to the Advanced tab and click on Environment Variables… button. A new window should pop up. In the System variables list, find, select and press Edit… button for a variable called Path. Append a semi-colon and then paste / type the path to the VirtualBox install directory e.g
C:\Program Files\Oracle\VirtualBox Click OK to all opened windows to save and exit.
Open a command prompt
Start Menu > Run Type
cmd and click the OK button. The familiar DOS looking window appears. Navigate to where the .vdi file to be cloned and run the following command:
VBoxManage clonevdi "[name of vdi].vdi" "[name of new vdi].vdi"
Replace [name of vdi].vdi with the VDI file name of the original file and [name of new vdi].vdi with the new file name.
VBoxManage clonevdi "Linux2.6.vdi" "TestLinux2.6.vdi"
Press enter to execute the command and wait for it to complete the copy.
When it finishes go back / start up VirtualBox and go to the media manager File > Virtual Media Manager and select the Hard Disks tab. Click the Add button and locate the cloned .vdi file. All that’s left now is to create a new VM with similar settings to the previous VM e.g if it’s a Windows XP ensure it is set to Windows XP in the new VM and select the new Hard drive in the existing drive drop down box.