stafwag Blog

staf wagemakers blog

Migrate a Windows Vmware Virtual Machine to Linux KVM

Linux KVM is getting more and more useable for desktop virtualization thanks to the the virtio and QXL/SPICE drivers.

Most Linux distributes have the virtio & QXL drivers you might need to install the spice-vdagent.

On Windows you can download and install the virtio and QXL drivers.

Using the virtio drivers will improve your guest system performance and your virtualization experience.

Convert the disk image

merge the vmware disk images…

If you use split disk images on vmware ( or vmware player ) migrate them to a single disk images with the vmware-vdiskmanager command.

1
2
3
4
5
$ vmware-vdiskmanager -r mywin.vmdk -t 0 /tmp/mywin._combined.vmdk
Creating disk '/var/lib/libvirt/images/tmp/mywin._combined.vmdk'
  Convert: 100% done.
Virtual disk conversion successful.
$

convert the vmdk image to qcow2

Convert the VMDK disk image to qcow2

1
[staf@vicky vboxes]$ qemu-img convert -f vmdk -O qcow2 mywin._combined.vmdk mywin.qcow2

mv

1
2
[staf@vicky vboxes]$ sudo mv mywin_combined.qcow2 /var/lib/libvirt/images/
[sudo] password for staf: 

Import the disk image to KVM

We’ll inport the disk image with virt-install it’s also posible to import the images with virt-manager if you prefer a graphical interface or or just being lazy :-)

Available os options

To list the supported operation system you can use the osinfo-query os command

1
2
3
4
5
6
7
8
9
10
11
[staf@vicky ~]$ osinfo-query os | head
 Short ID             | Name                                               | Version  | ID                                      
----------------------+----------------------------------------------------+----------+-----------------------------------------
 alpinelinux3.5       | Alpine Linux 3.5                                   | 3.5      | http://alpinelinux.org/alpinelinux/3.5  
 alpinelinux3.6       | Alpine Linux 3.6                                   | 3.6      | http://alpinelinux.org/alpinelinux/3.6  
 alpinelinux3.7       | Alpine Linux 3.7                                   | 3.7      | http://alpinelinux.org/alpinelinux/3.7  
 altlinux1.0          | Mandrake RE Spring 2001                            | 1.0      | http://altlinux.org/altlinux/1.0        
 altlinux2.0          | ALT Linux 2.0                                      | 2.0      | http://altlinux.org/altlinux/2.0        
 altlinux2.2          | ALT Linux 2.2                                      | 2.2      | http://altlinux.org/altlinux/2.2        
 altlinux2.4          | ALT Linux 2.4                                      | 2.4      | http://altlinux.org/altlinux/2.4        
 altlinux3.0          | ALT Linux 3.0                                      | 3.0      | http://altlinux.org/altlinux/3.0        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[staf@vicky ~]$ osinfo-query os |  grep -i windows
 win1.0               | Microsoft Windows 1.0                              | 1.0      | http://microsoft.com/win/1.0            
 win10                | Microsoft Windows 10                               | 10.0     | http://microsoft.com/win/10             
 win2.0               | Microsoft Windows 2.0                              | 2.0      | http://microsoft.com/win/2.0            
 win2.1               | Microsoft Windows 2.1                              | 2.1      | http://microsoft.com/win/2.1            
 win2k                | Microsoft Windows 2000                             | 5.0      | http://microsoft.com/win/2k             
 win2k12              | Microsoft Windows Server 2012                      | 6.3      | http://microsoft.com/win/2k12           
 win2k12r2            | Microsoft Windows Server 2012 R2                   | 6.3      | http://microsoft.com/win/2k12r2         
 win2k16              | Microsoft Windows Server 2016                      | 10.0     | http://microsoft.com/win/2k16           
 win2k3               | Microsoft Windows Server 2003                      | 5.2      | http://microsoft.com/win/2k3            
 win2k3r2             | Microsoft Windows Server 2003 R2                   | 5.2      | http://microsoft.com/win/2k3r2          
 win2k8               | Microsoft Windows Server 2008                      | 6.0      | http://microsoft.com/win/2k8            
 win2k8r2             | Microsoft Windows Server 2008 R2                   | 6.1      | http://microsoft.com/win/2k8r2          
 win3.1               | Microsoft Windows 3.1                              | 3.1      | http://microsoft.com/win/3.1            
 win7                 | Microsoft Windows 7                                | 6.1      | http://microsoft.com/win/7              
 win8                 | Microsoft Windows 8                                | 6.2      | http://microsoft.com/win/8              
 win8.1               | Microsoft Windows 8.1                              | 6.3      | http://microsoft.com/win/8.1            
 win95                | Microsoft Windows 95                               | 4.0      | http://microsoft.com/win/95             
 win98                | Microsoft Windows 98                               | 4.1      | http://microsoft.com/win/98             
 winme                | Microsoft Windows Millennium Edition               | 4.9      | http://microsoft.com/win/me             
 winnt3.1             | Microsoft Windows NT Server 3.1                    | 3.1      | http://microsoft.com/winnt/3.1          
 winnt3.5             | Microsoft Windows NT Server 3.5                    | 3.5      | http://microsoft.com/winnt/3.5          
 winnt3.51            | Microsoft Windows NT Server 3.51                   | 3.51     | http://microsoft.com/winnt/3.51         
 winnt4.0             | Microsoft Windows NT Server 4.0                    | 4.0      | http://microsoft.com/winnt/4.0          
 winvista             | Microsoft Windows Vista                            | 6.0      | http://microsoft.com/win/vista          
 winxp                | Microsoft Windows XP                               | 5.1      | http://microsoft.com/win/xp             
[staf@vicky ~]$ 

import

We need to import the disk image as IDE device since we don’t have the virtio driver in our windows disk image (yet).

1
2
3
4
5
[root@vicky ~]# virt-install --name "mywin" --ram 8192 --cpu host --os-variant win10 --vcpu 8 --disk /var/lib/libvirt/images/mywin_combined.qcow2,bus=ide --network bridge=virbr0 --import

Starting install...

(virt-viewer:3361): GSpice-WARNING **: 16:49:26.546: Warning no automount-inhibiting implementation available

Install the virtio drivers and QXL graphics drivers

Get them…

Type of virtio drivers

The following virtio windows drivers are available.

  • block (disk drivers)
  • network
  • baloon ((dynamic memory management)

The fedoraproject provides pre compiled iso images containig all the virtio drivers and installation images for windows XP.

ISO contents

  • NetKVM/ - Virtio network driver
  • viostor/ - Virtio block driver
  • vioscsi/ - Virtio Small Computer System Interface (SCSI) driver
  • viorng/ - Virtio RNG driver
  • vioser/ - Virtio serial driver
  • Balloon/ - Virtio memory balloon driver
  • qxl/ - QXL graphics driver for Windows 7 and earlier. (build virtio-win-0.1.103-1 and later)
  • qxldod/ - QXL graphics driver for Windows 8 and later. (build virtio-win-0.1.103-2 and later)
  • pvpanic/ - QEMU pvpanic device driver (build virtio-win-0.1.103-2 and later)
  • guest-agent/ - QEMU Guest Agent 32bit and 64bit MSI installers
  • qemupciserial/ - QEMU PCI serial device driver
  • *.vfd VFD floppy images for using during install of Windows XP

Download

The virtio windows driver images are available from https://docs.fedoraproject.org/quick-docs/en-US/creating-windows-virtual-machines-using-virtio-drivers.html

I use arch linux and download virtio-win AUR package with pacaur. You can download the images directly or use the installation packages for your Linux distribution.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[staf@vicky ~]$ pacaur -S virtio-win
:: Package virtio-win not found in repositories, trying AUR...
:: resolving dependencies...
:: looking for inter-conflicts...

AUR Packages  (1) virtio-win-0.1.149.2-1  

:: Proceed with installation? [Y/n] 
<snip>
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: virtio-win 0.1.149.2-1 (Sat Jun 16 20:00:22 2018)
==> Cleaning up...
:: Installing virtio-win package(s)...
loading packages...
resolving dependencies...
looking for conflicting packages...

Packages (1) virtio-win-0.1.149.2-1

Total Installed Size:  314.84 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                         [#######################################] 100%
(1/1) checking package integrity                                       [#######################################] 100%
(1/1) loading package files                                            [#######################################] 100%
(1/1) checking for file conflicts                                      [#######################################] 100%
(1/1) checking available disk space                                    [#######################################] 100%
:: Processing package changes...
(1/1) installing virtio-win                                            [#######################################] 100%
Optional dependencies for virtio-win
    qemu [installed]
:: Running post-transaction hooks...
(1/1) Arming ConditionNeedsUpdate...
[staf@vicky ~]$ ls -l /var/li

This install virtio images to /usr/share/virtio/

1
2
3
4
5
6
[staf@vicky ~]$  ls -l /usr/share/virtio/
total 321308
-rw-r--r-- 1 root root 324233216 Jun 16 19:58 virtio-win.iso
-rw-r--r-- 1 root root   2949120 Jun 16 19:58 virtio-win_x86_32.vfd
-rw-r--r-- 1 root root   2949120 Jun 16 19:58 virtio-win_x86_64.vfd
[staf@vicky ~]$ 

virtio-win.iso is the ISO cdrom image containing all the drivers.

Installation

mount the iso image

"mount_cdrom_000.png"

Make sure that the cdrom is mounted in windows.

"mount_cdrom_000.png"

Install

Open Device Manager

Open device Manager in the control panel or type devmgmt.msc on the command prompt.

"mount_cdrom_000.png"

Update the drivers

  • balloon, the balloon driver affects the PCI device
  • vioserial, affects the PCI simple communication controler
  • NetKVM, the network driver affects the Network adapters.
  • viostor, the block driver affects the Disk drives.
Update the PCI drivers

In windows 10 the PCI device and the PCI Simple Communications Controller have the missing driver icon. Right click on the PCI device and select update driver -> click on Browse my computer for driver software Specify the cdrom as the search location and click Next, this will install the Balloon driver.

Do the same for the PCI Simple Communications Controller this will install the “VirtIO Serial Driver”

"update_pci_000.png" "update_pci_001.png" "update_pci_002.png" "update_pci_003.png"

install the VioStor driver

Add a temporary disk to the virtual machine and use VirtIO as the Bus Type In the Device Manager you’ll get a new device SCSI Controller right click it and update the driver. This will install the Red Hat VirtIO SCSI controller

"install_viostor_000.png" "install_viostor_001.png" "install_viostor_002.png"

Go to the device settings of your virtual machine and change the Disk bus to VirtIO and shutdown you virtual machine.

"install_viostor_003.png"

You can remove the temporary disk now or leave it if you can find some use for it…

Make sure that you disk is selected as the bootable device.

"install_viostor_004.png"

Start the virtual machine and make sure that the system is bootable.

install the netKVM driver

Update the Device model to virtio.

"use_virtio_net_000.png"

Start devmgmt.msc and update the driver as we did before….

"install_netkvm_000.png" "install_netkvm_001.png"

And verify that you network card works correctly.

"install_netkvm_002.png"

install the QXL graphical driver

Update the Microsoft Basic Display Adapter

"install_qxl_000.png" "install_qxl_001.png" "install_qxl_002.png"

After the installation you can change the the display resolution.

"install_qxl_003.png"

If you want to use higher screen resolutions you need to increase the video ram

Have fun!

Links

Comments