Best practice to migrate from VirtualBox to KVM

Latest response

Hello community,

For quite some time I'm using Oracle VirtualBox on Linux Hosts to run some Linux and Windows guests on it. Since there are issues with the VBox Guest Additions almost every time a new version of the Guest Additions or the RHEL kernel are is released I'm thinking about to move over to use KVM instead. But I would like to keep my existing VMs and migrate them into KVM VMs.

Did someone of you walk down this path, already? If so you may give me some advise on how to do it?

Is it possible to use VirtualBox and KVM concurrently on one host until the migration is finished? Or at least to use them alternately?

How to convert the VMs? What are the common pitfalls?

Any advice would be appreciated.

Best regards,
Joerg

Responses

According to https://www.utappia.org/2016/04/how-to-migrate-your-virtual-box.html you should be able to run vbox and kvm on the same host and the migration looks pretty straight-forward to me.

Hi Jörg,

First of all : Congrats for your decision to (eventually) switch from ORACLE VirtualBox to KVM, you won't regret it ! :)

You cannot use a .vdi virtual disk with QEMU and - it is recommended to have only one virtualization solution installed.
So you have to convert the .vdi disk to a .qcow2 disk. The first part should be done with VBoxManage, the second with
qemu-img. Afterwards uninstall VirtualBox and restart the system - then create new VM(s) with virt-manager or from
within the web console (Cockpit) and attach the existing .qcow2 virtual disks. And here are the commands to convert :

VBoxManage clonehd --format RAW <vdisk-name>.vdi <vdisk-name>.img
qemu-img convert -f raw <vdisk-name>.img -O qcow2 <vdisk-name>.qcow2

Regards,
Christian

Hello Christian,

Be aware that although VirtualBox is used for virtualization to RHEL is it just an application. So running KVM and VirtualBox on the same box will only conflict if it causes resource issues.

Regards,

Jan Gerrit

Hi Jan Gerrit, I know, but I do have seen conflicts ! :) That's why I said this :

"... it is recommended to have only one virtualization solution installed."
"... uninstall VirtualBox and restart the system."

Regards,
Christian

Hi Christian,

It would be great if he had two servers, the current with VirtualBox and another with KVM and after the disk clone step move the raw disk to the KVM server.

@JoergK do you have these resources available? As Christian states you will avoid issues. You do not want to break the original VirtualBox guest during this process, to be able to fallback if required. (better be safe than sorry)

Regards,

Jan Gerrit

Thanks Jan Gerrit,

Having two servers would be great, but most certainly nothing will break, because the conversion of the vdisks
is done (Hope nobody disagrees !) while the VM's are not running. So, during the conversion process Vbox can
stay installed. Once that's done Jörg can remove VBox, reboot the host system and start working with KVM. :)

Why do I say "hope nobody disagrees" ? Well, I have seen cases where users are (still) working on (v)disks from
within a running system. It should be a known fact that this is a very risky action. Still some continue doing it ...

Regards,
Christian

Hello guys,

Thanks again for your suggestions.

Do you guys use VM snapshots in your environments. From RHEL 8 Release Notes I know that the current implementation is deprecated because it does not work properly. How is the situation in RHEL7? Are there any common issues while creating, reverting or deleting snapshots?

I rely on the snapshot feature because I use my VMs for testing purposes mostly and have to revert to a snapshot from time to time.

Regards,
Joerg

Hi Jörg,

I would delete all snapshots before converting the virtual disks. Not only snapshots may break the conversion,
but also they are only working on Legacy BIOS based VM's. On modern EFI based BIOS ones snapshots don't
work. Guess what ? The most easy solution to backup a virtual disk is to simply copy the qcow2 file to another
location. It's not necessary to backup a whole VM, if there is a problem, just clone another VM, and attach the
the disk to the new cloned VM. Another option would be to create a backup of the disks by using Clonezilla. :)

Regards,
Christian

We use our VMs also for testing (of a software application) and create thin provisioned VMs from templates. That is in our setup much faster than using snapshots. Our tests range from 4 minutes to 4 hours and the templates range from 40 - 60 GB.

Hi,
For testing purposes I think I could go the same way as Siem and just create new VMs from templates. That should be fine.

Today I'd like to take a snapshot from a production VM each time before I apply updates/patches to it. If something goes wrong I jump back to the snapshot and are up and running again. I guess I could not solve this easily by creating a new VM each time an update needs to be applied because I would have to migrate the data as well each time. So I guess there is still a point for using snapshots.

Christian, you mentioned that snapshots don't work with EFI based BIOS. Could you explain that in some more detail? In my understanding a snapshot is just a point in time where changes to the virtual disk are written to a new file. It's just like a copy on write operation or at least it should be. Therefor it should not matter whether EFI or BIOS is being used either on the virtualization host or in the guest.

To copy the whole qcow2 file may be a good choice for regular backups. But a simple snapshot would save you some time because only blocks that are changing have to be written to disk not the whole file itself.

To ask more specific, do you guys don't use snapshots because you don't need them for your use cases or do you have negative experiences and advice against using them?

Have a good start in the upcoming week.

Regards,
Joerg

Hi Jörg,

You seem to have misunderstood something ... you don't have to create a new VM when you want to roll back a
broken system - you just copy back the vdisk you've backed up before. Why snapshots don't work on EFI based
BIOS ? I don't know ... I just know that it doesn't work. Maybe it's got something to do with the implementation
of OVMF. If you insist on using snapshots, you can use the Boom Boot Manager from within RHEL itself : How
to create a BOOM boot entry
. Hope I could clarify everything. By the way, what is valid for bare metal installs,
is valid for virtual systems as well : There is no better solution to restore the state of a system than restoring
back a system backup image. And, once again : it is the virtual disk which matters, not the virtual machine. :)

Regards,
Christian

Hi,

The automated section of our test environment does not use snapshots as that would increase the amount of I/O and slow down performance compared to the thin provisioning from templates. We create and run many VMs and the difference does matter. Developers running individual tests will use snapshots after manual changes on the system as that will save them time and the overall performance impact is limited. So, (not) using snapshots depends upon the use case.

regards, Siem

Hi,

There was no feedback from me for quite some time. I'm sorry for that but things are a bit crazy around here.

Anyway, thanks to your help I have a laptop running Fedora 30 and KVM on it, now. I've installed the packages Christian recommended in his earlier post. And last but not least I got a shiny new Windows 10 installation from our desktop services guys. So far so good.

VMware and VirtualBox have some kind of guest tools (open-vm-tools or the doomed VBox Guest Additions). Is there something similar for KVM? Chapter 11 in the Virtualization Deployment and Administration Guide mentions guest agents for rhel7. Where to get them for a Windows guest?

At the moment I use GNOME boxes or the console from virt-manager to access the VM. In both tools I see two mouse pointers. The one in the guest OS and the on from my Host which controles the mouse from the guest. But the mouse cursor from the guest is a bit laggy. Is there any option to optimize that? I hope you understand what I mean. If it is not clear please say so and I try to explain again. ;-)

Best regards,
Joerg

Hi Jörg,

There are no such things like Guest Additions necessary in KVM, everything works right out-of-the-box. :)
The package qemu-guest-agent and open-vm-tools should be automatically installed in Linux guests.
Regarding the "laggyness" : Make sure you're using the Video virtio drivers and not the Video QXL drivers.

Regards,
Christian

Hi Jörg,

As you know, I do not use Microsoft software - so unfortunately I can't test it for you. :)
But this guide should help you get going : https://wiki.qemu.org/Features/GuestAgent

Regards,
Christian

Hi,

For KVM ovirt-guest-agent was in use, but it has been deprecated for RHV4.3 (https://access.redhat.com/documentation/en-us/red_hat_virtualization/4.3/html/release_notes/deprecated_features_rhv). Please use qemu-guest-agent to obtain info from the VM.

regards, Siem

Hi,
I would like to share some feedback about the following topic:

At the moment I use GNOME boxes or the console from virt-manager to access the VM. In both tools I see two mouse pointers. The one in the guest OS and the on from my Host which controles the mouse from the guest. But the mouse cursor from the guest is a bit laggy.

Fedora 30 is using Wayland as default. And in wayland I see the two mouse pointers. So I switched to old X and the mouse pointer problem is gone. For me that's ok. So far it looks good, not long and VirtulBox will be gone. ;-)

Thanks for the update, Jörg. I don't face notable issues on Fedora 30 workstation - not in a Wayland session,
not in a X session ... Do you use the QXL video drivers by chance ? I'd recommend to use the virtio drivers. :)

No "mouse laggyness" at all while running virtual machines in a Wayland session, not much difference to Xorg.
The host mouse cursor should disappear when you click into the guest window though, whatever driver in use.

Regards,
Christian

Hi, At first I used the QXL driver and switched to virtio due to your recommendation.

But the laggy mouse pointer exists with the virtio driver, too.

Well Jörg, eventually this gets resolved in fedora 31 with many Wayland improvements included. :)

Regards,
Christian