Converting VDI to QCOW2 | Step-by-Step Guide for Virt-Manager Migration

Virtualization is one of the great gifts of modern computing. I have used Virtualbox, primarily, for Windows based VMs because certain things in Virtualbox work just so much easier than Virt-Manager. The problem is, I am using Virt-Manager primarily for all the non-Windows stuff because I prefer the improved performance I experience. The other problem with Virt-Manager is that a lot of the VM creature comforts built into Virtualbox isn’t quite as regularly available.

This is a guide, to take VDI image of Windows 10 from VirtualBox and migrating it over to Virt-Manager while also adding some other bits to provide all the nice features you have grown to enjoy on VirtualBox like clipboard sharing and automatic screen rescaling and exposing the file system of the Linux host OS to the Windows guest OS

Converting VDI to QCOW2

The first step in this process is to locate the VDI of the virtual machine you want to move to Virt-Manager. The default as of late is a folder in the home directory:

~/Virtualbox VMs

Within the VM directory, locate the VDI file and convert the file. The way I did it, to keep my life simple is to go into the terminal and navigate to that location.

Note: Due to the spaces in the folder names, the backslash \ is an escape character to allow for the use of spaces in the terminal. Alternatively, you can use quotes but the easiest way is to start typing the location and use the Tab key to auto fill the location.

cd ~/VirtualBox\ VMs/Windows10/

Within the directory of the VDI image, I run this to convert it into the QCOW format

qemu-img convert -f vdi -O qcow2 Windows10.vdi Windows10.qcow2 

To explain the options -f is the input image type and -O is the output image type.

This does take a while, depending on the size of the file and the speed of your system. It also looks like nothing is happening for a while, when it does complete, the terminal will return to the command prompt.

For more information on the qemu-img options. See this page:

https://www.qemu.org/docs/master/tools/qemu-img.html

To verify that the conversion was a success, you can type ls -lh to see that the size of the qcow2 is a reasonably appropriate size, so, something in the GB range. I would also recommend you put it where QCOW2s are normally stored for Virt-Manager.

~/.local/share/libvirt/images

This is not required but I would recommend it for organizational purposes. You know, keep all the QCOW2 images in the same spot.

Import QCOW2 into Virt-Manager

After the conversion is completed and it passed the size test (or even if you don’t think it did), you need to import it into Virt-Manager.

If you do not immediately see the new image in the list, select Browse Local and locate the VM.

Select the qcow2 you want, then Choose Volume.

In the next step, be sure to choose the operating system. This does set up some of the specifications for your convenience.

If you want to allocate some more resources to this VM here is the place to do it now.

Set the desired name for the VM and finish in import.

Enable Clipboard Sharing

The next big challenge with Virt-Manager is that clipboard sharing doesn’t work by default. This is easy enough to fix. Start with Downloading the Spice Guest Tools on the Windows VM.

https://www.spice-space.org/download/windows/spice-guest-tools/spice-guest-tools-latest.exe

Run this and proceed with the installation.

Once installed you will now have your working bi-directional clipboard. Test it out!

Shared Folder with Host

Another great feature to have is to be able to share data from the host operating system to the guest operating system. To get this rolling open the Windows VM but ensure that the guest operating system is shut down.

Configure Virt-Manager

Open the Virtual machine and select Show virtual hardware details icon. In the list of topics, Select Memory and Enable shared memory then select Apply.

Select Add Hardware to add new Virtual Hardware.

Under the Filesystem category select the virtiofs driver.

For the Source path enter the folder path for the location you want to share.

The Target path is the name that will be presented to the guest OS.

WinFsp | FUSE for Windows

In order for Windows to be able to mount the Linux shares or for even the Guest tools (next step) to even start, you need to have the components from this gem of an application.

https://github.com/winfsp/winfsp/releases

Be sure that the Core portion is being installed of the WinFsp files. Nothing else is needed in this portion of the installation.

VirtIO Guest Tools

The VirtIO Guest tools are essential components for improving the performance and functionality on hypervisors like KVM/QEMU. This is especially necessary for passing through the host file system to the virtual machine. To install this follow this link.

https://fedorapeople.org/groups/virt/virtio-win/direct-downloads

Select stable-virtio then select virtio-win-guest-tools.exe

Install the Application. The default setup can be left as it is but be sure that the Viofs module is installed. Upon completion, select to Restart the VM.

Open Device Manager and be sure that you see VirtIO FS Device under System Devices.

Open up Services, find VirtIO FS Service and Start the service

If you would like this service to start at each time you boot VM, right click on the VirtIO FS Service, select Properties and change the Startup type from Manual to Automatic.

Open up File Manager, navigate to This PC and you can now observe that drive Z: is the host_documents folder previously specified.

Automatic Resizing VM

This works and also doesn’t work so it may be an issue with my specific system, but I can confirm that when it does work, this is what I have done to make it happen. In the menu at the top of the VM window select View > Scale Display > Auto resize VM with window.

What is odd here is that on my main display which is scaled at 125%, the VM won’t always resize with the window but on one of my displays scaled at 100%, which are 1080p, the window will resize without any issue. Further investigation is needed here but I have mitigated the issue by setting the resolution to something very close on the guest OS./

Final Thoughts

I’m not really a fan of Windows. I have, however, been requiring it for a few functions. I do think that this is a rather painfully lengthy process to get something that is so easily obtained with VirtualBox running in Virt-Manager / KVM. I don’t actually notice any performance improvements between these two hypervisors but I am sure that there is a difference. The main benefit here is that I don’t have to carry around a Windows laptop along with my openSUSE Linux machine to get my work done. I can just have the Windows VM open on a virtual desktop and do the few tasks that I am just not able to accomplish in Linux. I don’t necessarily keep it running either. Ultimately, I will have to fine a different set of applications to accomplish this but that is rather low on my priority scale right now.

It would be nice if all this could be wrapped up into a single click and go process, much as it is on VirtualBox. The additional features are easy to install on the VirtualBox application and the guest side can easily have an ISO mounted to it at the click of a button. I do believe that the user experience is really quite nice when you are running VirtualBox. It would be a welcome improvement to Virt-Manager to have these functions built in too.

The auto resizing of the guest windows is not as clean as it is in VirtualBox. It is a bit unreliable in how it behaves. This is annoying but not a deal breaker. I just wish it was a bit more polished.

All that said. If not for my need to run several other VMs somewhat regularly and it is not possible to run KVM at the same time as VirtualBox, it was necessary to make this move. KVM with Virt-Manager has been great in my current line of work on many accounts. I appreciate how easily I am able to accomplish many of the tasks I wish with great efficiency. There just happens to be some room for improvement.

References

https://virt-manager.org/
https://www.qemu.org/docs/master/tools/qemu-img.html
https://markontech.com/posts/convert-virtualbox-vms-to-qemu-kvm/
https://dausruddin.com/how-to-enable-clipboard-and-folder-sharing-in-qemu-kvm-on-windows-guest/
https://www.debugpoint.com/kvm-share-folder-windows-guest/

Leave a Reply