Skip to content

Install Windows7 on KVM Qemu

romale edited this page Mar 2, 2020 · 8 revisions

If you plan to install Windows 7 on KVM/Qemu Hypervisor you would need to resolve few problems:

  • lockup on boot (ending with Starting Windows and animated logo)
  • need to have VirtIO disk and drivers for good IO performance

Setup for Ubuntu 16.04 LTS 64-bit

Install at least following packages in Ubuntu:

sudo apt-get install virt-manager qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils virt-viewer 

NOTE: You may need to Logout/Login after above installation to get membership in libvirtd group

Requirements

To install Windows 7 you need:

NOTE: According to https://fedoraproject.org/wiki/Windows_Virtio_Drivers QXL Graphics driver is included in virtio-win-0.1.103-1 and later Therefore we use 0.1.126 here (to fulfill this requirement)

Creating Win7 VM

  • Start Virtual Machine Manager (either from your favorite Desktop (LXDE), or issuing virt-manager from terminal).
  • Click on Icon Create a new virtual machine
  • Keep Local install media (ISO image or CDROM) selection and click on Forward
  • Select Use ISO image and Browse... to your Win7 installation DVD

NOTE: OS auto-detection failed in my case, so don't worry - you are not alone. Try to install libosinfo package.

  • Uncheck automatically detect OS...
  • select in listboxes:
    • OS Type: Windows
    • Version: Microsoft Windows 7
  • Click on Forward
  • Use proper CPU and Memory for Win7, reasonable minimums are:
    • 1x CPU
    • 2048MB of RAM
  • Keep selected Enable storage and Create disk image... - recommended size is 30GB or more.
  • Click on Forward
    • change Name: to something reasonable
    • Select check-box Customize configuration before install
  • Click on Finish

Now we need to adjust our configuration:

  • Click on IDE Disk 1
    • expand Advanced
    • change Disk bus to VirtIO
    • click on "Apply"
  • click on Display Spice
    • change Type: to VNC Server
    • click on Apply
  • click on Video QXL
    • change Model: to Cirrus
    • click on Apply
  • click on NIC: ...
    • change Device Model: to VirtIO
    • click on Apply
  • Remove Sound: ich6
  • click on Add hardware
    • select Storage
    • select Device Type: to CDROM Device
    • click on Finish
  • click on IDE CDROM 1 and change:
    • click on Connect and select your Windows 7 installation DVD ISO
    • enable checkbox Shareable
    • click on Apply
  • click on your IDE CDROM 2 and change:
    • click on Connect and select your virtio-win-0.1.118.iso
    • enable checkbox Shareable
    • click on Apply

NOTE: There is some rumor, that ordering DVD as Driver ISO First and OS ISO last will automatically load required drivers - but I had never such luck...

  • click on Boot options
    • check Enable Boot Menu
    • enable and reorder these entries so that boot menu looks like:
      • IDE CDROM 1
      • VirtIO Disk 1
      • ...others...
    • click on Apply

Now we need to add (temporarily) secondary QXL adapater, otherwise the Windows graphics drivers will be unable to install.

However - primary adapter must be (temporarily) Cirrus - otherwise Windows would have no chance to display installation setup.

Add QXL using:

  • Click on Add Hardware
    • Select Graphics
    • Keep Type: to Spice Server
    • Click Finish
  • again Click on Add Hardware
    • click on Video
    • Change Model: to QXL
    • click on Finish

Finally you can click on Begin installation

  • After a while a window Install Windows should appear
  • Click on Next
  • click on Install Now

NOTE: At any time you can use Ctrl-Alt to release mouse from KVM to X-Window

  • confirm license terms (but rather don't read them if you want to sleep well)
  • Click on Custom (Advanced) installation Type

NOTE: there should be warning No drives were found - it is expected...

  • do this to fix missing Disk Drive problem:
    • click on Load Driver
    • click on Browse
    • On DVD labeled virtio-win-0.1.1 Expand path to \viostor\w7\amd64
    • confirm driver Red Hat VirtIO SCSI controller clicking on Next
  • now there should be visible Disk 0 unallocated space
  • just click on Next - Windows should start Copying and Expanding files - the installation itself should take about 30minutes

After few reboots you should have Windows 7 desktop ready. However there are few things that need to be fixed...

Installing QEMU drivers

Windows 7 knows nothing about VirtIO (or KVM at all) - so you need to install proper drivers (with exception of Disk driver - it was already done in setup part).

  • hold Win+R and type devmgmt.msc to Run box
  • a Device Manager should appear
  • Right-click on Other Devices -> Ethernet Controller (with question mark)
    • Click on Update Driver Software...
    • choice Browse my computer for driver software
    • click on Browse... and choice your CD with virtio-win-0.1.1 label
    • ensure that Include subfolders is checked on - click on Next
    • confirm always trust sofwtare from "Red Hat, Inc."

Now you should have installed RedHat VirtIO Ethernet adapter

Repeat above steps for remaining Other devices:

  1. PCI Device -> should install VirtIO Balloon Driver
  2. PCI Simple Communications Controller -> VirtIO-Serial Driver
  3. Video Controller -> Red Hat QXL GPU

Windows Guest Agent

In your windows guest run from your virtio-win-0.1.1 ISO CD Guest agent - in a path like \guest-agent\qemu-ga-64.msi

Enable Accelerated Display Driver

  • Run again Device Manager
  • Verify that QXL is detected and working proberly - there should be a device in:
    • Display Adapters -> Red Hat QXL GPU
  • Shutdown your Windows Guest (thanks to Guest Agent it should be even possible to use Virtual Machine Manager -> Shut Down)
  • Switch Manager to i icon (Show Virtual Hardware Details)
  • Remove these devices:
    • Display VNC
    • Video Cirrus

Power on your Windows Guest - it should work with QXL/Spice now...

Spice can be verified using virsh for example:

virsh
virsh # list
 Id    Name                           State
----------------------------------------------------
 4     win7tutor                      running

virsh # domdisplay win7tutor
spice://127.0.0.1:5900

In Windows Guest you can verify or change your Adapater settings using:

  • Right-Click somewhere on Windows Desktop
  • click on Screen resolution
  • You should see Display: like: 1. (Default Monitor) on Red Hat QXL GPU

That's all.

Resources

Clone this wiki locally