Problem migrating a virtual machine between servers

This is for discussing general topics about how to use VirtualBox.
Post Reply
Dr. T
Posts: 30
Joined: 2. Feb 2010, 02:40
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: NextStep, OpenStep, Linux, Haiku

Problem migrating a virtual machine between servers

Post by Dr. T »

I have a virtual machine located on a shared filesystem which is NFS-exported to all my virtual machine servers. The machine is in the middle of a long running computation but I need to perform some hardware maintenance on the server it is running on. So I did the following:

1) Put the virtual machine into a saved state.
2) Deregistered the machine on server #1.
3) Closedmedium'd all its virtual hard disks.
4) Attempted to register the virtual machine on server #2. This failed, with a message "Medium '<virtual-hard-disk-filename>' cannot be closed because it is still attached to 1 virtual machines.
5) I attempted to register the machine back on server #1. This failed too, with the same error message.

So now I don't seem to be able to get the machine either onto the new server or even back onto the old server.

I can delay the hardware maintenance on server #1 a bit (one of its non-hot-swappable disks is failing but I think it has some more life in it yet), but I don't want to disrupt the current run of the virtual machine. How do I get the machine running again? Thank you.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Problem migrating a virtual machine between servers

Post by scottgus1 »

Unless the two host servers are identical in the strictest sense of the word, switching a save-stated VM to another host probably will not work. So you'll have to get it going on the original host.

It is not necessary to deregister a shared-network-storage VM from one host to register it on another host. A VM can be registered on two hosts, you only have to make sure Virtualbox is not running on both hosts at once. In fact, the deregistering and closemediuming seems to have damaged the VM. If you have a backup of the VM's .vbox file you might be able to restore that file and get the structure of the VM back in order, though without the saved state. If you carefully study the XML of a VM's .vbox file with a saved state, you might be able to put the saved state into the restored .vbox file.

Basically, there's not much we can do with this without seeing a backed-up .vbox file and the existing deregistered .vbox file, and someone in the forum's volunteer answerers willing to take the time to cobble it all back together again. It would have been better to ask how to move the VM first before attempting to move it unguided.
Dr. T
Posts: 30
Joined: 2. Feb 2010, 02:40
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: NextStep, OpenStep, Linux, Haiku

Re: Problem migrating a virtual machine between servers

Post by Dr. T »

Thank you for your kind reply.

I have solved the problem now. Here is how.

First, after solving this problem with this particular virtual machine which I was migrating from server #1 to server #2, I also migrated several other virtual machines between the same pair of servers and the rest of them all migrated without problems. I saved the state of each virtual machine, de-registered it on server #1, closemedium'd all its attached virtual hard drives, then registered it on server #2 and started it up again on server #2. In all cases except the one troublesome machine, that just worked. Thank you for kindly explaining that the de-registration from server #1 was unnecessary. I didn't know this and it's useful to know. In this instance, I in the end decided to move all the virtual machines to local storage on server #2 after migrating them, so presumably I would have had to de-register them from server #1 in any event? - but this won't always be the case.

Now for what I did to sort out the troublesome virtual machine, and how it differed from the others. The virtual machine had four virtual hard disks attached. Two of those four were listed in the <MediaRegistry><HardDisks> section of the .vbox file, but two were missing from that section. I don't know why. Having said that, when I tried to register the virtual machine on server #2, the issue reported was with one of the two hard disks which was listed in that section. All four drives were listed in the <StorageController name="SATA" ...><AttachedDevice ...> sections. I backed up the .vbox file. In a text editor, I deleted the <AttachedDevice> sections from the .vbox file, and added the two missing <HardDisk> definitions. I then registered the virtual machine on server #2, which succeeded. I then added back the four <AttachedDevice> lines to the .vbox file in a text editor. I ran vboxmanage and adjusted the name of the virtual machine's <BridgedInterface> because the Ethernet interface names on server #2 are different from those on server #1. No other changes were needed. I then started the virtual machine on server #2, which succeeded. The saved state was respected and the virtual machine resumed execution from the saved state. The hardware on server #2 is fairly different from that on server #1, e.g. the CPU on server #2 is an AMD EPYC while that on server #1 is Intel Core i5, etc., however, the virtual machine still appeared to resume from the saved state and appears to be operating without problems. All the other virtual machines I migrated also resumed from their saved state without problems.

None of the other virtual machines I successfully migrated had missing disks in the <HardDisks> section of the .vbox file, and that is the only difference between them I'm aware of. So it looks like that was the cause of the problem. I don't know, however, either why those definitions went missing from the .vbox file, nor why this would have caused a problem of this nature (if indeed this was the cause of the problem).

Thanks again for your help.
Post Reply