How to move a VBox VM to another PC?

This is for discussing general topics about how to use VirtualBox.
mmorris
Posts: 6
Joined: 16. Jan 2009, 22:49

Re: How to move a VBox VM to another PC?

Post by mmorris »

The process is even simpler...

On the existing host machine:
1) Close the Virtual Box session that you want to clone/export/copy
2) Use the Sun Virtual Box interface select File --> Export Appliance ...

On the new host machine:
1) Use the Sun Virtual Box interface select File --> Import Appliance ...

Mike
DavoMartinez
Posts: 1
Joined: 31. Jul 2009, 18:54
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: XP

Re: How to move a VBox VM to another PC?

Post by DavoMartinez »

I started using VBox last week.

I made the mistake of changing the drive letter of where my VMs were on my computer and I had to redo my system and snapshots. It was not a big deal since I had only spent about 2 hours installing the VM OS and creating snapshots.
g0nad
Posts: 1
Joined: 2. Aug 2009, 05:50
Primary OS: Ubuntu other
VBox Version: OSE other
Guest OSses: debian & XP

Re: How to move a VBox VM to another PC?

Post by g0nad »

I had a VM with a snapshot but the (windows) host died. I didn't want to reinstall windows so thought I'd be able to run up the VM on my Linux workstation. Getting the VM going was not a problem however I'm stumped about being able to pull in the snapshots. I won't be using snapshots in future, I'll just take copies of the vdi "harddisks" from time to time instead.
SecretCode
Posts: 67
Joined: 17. Jul 2009, 10:20
Primary OS: Ubuntu other
VBox Version: PUEL
Guest OSses: Ubuntu, XP, other
Location: Finland

Re: How to move a VBox VM to another PC?

Post by SecretCode »

DavoMartinez wrote:I started using VBox last week.

I made the mistake of changing the drive letter of where my VMs were on my computer and I had to redo my system and snapshots. It was not a big deal since I had only spent about 2 hours installing the VM OS and creating snapshots.
I successfully recovered from situation like this (but I was not using snapshots) just by editing the main vbox xml - on a Windows host, C:\Documents and Settings\user\.VirtualBox\VirtualBox.xml - and fixing the paths in the <MachineRegistry> and the <MediaRegistry> sections.

This may be unsupported and is probably risky - take backups of that file before editing.
jacksenechal
Posts: 1
Joined: 1. Sep 2009, 01:47
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Ubuntu, WinXP, Incognito Linux (at least, trying to get it to run!)

Re: How to move a VBox VM to another PC?

Post by jacksenechal »

I have managed to move my virtual machines from my laptop hard drive to an external, to free up space. Here's how I did it:

1) Create VirtualBox directory on external
2) Move ~/.VirtualBox/HardDisks/ and ~/.VirtualBox/Machines to the external
3) Edit ~/.VirtualBox/VirtualBox.xml, and:
4) Replace all absolute path references with the path to the external directory (eg. replace /home/jack/.VirtualBox/ with /media/disk/VirtualBox)
5) Convert all relative paths to absolute paths, pointing to the external (eg. under <MachineRegistry>, "Machines/Windows/Windows.xml" becomes "/media/disk/VirtualBox/Machines/Windows/Windows.xml", etc)

Success! And all of my snapshots, etc are still intact.
ColOfNature
Posts: 4
Joined: 6. Sep 2009, 02:06
Primary OS: MS Windows Vista
VBox Version: PUEL
Guest OSses: debian, gentoo, freebsd

Re: How to move a VBox VM to another PC?

Post by ColOfNature »

Is it possible to migrate a VM to another host while it is running? i.e. I need to shut down my host while I'm compiling on the guest, can I move the guest temporarily to my laptop without stopping the running process?
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: How to move a VBox VM to another PC?

Post by mpack »

ColOfNature wrote:i.e. I need to shut down my host while I'm compiling on the guest, can I move the guest temporarily to my laptop without stopping the running process?
No. Your virtual disks are actual opened host files. AFAIK, no host OS allows you to move opened files.

You could try saving the machine state, but that makes the move more complicated.
MrX1980
Posts: 26
Joined: 3. Sep 2008, 20:44

Re: How to move a VBox VM to another PC?

Post by MrX1980 »

Please participate on "Add OPEN function" ( http://www.virtualbox.org/ticket/5767 )
AwesomeHighFive
Posts: 9
Joined: 19. May 2011, 19:20
Primary OS: MS Windows 7
VBox Version: PUEL
Guest OSses: Ubuntu 8.04.4 Server LTE

Re: How to move a VBox VM to another PC?

Post by AwesomeHighFive »

If anyone is still wondering about this, if you went and deleted the old machine like I did, you have to find its UUID in its local virtualbox file (which is just xml) and copy it into the main xml file in your C:\users directory. It looks like it correctly reads all of the snapshots once the machine UUID is in place.
jdthood
Posts: 1
Joined: 4. Aug 2011, 09:38
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Windows XP, Debian, etc.

Re: How to move a VBox VM to another PC?

Post by jdthood »

I just moved a VirtualBox VM from an i386 machine to a x86_64 machine. I just used scp to copy the whole /home/<username>/VirtualBox\ VMs/<vmname> directory over. I started VirtualBox OSE Manager on the new host machine and was able to boot the VM without any further action. Nice.

But then I decided I wanted to move the VM's files to another location in the filesystem. I reverted to snapshot and used mv to move the directory named like the VM. In VirtualBox OSE Manager I "Remove"d and "Add"ed the VM from the new location. VirtualBox could no longer start the VM, complaining of a hard disk file not found. Interesting that the VM files can be moved brute-force from one machine to another, of another architecture, but not from one directory to another on the same machine!

I was able to move the VM directory by (1) moving it back to the original location, where it worked (again) and (2) exporting and importing it to the desired location.

Both of these techniques were mentioned earlier. Thanks to the help of other forum contributors.

This was with VirtualBox OSE 4.0.4, both machines running Ubuntu 11.04 (natty).
Cyberian
Posts: 49
Joined: 17. Dec 2008, 10:21
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Windows, Fedora

Re: How to move a VBox VM to another PC?

Post by Cyberian »

Have a look in your Virtual Media Manager.

remove the entry (without deleting the vdi) and re-add the VDI from the new location.
ssamuel
Posts: 1
Joined: 29. Oct 2011, 16:47
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: multiple

Re: How to move a VBox VM to another PC?

Post by ssamuel »

If anyone's still looking, I found an easy manual solution:

1. Exit VirtualBox. It may work while still running but I doubt it refreshes. Probably a good idea to exit first anyway, programs tend not to like their master config files changing under them while running.
2. Backup your ~/.VirtualBox/VirtualBox.xml file then edit it. It's a light edit, any text editor should work.
3. Find the [machinename].vbox XML file in the folder for the VM you're trying to add and open it.
4. At the top of the machine file is a <Machine ... > tag. Copy the whole tag, single line, just the open tag.
5. Insert this into the VirtualBox.xml file with the rest of the <MachineEntry ... > tags, change the name to match. Keep the UUID but change the source to point to the physical path of the [machinename].vbox file that you just opened. I just did some copy-paste with the line above it since I keep all my HDs in one place and follow the general pattern it defaults to. Basically, make it look like its friends but with the correct information.
6. Save, close, restart VirtualBox.

If you get an error complaining about some mounted CD image, edit the [machinename].vbox file and remove the mounted CD/DVD images. This would happen if you've re-mounted the same ISO on the new server as the first time it mounts, it seems to get a UUID that sticks with it. May happen otherwise, dunno, but it's an easy fix. You'll need to re-mount the ISO but that's easy through the UI.

I'm assuming you know XML and can manage modifying a listing while maintaining validity. If not, use an XML-aware editor on the VritualBox.xml file and it should help you. Every XML tag <something> must have a corresponding </something> at the same structural level and <something></something> is syntactically equivalent to <something/>. XML is case-sensitive, even on Windows. If you cronk your config file, you have a backup from step 1.

I did this on Ubuntu but a brief peek at a Windows VBox install seems to show the configuration being exactly the same. On Windows the VirtualBox.xml file is [userdirectory]/.VirtualBox/VirtualBox.xml. Since you copied your machine config from somewhere else, you should know where it lives.

This got me all my snapshots, exact same configuration (minus the mounted ISOs), etc. Took me all of a minute.

HTH
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: How to move a VBox VM to another PC?

Post by mpack »

? What is the point of this cumbersome procedure? If you want to add a VM described by a .vbox file to the VirtualBox UI, you simply double-click the .vbox file, or alternatively select the Machine | Add... menu item in the UI, and then browse to the .vbox file you want. Manual xml edits can't be supported because we can't be sure you got it right - and anyway it is unnecessary in this instance.

Much of the above thread deals with VirtualBox prior to v4.x, which is when new features were added to the UI which makes this easy, rendering much of this thread obsolete - IMHO it should be locked to prevent further misinformation being posted.
noletolucas
Posts: 2
Joined: 29. Dec 2011, 22:59
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: winxp

Re: How to move a VBox VM to another PC?

Post by noletolucas »

To MOVE PRESERVING SNAPSHOTS and NOT MANUALLY EDITING ANYTHING:
viewtopic.php?f=1&t=48258#p219275
viewtopic.php?f=1&t=48258#p219285

Basically you should follow this 2 replies.
Locked