Cloning HDD In VirtualBox

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 C:\Program Files\Oracle\VirtualBox
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.
For example:
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.

VBoxManage not working

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog. Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise. Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school. View all posts by Danny → This entry was posted in Virtualization and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *.

All comments must go through an approval and anti-spam process before appearing on the website. Please be patience and do not re-submit your comment if it does not appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.