Clone and move virtual machines in VirtualBox
It describes cloning and moving virtual machines in VirtualBox.
What you need
- VirtualBox installed (the host platform doesn’t matter)
- A running virtual machine
- The ability to move the clone from one machine to another (shared drive, external drive, disk, etc.)
Cloning a virtual machine
Step 1: Close the virtual machine
You cannot pause the machine that is going to be cloned and then clone it — the machine must be turned off.
Step 2: Start the cloning process
Select the virtual machine you want to clone in the left pane of the VirtualBox main window. Click the Snapshots tab (Figure A) and then click the small sheep icon.
Figure A
A Ubuntu 12.04 virtual machine with no snapshots taken.
The wizard that opens is a simple two-step process. The first step requires you to give the clone a name; you must give this clone a different name than the source virtual machine. By default, VirtualBox will append “clone” at the end of the name of the source virtual machine. You can keep this, and it should work fine. The second phase of the wizard asks the type of clone you want to create (Figure B). You will want to create a full clone, since our goal is to move this virtual machine to a new host.
Figure B
Read carefully the difference between full and linked clones.
Step 3: Locate and move the clone
You will be looking for a .vdi file. The location of this file will depend upon the host platform. On my Linux host, the file will be found in ~/VirtualBox VMs. Within that directory, you will find sub-directories of all your virtual machines. Within the virtual machine directory in question, you will find the .vdi file of the cloned virtual machines — that is, the file that must be moved to the new host. Copy that file to an external or shared drive and then copy it onto the new host (the location doesn’t matter).
Step 4: Create a new virtual machine
The process of creating the new virtual machine will be the same as if you were creating a standard virtual machine until you get to the Virtual Hard Disk creation screen (Figure C). You will select Use Existing Hard Disk, click the folder icon, navigate to the newly copied .vdi file, select the file in question, and then click Next.
Figure C
I’m almost finished adding my clone to a new host.
Once the new virtual machine is created, that virtual machine should fire up as expected and regardless of platform (I have tested this going from Linux to Linux, Linux to Windows, and Windows to Linux hosts).
Summary
The ability to clone and move virtual machines in VirtualBox as easily as shown above makes this a great tool for anyone who needs to expand their world with virtual machines. Give this a try and see how far you extend the reach of your hosts and guests with VirtualBox.