Page 1 of 1

Migrating VM from one PC to another

Posted: 30. May 2012, 06:31
by Neoc
I have looked through the forum and couldn't find a thread which answered my specific needs (I may be wrong - feel free to point me to any relevant threads).

I have recently started dabbling with VirtualBox at home. Since my old mail server hardware died, I thought I'd see if I could create a mail server in VB. After much trial-and-error and false starts, I managed to created a working server.

Dramatis Personnae:
Host: Windows 7 Pro x64 on Dell laptop (hereafter referred to as Laptop), connected via WiFi to network
Guest: Ubuntu 10.04 LTS x64 running Zimbra 7.2 (hereafter referred to as Mailserver)
Other: Ubuntu 10.04 LTS running RAID 5 (hereafter referred to as Fileserver), physical Gb Ethernet connection.

When I installed VB on Laptop, I changed the options so that the VMs would be created in a specific directory on Fileserver (which has both SMB and NTFS services enabled). Mailserver is happy to run on Laptop and, after a few tweaks to Laptop's firewall and my ADSL router for NAT, is quite happily sending and receiving mail as well as serving up webmail access. :D

The ability to play around on Laptop during this time has been fantastic, and I wish to continue experimenting on Laptop. But now that Mailserver is up and running, I would like to move it to another host with spare capacity - either my Win7Prox64 desktop machine or another spare Ubuntu box I have on the network.

Since all the relevant Hosts are on the same network and all have access to Fileserver (either through SMB for Windows PCs or NTFS for the Ubuntu boxen) I had though it'd be as simple as pointing the VB installation on the second Win7 PC to the relevant directory on Fileserver (easily done) and add/import the relevant VM (also easily done).

Easily done, maybe... but the imported VM will not start. :(

Threads I have read talk about having to clone the VDI and build a new VM pointing to that new VDI. Since my Mailserver VDI is "centrally" located on the network, is there an easy(?) way to "move" it to a different Host PC? (with Xen, I could simply have the new Host PC join the Pool and then transfer the VM to the new host)

Re: Migrating VM from one PC to another

Posted: 30. May 2012, 11:15
by mpack
Neoc wrote:Threads I have read talk about having to clone the VDI and build a new VM pointing to that new VDI.
Ancient threads perhaps. For VMs created by VBox v4.0 or later you simply copy the VM folder (or otherwise make it available on another host). Unless you interfered with the process, then VirtualBox will have created a folder containing the .vbox control file, .vdi disk image, xxx-prev files are backups, there may also be Logs and Snapshots subfolders.

All you do is move that entire folder to the other host, then use "Machine|Add" on that other host to register the VM with the new hosts UI.

If you have been putting files in non-standard places then you may have to manually correct any absolute file paths in the .vbox file (xml text). In fact it would be better to put any such files back in the VM folder where they belong, and remove path info. Host specific names such as the NIC to bridge to, COM number may also need to be changed if the VM uses those features.

Re: Migrating VM from one PC to another

Posted: 6. Jun 2012, 01:23
by Neoc
So I tried again last night after upgrading my PCs' memory from 2Gb to 4Gb :-
- stopped the VM on the laptop
- "Machine->Add" on the PC which brought me straight to the networked folder on the fileserver.
- Added the VM to the PC.
- Checked memory settings (unchanged).
- Checked network settings (they had automagically changed to the 1Gb network card).
- Started the VM... no problems. :shock:

I have no idea what I did different this time from last time (expect maybe for the increased physical RAM). I'll leave this running as-is for a few days before I remove the VM from the laptop.

This means I will be able to "play" with VMs on the laptop and then shunt them to a PC when I'm happy with them. Yay! :D

Many thanks for the help and suggestions. Obviously something worked.

Re: Migrating VM from one PC to another

Posted: 8. Jun 2012, 08:09
by cyberjanet
I wish I understood the instructions.

My motherboard died last Saturday. After replacing it with a newer model, my computer would not boot so I had reinstall an OS. Everything is on the computer, it just has to talk to the OS again, so I am having to reinstall a lot of stuff including Virtualbox.

It seems to me that it should be easy to take the existing virtualmachines that I have and just move them, but in practice I am not succeeding. In Windows.old, the folder structure is different. I have a .virtualbox folder in my users file, which has subfolders of Machines and VDI, and a number of files including a virtualbox.xml. Inside the machines folder are folders for my two machines, and those contain .xml files, while in snapshots I find .vdi files.

In my new setup, in users I have two folders: .virtualbox, and Virtualbox VMs. I have tried copying across the windows.old .virtualbox contents to the newer .virtualbox folder but that had no effect. I tried to use the Import Appliance option, but couldn't find the right kind of file to import. I tried using the Add function to add xml files, but got errors along the line of

Failed to open virtual machine located in C:/Windows.old/Users/janet/.VirtualBox/Machines/Win2K/Win2K.xml.

A differencing image of snapshot {570b0e84-972b-4a21-b155-e557ce3d7847} could not be found. Could not find an open hard disk with UUID {0d13d11f-1ae3-42b1-877e-0350b8470b19}.

Result Code: E_FAIL (0x80004005)
Component: SnapshotMachine
Interface: IMachine {5eaa9319-62fc-4b0a-843c-0cb1940f8a91}
Callee: IVirtualBox {c28be65f-1a8f-43b4-81f1-eb60cb516e66}


I cannot find a .vbox file to add. I did make a dummy machine to see where the program put everything, which is how I got the new folder structure.

At this stage I have to admit that this is beyond my competence. Clearly, I am missing something obvious, but I have no idea what. Any help would be much appreciated.

Thanks,
Janet

Re: Migrating VM from one PC to another

Posted: 8. Jun 2012, 10:27
by mpack
@cyberjanet: As I said above, "easy migration" applies to VMs created by more recent versions of VirtualBox, i.e. 4.0.0 or later.

The VMs you are talking about were created by v3.x or earlier, i.e. you need to apply techniques discussed in "ancient threads". And just to round things off, you used snapshots, so you clearly weren't bothered about reliability or recoverability. In fact if you have a folder called "VDIs" then it must be old indeed, or non-standard, since that folder has always been called "HardDisks" in every version I've used (since 2008).

Basically, you can't recover the dead VM, but it might be possible to create a new VM which has the same data on its hard disk. To do that, copy the base VDI plus all snapshot VDIs into one folder. Download the CloneVDI tool from the sticky in "Windows Hosts", and use it to clone the most recent snapshot VDI (do not make the mistake of cloning only the base VDI). If successful this will give you a stand-alone (merged) VDI which you can build a new VM around. CloneVDI is a Windows app, so on non-Windows hosts you'll need to install Wine.

Further instructions depend on which VBox version you will be using from now on.

Re: Migrating VM from one PC to another

Posted: 8. Jun 2012, 14:17
by cyberjanet
Version-wise: every time VirtualBox asks me to download a new version, I do. I use it to run a win2k program that I need occasionally, and I have used it in the past few months. I thought backups were the way to preserve data, but clearly I am wrong. In any case I cannot restore the backup as the new OS is not Vista; it would not boot after the hardware change and the licence has been invalidated by the change of motherboard. However, everything on the hard drive is still fine and quite accessible.

I could just make a new box, reinstall win2k from my pre-Noah disks, reinstall sp4, and reinstall the software. However, I'm going to have to do it all again quite soon as I currently have no permanent OS - I am dual-booting between Win7 and Win8 trying to decide my future. So if there is a way of just moving the existing (and I thought very much alive) win2k box I would prefer to know how to do that.

I have made the clone. I downloaded and installed the most recent version of Virtualbox which is 4.1.16 r 78094.

Thanks.
Janet

Edit: I have just checked the properties of the VirtualBox file in Windows.old and it has the version as 4.1.14 r77440.

Re: Migrating VM from one PC to another

Posted: 12. Jun 2012, 01:23
by Neoc
The only help I can provide is that your "new" installation is trying to access your "old" files. When you copied the files from windows.old, did you modify the contents of the .vbox file to point to the new directory structure?

Re: Migrating VM from one PC to another

Posted: 12. Jun 2012, 12:13
by mpack
cyberjanet wrote:Version-wise: every time VirtualBox asks me to download a new version, I do.
I don't doubt you, however you'll note that I referred to which version had created the VM. It is during creation that the folder structure is established, and once established, VirtualBox supports that folder structure for backwards compatibility.

I see you say you've already done it, but to other readers, if you want to convert a VM to the new folder structure, and you are now using VBox 4.1.0 or later, then a convenient way to do it is to right click the VM and select "clone". The clone, being created by a new version of VBox, will have the new folder structure, though the contents should be identical (except for UUIDs). Make sure it boots before deleting the VM, as some boot managers are sometimes configured to be sensitive to hd UUID. If the old VM used snapshots then you'll be asked during cloning if you want to retain the snapshots or clone the current state only - I would suggest the latter, since snapshots are the work of the devil. :-)

Re: Migrating VM from one PC to another

Posted: 12. Jun 2012, 15:10
by cyberjanet
OK, I have solved this problem, and it was as easy as I thought it should be.

The trick I did not know was to create a new machine. I didn't have to import or add or anything, nor copy folders across, nor create clones. I just went through the steps of naming the machine, specifying the OS, setting the memory. Then when I got to the Virtual Hard Disk screen, I chose Use Existing Hard Disk and looked for the .vdi file of my existing box.

So it's running just fine at the moment, and my ancient copy of Pagemaker 6.5 is also working fine. I had to reinstall a lot of drivers for some reason, but that was all automatically generated. It seems I'll have to reinstall the network bridging stuff to get the printer back, but I'll worry about that side of things once I have a permanent OS.

Thanks for your time.

Re: Migrating VM from one PC to another

Posted: 12. Jun 2012, 15:19
by mpack
cyberjanet wrote:when I got to the Virtual Hard Disk screen, I chose Use Existing Hard Disk and looked for the .vdi file of my existing box.
That works provided the VM did not use any snapshots: rather, anything installed after the first snapshot will be lost. Another point to note is that other versions of Windows may be provoked into reactivating because its a new VM with a new machine UUID.

Re: Migrating VM from one PC to another

Posted: 12. Jun 2012, 23:23
by cyberjanet
Cannot comment on snapshots. I appear to have them, they seem to be automatic, but I have never knowingly made any. When it comes to VirtualBox, it's like driving a car. I get in with the keys, turn the engine, and drive off. I don't know how to change the oil, fill the tank, or pump the tyres. Don't even talk about calibrating spark plugs.

Re: Migrating VM from one PC to another

Posted: 13. Jun 2012, 10:26
by mpack
VirtualBox does not create snapshots automatically. Also you must distinguish between snapshots and other forms of difference image (*), some of which are created implicitly (e.g. when you make an immutable drive, or create a linked clone). Although I only mentioned the most common case - snapshots, my earlier comments applies to all forms of differencing image.

(*) The distinction is that snapshots record the VM settings too, not just the contents of hard disks. Snapshots also appear in the "Snapshots" pane of the VM dialog, other forms of differencing disk do not.