Move VirtualBox Machine & Disk Directory - Success

Discussions related to using VirtualBox on Windows hosts.
Post Reply
AndyPryke
Posts: 2
Joined: 24. Jan 2010, 12:55
Primary OS: MS Windows Vista
VBox Version: OSE other
Guest OSses: Windows XP

Move VirtualBox Machine & Disk Directory - Success

Post by AndyPryke »

This is my first post, but I've found the boards invaluable in my experiments with VirtualBox.

One thing I wanted to do but didn't find step-by-step instructions in one place, was to move my very large Machine and HardDisk directories to a different drive. This is how I did it, on Windows Vista, with virtual Windows XP Machines which have snapshots.

Background
On Windows Vista, the default directory for my disks and machines is:
c:/User/xxxx/.virtualbox
where xxxx is my username. As I don't have a large system partition, and I'd like to keep them seperate, I wanted to move my virtual machines (with snapshots) to:
F:/VirtualBox

This is how I did it:
0) Exit VirtualBox
1) Backup all .xml files in c:/User/xxxx/.virtualbox (and subfolders) to a "xml before move" folder - in case things go wrong!
2) Duplicate the backups to a "edited xml after move" folder
3) Make a new F:/VirtualBox folder, and move c:/User/xxxx/.virtualbox/Machines and c:/User/xxxx/.virtualbox/HardDisks to it (takes a while...)
4) Edit the VirtualBox.xml file (in the "edited..." folder), changing all the occurences of c:/User/xxxx/.virtualbox/ to F:/VirtualBox/
5) Edit the VirtualBox.xml file, changing the values of defaultMachineFolder and defaultHardDiskFolder in the SystemProperties tag to:

Code: Select all

defaultMachineFolder="F:\VirtualBox\Machines" defaultHardDiskFolder="F:\VirtualBox\HardDisks"
6) Copy your new VirtualBox.xml file to the F:\VirtualBox directory
7) What I did incorrectly - don't do this: tried starting VirtualBox - the Machines were listed, but as unregistered, and with an "103" error about the path of "machineimpl.cpp". Stopped VirtualBox
8) Add the system variable VBOX_USER_HOME with a value of F:\VirtualBox
9) Started VirtualBox - it worked and the machines are accessible and run just as before :-)

I will now try a similar procedure to clone a VirtualMachine (and Disks, and snapshots) to a new physical machine, having failed (VM crashed) when just moving the disks.

I cannot guarantee that it will work for you, though it seems straight forward. If you have invested a lot of time in setting up your VMs, you might want to do a more comprehensive backup before starting.

Andy
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Move VirtualBox Machine & Disk Directory - Success

Post by mpack »

Your procedure itself is fine, my only comment is that if (as I suspect), "F:" refers to a removable drive, then based on user experiences from this site I consider it unwise to run VirtualBox off of data on a removable drive.

Disk performance is likely to be poor for one thing (most removable drives are configured so that writes go directly to the drive, bypassing the cache), and there is also the danger of absent mindedly removing the drive while the VM is running, which can corrupt your data. Unless you have a laptop I would recommend giving consideration to buying a second (big) internal drive for your PC.
AndyPryke
Posts: 2
Joined: 24. Jan 2010, 12:55
Primary OS: MS Windows Vista
VBox Version: OSE other
Guest OSses: Windows XP

Re: Move VirtualBox Machine & Disk Directory - Success

Post by AndyPryke »

Thanks for the tip. I wouldn't want to accidentally encourage people to deploy on external drives given the problems you outline. In my case, F: is an internal drive, so all should be OK.

Andy
code001
Posts: 1
Joined: 17. Jan 2013, 13:04

Re: Move VirtualBox Machine & Disk Directory - Success

Post by code001 »

I would add some step I did (My VDisk were lost for long and I had to rescue them everytime using a log and repeating tricky procedure).

As soon as I set the VirtualBox.xml in the working dir (I got it fron the VirtualBox installing dir) and I made the proper changes, I rescue my disks using the File>>Virtual Media Manager>> Copy utility.
I did not use up to the end Copy utility, but it was usefull to permit the VirtualBox to rescue the right pointers (sorry for the improper use!) to the Disk files I had lost, simply choosing virtual Hard Drive not in the list!
Depending on the presence of Snapshots on every VMachine, some disk were in (my case, F is still an internal drive!!!) F:\VirtualBoxDir\VDiskDir and some other were in the F:\VirtualBoxDir\Machines\MyVMachineDir\Snapshots. It is important to follow the proper Hierarchical order in choosing the VDisks, so try before the VDisk dir then the snapshot Dir (or viceversa, sorry I do not remember now!), snapshot have their own hierarchy too! (The Details Window, gives you the infos about what you are in lack of with the proper order of missing devices!)

Before I used a simple trick, I started a new VM machine, I added the disk using the option "Use an already existing Disk", choosing all the disks I needed I had lost, then aborting the New VM operation.
After a Refresh the VM had their own disks for the session, till I close the VirtualBox program!

Thank for the solution I got!
Luca
Post Reply