Page 1 of 1

Moving all my VM storage to another drive

Posted: 2. Jun 2011, 02:18
by rossmcm
I have VB installed on my desktop machine but the disk is getting a bit tight so I want to transfer all my VMs to a second local drive. So I need to transfer:

- all of my virtual machines
- snapshots (not essential)
- exported appliances

i.e. anything associated with VB that has large storage requirements. I want to leave VB installed as it is apart from the disk where it stores these things.

I have seen various posts on what you can't do/must do/shouldn't do. I'm assuming it's little more than copying some folders across and updating some pointer disk address but I would hate to miss anything.

TIA
Ross

Re: Moving all my VM storage to another drive

Posted: 2. Jun 2011, 11:32
by mpack
If the VM was created by VBox v4 then you can simply copy the containing folder, then remove the old VM from the GUI (letting it delete all the old files), than add the VM back from its new location.

If it wasn't VBox v4, then you can't move a VM with snapshots.

Also see this recent discussion.

Make backups before you start.

Re: Moving all my VM storage to another drive

Posted: 2. Jul 2011, 05:53
by $roman
This does not work. There are separate entries for machines and harddisks in the file. If you follow that procedure, the machines will get fixed, but the hard drives they depend on won't.
It's simple. This is what I did.
1. copied the entire .VirtualBox folder elsewhere.
2. edited the VirtualBox.xml file in the original location (because there seems to be no way to tell the computer that it exists somewhere else).
2.1 found all of the entries that start off with src="Machines\ and changed that to src="E:/.VirtualBox/Machines/ in my case. You have to specify the full path to where the machine is now whereas before it showed only the relative path.
2.2 found all of the entries that have a full path to the old files (eg. location="C:/Users/User_Name/.VirtualBox/Machines) and just change that to the new location (ie. location="E:/.VirtualBox/Machines). Any decent text editor (even notepad) will have a find and replace function to make this easier.

Note: I don't think it matters which was the slash goes /\. Most of the slashes in this document are forward slashes even though I'm on Windows 7 host.
Note: make sure that you close VirtualBox before doing these edits. Otherwise, when you do close VirtualBox, it will overwrite the file with the old settings (or whatever was set in the GUI during that session).

Re: Moving all my VM storage to another drive

Posted: 2. Jul 2011, 11:19
by mpack
$roman, your advice is uninformed and obsolete.

The procedure I outlined above works in VirtualBox v4.x. The .VirtualBox folder tree does not contain the VMs in v4 (unless they happen to have been left there by legacy v3 installations), so copying that folder elsewhere en mass will do nothing very useful.

Re: Moving all my VM storage to another drive

Posted: 4. Jul 2011, 22:36
by rossmcm
Hi, OP here. I initially tried the procedure outlined in @mpack's first post, but when I started one VM it complained about not being able to find the disk. Whatever I put it aside until I saw @$romans post. I think my installation may be a hybrid of previous VB versions. Inspecting my VirtualBox.xml, I see that some VM's seem to have machine entries that point to a file:

\.Virtualbox\Machines\WinXP1\WinXP1.xml

and a disk image in WinXP1.vdi and some have a machine entry that points to WinXP2/WinXP2.vbox

whatever, I moved everything apart from VirtualBox.xml to the E:\ drive and then edited VirtualBox.xml to point all paths to the E:drive, renamed the old stuff on the c: drive to hide it, and everything still works so far. The structure I have ended up with on the E: drive is:

Code: Select all

E:\
    .VirtualBox\
        HardDisks\
            WinXP1.vdi
            WinXP2.vdi
            ... 
            <one VDI file per VM, but not for all of them, for some reason> 
        Machines\
            WinXP1\
                Logs\
                Snapshots\ 
                    {GUID}.vdi
                    {GUID}.sav
            WinXP2\
            ... 
            <one folder per VM>
Does this look sensible?

What would be really nice (listening anyone...?) would be a "Properties" sheet for each VM that showed a list of all the files associated with the VM, what they were, and where they lived. And maybe a function for moving a VM that involved nothing more than entering the new path.

Thanks for your input folks.

Ross