How to move VirtualBox Guest VM

Scenario / Question:

How do I move an existing VirtualBox Guest VM to a new server or machine

Solution / Answer:

There are two ways to do this:

1. Use VBoxManage to make a copy of the VirtualBox VM .vdi and then create a new VirtualMachine on the new server

2. Move your existing VirtualBox VM .vdi file and VirtualMachine .xml files

#1 VBoxManager to make copy of .vdi

There are a few steps involved in order to make a copy of a VirtualBox .vdi disk file.

#1. Shutdown the Virtual Machine or make sure it is not start/on

#2. Release the .vdi file – File > Virtual Media Manager > Select the virtual machine disk to be copied > Click “Release”

#3. In a terminal or shell prompt (use the full location paths for .vdi locations)

VBoxManage clonevdi /root/.VirtualBox/Original.vdi /root/.VirtualBox/NewCopy.vdi

#4 Copy the new .vdi file to the new server

#5 Attach the .vdi File > Virtual Media Manager > Add > select copied .vdi file

#6 Create a new VirtualMachine in VirtualBox and use the copied .vdi as the HardDisk

#2 Move existing VirtualBox VM .vdi file and VirtualMachine .xml files

In order to move existing VirtualMachine and .vdi drive file you need to complete multiple steps and edit your VirtualBox.xml configuration file.

#1 On old server make sure that the Virtual Machine is turned off.

#2 Umount any CD/DVD drives that may be attached

#3 Remove any snapshots so that they merge with the main .vdi ( You will lose your snapshots and only most recent state will be moved to new server )

#4 Copy /home/[USERNAME]/.VirtualBox/Drives/myVM.vdi file and /home/[USERNAME]/.VirtualBox/Machines/myVirtualMachine folder to new server

#5 Copy Virtual Machine information from old servers VirtualBox.xml

$ cat /home/[USERNAME]/.VirtualBox/VirtualBox.xml | grep MachineEntry |grep myVirtualMachine

<MachineEntry uuid="{c16cec03-ee8f-4a12-a3c0-ac88fcad94fa}" src="/home/[USERNAME]/.VirtualBox/Machines/myVirtualMachine.xml"/>

#6 Copy Virtual Machine information to new servers VirtualBox.xml and place between the <MachineRegistry> </MachineRegistry> tags

#7 Copy Hard Disk information from old server VirtualBox.xml

$ cat /home/[USERNAME]/.VirtualBox/VirtualBox.xml | grep HardDisk |grep myVirtualMachine

<HardDisk uuid="{f2e2fb6a-0849-40bc-b78d-1e64ead3b98a}" location="/home/[USERNAME]/.VirtualBox/Drives/myVirtualMachine.vdi" format="VMDK" type="Normal"/>

#8 Copy Hard Disk information to new servers VirtualBox.xml and place between the <HardDisks> </HardDisks> tags

#9 Restart VirtualBox or Restart the Host machine (This must be done so that VirtualBox re-loads VirtualBox.xml with the updated entries and registers them)

Fabio Milano has written 80 articles for us. Fabio Milano is a certified RHCE, MCP, and CFOI. He runs an IT consulting and services company called RDS Support inc. Website:http://www.rdssupport.com
The information provided is for educational purposes only. All content including links and comments is provided "as is" with no warranty, expressed or implied. Use is at your own risk and you are solely responsible for what you do with it.

No Comments

Leave a reply