How to run windows 10 as a kvm guest.

In this tutorial I want to talk about how to install Windows 10 x32/x64 as virtual machine (hereinafter VM) on the Linux system using KVM hypervisor.

You can install Windows 7 x32/x64 and Windows 8 x32/x64 without any problems. In internet you can find a lot of manuals and recommendations on how to install it.
Best practices for installation of Windows as a guest you can find on the proxmox wiki: http://pve.proxmox.com/wiki/Category:HOWTO
But, if you want to install Windows 10 you need to know some of the subtleties.

Be advised that: Proxmox specialists advise to use “write back” cache option for disk usage. Sometimes it can be unsafe and you should be careful doing it. Go to this link for more information. 

This tutorial has been tested on the:
# cat /etc/system-release
CentOS Linux release 7.1.1503 (Core)

# virsh -V
Virsh command line tool of libvirt 1.2.8
See web site at http://libvirt.org/

Compiled with support for:
 Hypervisors: QEMU/KVM LXC ESX Test
 Networking: Remote Network Bridging Interface netcf Nwfilter VirtualPort
 Storage: Dir Disk Filesystem SCSI Multipath iSCSI LVM Gluster
 Miscellaneous: Daemon Nodedev SELinux Secrets Debug DTrace Readline Modular

# qemu-system-x86_64 -version
QEMU emulator version 2.0.0, Copyright (c) 2003-2008 Fabrice Bellard


Short instruction:
If you want to install Windows 10 as a KVM guest system you have to use i440fx or Q35 chipset, set qemu-system-x86_64 as  an emulator and enable “nx” support  for processor.






Step by Step instruction:
To install Windows 10 x32 bit.
First of all,  you need to run the following:

# virsh capabilities

Output of this command must be:
…..
  <guest>
    <os_type>hvm</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/bin/qemu-system-x86_64</emulator>
      <machine maxCpus='255'>pc-i440fx-1.5</machine>

….
This means, that  you have support i440fx chipset, and you can run Windows 10 as a KVM guest system.

Please note: in this tutorial I suggest that you have already prepared your Linux host for virtualization.
After that, you need to download VirtIO drivers on ISO format from fedoraproject site.
We will be installing our VM to the LVM drive, let's create it:
lvcreate vg -n kvm_win_10_32 -L14G
I prefer to set VM  parameters from xml-file, let's create it:

<domain type='kvm'>
  <name>win_10_32</name>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-1.5'>hvm</type>
    <boot dev='cdrom'/>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu mode='custom' match='exact'>
    <model fallback='allow'>cpu64-rhel6</model>
    <feature policy='require' name='nx'/>
  </cpu>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='block' device='disk'>
          <driver name='qemu' type='raw' cache='none'/>
          <source dev=''/dev/vg/kvm_win_10_32”>
          <target dev='vda' bus='virtio'/>
    </disk>
    <disk type='file' device='cdrom'>
          <driver name='qemu' type='raw'/>
          <source file='/mnt/storage/Win-10-32.iso'/>
          <target dev='hdd' bus='ide'/>
          <readonly/>
        <address type='drive' controller='0' bus='1' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
          <driver name='qemu' type='raw'/>
          <source file='/mnt/storage/virtio-win-0.1.102.iso’/>
          <target dev='hdd' bus='ide'/>
          <readonly/>
        <address type='drive' controller='0' bus='1' target='0' unit='1'/>
    </disk>
    <controller type='usb' index='0'>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='ide' index='0'>
          <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
        <controller type='pci' index='0' model='pci-root'/>
    <serial type='pty'>
      <target port='0'/>
    </serial>
    <console type='pty'>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
    <video>
      <model type='cirrus' vram='16384' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
</domain>

Please note: You can find this xml in my github repository and download it.

In this XML we set machine name: win_10_32, machine RAM 1G, chipset: pc-i440fx-1.5
first boot device - cdrom, we use virtIO driver for primary block device. We don’t set any network interfaces.

We have to define new VM from the XML, run it and view:
virsh define win_10_32.xml
virsh start win_10_32
virt-viewer win_10_32 &

6. Let’s go ahead and make typical installation of Windows system. When you get to the step where you must select the storage drive for Windows installing you won’t see anything because typical Windows image doesn’t contain virtIO drivers. 
You should choose Load driver option and select the driver you need:


11.png

7. After that you have to follow Windows Setup instructions to install Windows 10.

I didn’t have any issues with installation of Windows 10 x32 bit but installing Windows 10 x64 I had the problem. It froze during installation process without any errors.

I’ve found the solution:

First of all, you need to install Windows 10 x64 on the Virtualbox using vdi hard drive file type,  then copy it to the centos server. Instead of vdi format you can also use qemu or vmdk.

Secondly, you need to convert vdi hard drive to the raw format:
qemu-img convert -f vdi -O raw win_10_64.vdi win_10_64.raw

Finally, you need to copy content of this file to the lvm volume using dd command:
dd if=win_10_64.raw of=/dev/vg/kvm_win_10_64

Following these simple steps, you will get a running virtual machine with Windows 10.

PS If you liked this article you can support me via PayPal: https://www.paypal.me/nmishin

Комментарии

Популярные сообщения из этого блога

How to work with authentication in Zookeeper?

How-to use cUrl for work with ZKUI.

Consul-template: how to run exec command, if file changed? Create a "watcher" via consul-template.