Fail: How to move a VM to another disk (same machine)

This is for discussing general topics about how to use VirtualBox.

Fail: How to move a VM to another disk (same machine)

Postby jvsrvcs » 1. Mar 2012, 20:18

I am attempting to move all my virtual machines and their snapshots to another hard drive on the same box.

Host: Windows 7 (64 bit)
Guest: Windows XP Pro (32 bit)

I google'd around and found a tutorial on how to move a virtual machine to another machine and the instructions included => First delete all snapshots.

This is counterproductive, I have many snapshots that I need to retain and this tutorial is useless.

---
I exported the appliance to the E: disk drive (was on C:) and imported with virtual box, there is a reference in the popup dialog to the C:\ drive but I thought this a bit odd and was wondering if it is actually accessing the C: .vdi file when I do the import. If so the export/import would not be very useful for moving the vm to another machine.

At this point can I delete the VM on the C: drive?

I am still running the virtual box software from the C: drive, I just want to move all my VM's and their snapshots to a larger (2TB) E: drive.
jvsrvcs
 
Posts: 38
Joined: 26. Oct 2011, 02:53
Primary OS: MS Windows 7
VBox Version: OSE self-compiled
Guest OSses: Android

Re: Fail: How to move a VM to another disk (same machine)

Postby Perryg » 1. Mar 2012, 20:29

What versions were the VMs created with and what version are you using now?
Perryg
Site Moderator
 
Posts: 25915
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX - Other

Re: Fail: How to move a VM to another disk (same machine)

Postby jvsrvcs » 3. Mar 2012, 00:22

I am using the latest version of Virtual box. They may have been created with a few minor release revisions earlier.
jvsrvcs
 
Posts: 38
Joined: 26. Oct 2011, 02:53
Primary OS: MS Windows 7
VBox Version: OSE self-compiled
Guest OSses: Android

Re: Fail: How to move a VM to another disk (same machine)

Postby Perryg » 3. Mar 2012, 02:19

Well I can only assume that you mean 4.1.8 so here goes.

You should have a folder called VirtualBox VMs. This folder has all of your guests in them (if they were created with version => 4.*) including the snapshots.
You can copy this folder to the new location and remove them from the VirtualBox main manager (without deleting them)
Then use the add feature to add them back one at a time. (select the *.vbox file)
You should then open the preference section in the VirtualBox main manager and change the default location to the new place.

Be sure to backup the VirtualBox.xml file before you start just in case you make a mistake.
Once this is all working then you can delete the original VirtualBox VMs folder.

Look this all over and become familiar with the locations before you start to help prevent errors.
Perryg
Site Moderator
 
Posts: 25915
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX - Other

Re: Fail: How to move a VM to another disk (same machine)

Postby jvsrvcs » 5. Mar 2012, 22:47

Perryg wrote:Well I can only assume that you mean 4.1.8 so here goes.

You should have a folder called VirtualBox VMs. This folder has all of your guests in them (if they were created with version => 4.*) including the snapshots.
You can copy this folder to the new location and remove them from the VirtualBox main manager (without deleting them)
Then use the add feature to add them back one at a time. (select the *.vbox file)
You should then open the preference section in the VirtualBox main manager and change the default location to the new place.

Be sure to backup the VirtualBox.xml file before you start just in case you make a mistake.
Once this is all working then you can delete the original VirtualBox VMs folder.

Look this all over and become familiar with the locations before you start to help prevent errors.


Will this preserve my snapshots as well?
jvsrvcs
 
Posts: 38
Joined: 26. Oct 2011, 02:53
Primary OS: MS Windows 7
VBox Version: OSE self-compiled
Guest OSses: Android

Re: Fail: How to move a VM to another disk (same machine)

Postby jvsrvcs » 5. Mar 2012, 22:50

Also I have so many VM's that I cannot move all at once.

If that is the case, could I leave the preferences location alone for the moment? Is it possible to have VM's in two different folders at the same time and launch each?
jvsrvcs
 
Posts: 38
Joined: 26. Oct 2011, 02:53
Primary OS: MS Windows 7
VBox Version: OSE self-compiled
Guest OSses: Android

Re: Fail: How to move a VM to another disk (same machine)

Postby Perryg » 5. Mar 2012, 22:54

The preference is only for new creations of VMs so I would change that now. You can move them one at a time and yes it will work, but you should be absolutely sure that it is copied and working before you delete the original. Keep a backup of the VirtualBox.xml file is case.
Perryg
Site Moderator
 
Posts: 25915
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX - Other

Re: Fail: How to move a VM to another disk (same machine)

Postby jvsrvcs » 6. Mar 2012, 18:50

Perryg wrote:Well I can only assume that you mean 4.1.8 so here goes.

You should have a folder called VirtualBox VMs. This folder has all of your guests in them (if they were created with version => 4.*) including the snapshots.
You can copy this folder to the new location and remove them from the VirtualBox main manager (without deleting them)
Then use the add feature to add them back one at a time. (select the *.vbox file)
You should then open the preference section in the VirtualBox main manager and change the default location to the new place.

Be sure to backup the VirtualBox.xml file before you start just in case you make a mistake.
Once this is all working then you can delete the original VirtualBox VMs folder.

Look this all over and become familiar with the locations before you start to help prevent errors.


What you have suggested above did not work. It failed and is not a solution to the question posted. It wasted a lot of my time doing this.
I cannot copy and paste the exact error message in the error dialog, but it is something like this:

--- (got this when I tried to add the .vbox file)
Failed to open virtual machine located in:

E:/.../machine.vbox

Cannot register the hard disk 'E:\...\vmdir\Snapshots{fff... because a hard disk 'C:\<path>\Snapshots\{fff}.vdi

with UUID {fff...} already exists.
jvsrvcs
 
Posts: 38
Joined: 26. Oct 2011, 02:53
Primary OS: MS Windows 7
VBox Version: OSE self-compiled
Guest OSses: Android

Re: Fail: How to move a VM to another disk (same machine)

Postby mpack » 6. Mar 2012, 18:59

You provided only vague version information, even after being asked to clarify. What other result do you expect? To date you still have not said explicity what version you are using, and what version the VMs were created with.
mpack
Site Moderator
 
Posts: 13143
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Fail: How to move a VM to another disk (same machine)

Postby Perryg » 6. Mar 2012, 19:01

You must have missed a step because I know it works. With that said I can only say I will not waste any more of your time.
Perryg
Site Moderator
 
Posts: 25915
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX - Other

Re: Fail: How to move a VM to another disk (same machine)

Postby Perryg » 6. Mar 2012, 19:10

Finally I suspect you missed the part about removing, see below
You can copy this folder to the new location and remove them from the VirtualBox main manager (without deleting them)
Perryg
Site Moderator
 
Posts: 25915
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX - Other

Re: Fail: How to move a VM to another disk (same machine)

Postby jvsrvcs » 7. Mar 2012, 20:26

remove what? My snapshots?
jvsrvcs
 
Posts: 38
Joined: 26. Oct 2011, 02:53
Primary OS: MS Windows 7
VBox Version: OSE self-compiled
Guest OSses: Android

Re: Fail: How to move a VM to another disk (same machine)

Postby mpack » 7. Mar 2012, 20:55

My attempt at a step by step.

1. Shut down VirtualBox, back up your <userdoc>\.VirtualBox\VirtualBox.xml file.
2. Find your existing "Virtualbox VMs" folder, and copy (not move) the whole folder with contents to your new drive E:
3. Run VirtualBox, then for each VM in turn :-
3.1 Right click the VM name and select "Remove" from the popup menu. Answer no to the "physically delete files?" question.
3.2 Select the Machine|Add.. menu item, navigate to the VMs new location on drive E:, and select the .vbox file.
3.3. Repeat for any remaining VMs.
4. In File|Preferences, set the default machine path to "E:\VirtualBox VMs"
5. Test each of the VMs. Only after you are sure they all work, delete the old VM containing folder, i.e. delete "C:\VirtualBox VMs".


Now this is about as simple as I can make it.
mpack
Site Moderator
 
Posts: 13143
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Fail: How to move a VM to another disk (same machine)

Postby mpack » 7. Mar 2012, 22:02

Pasted in from your attempt to create yet another thread for this subject.

jvsrvcs wrote:I copied my entire folder containing a VM to another drive (C:\ to E:\)

I then removed the VM from the VM manager (I did not delete the files on the C:\ drive in case of a failure)

I then tried to add the .vbox file on the E: drive via the manager. I get the following error message.
My question is why the virtual machine files are referencing anything on the C:\ drive?

Is there any way possible to move a VM - INCLUDING THE SNAPSHOT's) to another hard drive on the same system (or to another computer for that matter).

If there is any solution at all, please let me know. I need to clear up space on my C:\ drive. If I loose the snapshots, I loose about six months of work.

I just want an existing VM on the C:\ drive that has many snapshots moved to the E:\ drive and be able to run as before as I did on the E:\ drive.

If this is not possible, I just need to know simply "VirtualBox does not have this capability".

--- VirtualBox - Error (after copying VM files to another Drive)

Failed to open virtual machine located in E:/<path>/<machine_name>/<machine_name>.vbox.

Cannot register the hard disk 'E:\<path>\<machine_name>\Snapshots/{0ece4bff-9185-4cff-9069-b3d1f4536394}.vdi' {0ece4bff-9185-4cff-9069-b3d1f4536394}
because a hard disk 'C:\<path>\<machine_name>\Snapshots/{0ece4bff-9185-4cff-9069-b3d1f4536394}.vdi' with UUID {0ece4bff-9185-4cff-9069-b3d1f4536394} already exists.

Result Code: E_INVALIDARG (0x80070057)
Component: VirtualBox
Interface: IVirtualBox {c28be65f-1a8f-43b4-81f1-eb60cb516e66}
---

One question is how does the VM Manager know about the C:\<path>\<machine_name>.vdi file even after removing from the VM Manager? I deleted it.

Where is the metadata kept that the VM Manager reads? Can I open the metadata file and delete the reference to the VM on the C:\ drive from this metadata?
mpack
Site Moderator
 
Posts: 13143
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Fail: How to move a VM to another disk (same machine)

Postby mpack » 7. Mar 2012, 22:10

Ah, ok. I just tried it and it does indeed do what you say. VirtualBox has an in memory copy of the media registry, which it rebuilds when you start up. This resident media registry is not updated when you delete a VM - I would call that a bug and will register it as such soon.

In the meantime the workaround is, after removing a VM from the UI you have to close VirtualBox, and leave it closed for long enough for the background VBoxSVC task to time out and terminate also. Then you can start the VirtualBox app again and use Machine|Add to add back the VMs removed in the previous step.

If you remove 2 or 3 VMs in one go then you should be able to get through this procedure in a reasonable time.
mpack
Site Moderator
 
Posts: 13143
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows XP
VBox Version: PUEL
Guest OSses: Mostly XP

Next

Return to Using VirtualBox

Who is online

Users browsing this forum: No registered users and 12 guests