Skip to content

Instantly share code, notes, and snippets.

@timohuovinen
Last active October 31, 2022 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timohuovinen/8178234d4ce8664411ca80eb9f17e5bc to your computer and use it in GitHub Desktop.
Save timohuovinen/8178234d4ce8664411ca80eb9f17e5bc to your computer and use it in GitHub Desktop.
Windows 10 guest virtual machine on linux mint 21 host using KVM and QEMU

KVM + QEMU (Free and Open Source, better than VirtualBox)

Windows 10 guest virtual machine on linux mint 21 host using KVM and QEMU
Host OS: Linux mint 21 amd64
Guest OS: Windows 10 pro amd64 with "TPM 2.0" and "Secure Boot"

  1. Enable virtualization (e.g. VT-x / AMD-V) in your BIOS / UEFI settings.
  2. Download: https://www.microsoft.com/en-us/software-download/windows10ISO
  3. Download: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
  4. Install KVM dependencies
sudo apt-get update
sudo apt-get -y install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager
sudo apt-get -y install qemu virt-viewer spice-vdagent
sudo apt-get -y install ovmf swtpm swtpm-tools
  1. Restart
  2. Open Virtual Machine Manager
    1. File > New virtual machine
    2. Local install media > Browse > Browse Local > Select downloaded windows ISO
    3. Pick RAM and CPU (can be changed later)
    4. Storage > Select or create custom storage > Manage > +
      1. Name: anything
      2. Format: raw
        1. For best performance choose the raw format. The qcow2 format offers some advanced features such as copy on write and live snapshots (Source: proxmox)
      3. Capacity: At least 32GB
      4. Allocate entire volume now > checked (for max performance)
      5. Finish
      6. Choose volume
    5. Forward
      1. Give some name to the machine
      2. Customize configuration before install > Check
      3. Finish
    6. Add Hardware > Storage > Select or create custom storage
      1. Manage > Select downloaded virtio ISO > Choose volume
      2. Device type: CDROM device
      3. Bus type: default (SATA)
      4. Finish
    7. Overview:
      1. Chipset: Q35
      2. Firmware: UEFI x86_64:/usr/share/OVMF/OVMF_CODE_4M.ms.fd (ms stands for emulated microsoft secure boot)
      3. Apply
    8. NIC
      1. Network source: NAT
      2. Device model: virtio
      3. Apply
    9. SATA Disk 1
      1. Disk bus: VirtIO
      2. Advanced options:
        1. Cache mode
          1. None: safety during power outage
          2. writeback: for max performance (details)
      3. Apply
    10. Boot Options
      1. Check both CDROMs
      2. Apply
    11. Add Hardware
      1. TPM
        1. Type: Emulated (or passthrough)
        2. Advanced options > version > 2.0
      2. Finish
    12. Begin Installation
  3. Install windows
    1. Start it, it might show a weird UEFI screen, type exit
    2. Boot menu > pick boot from CD
    3. Install windows
    4. No HDD found?
      1. Load Driver > Browse > CD Drive (E:) > viostor > w10 > amd64 > Next
      2. Load Driver > Browse > CD Drive (E:) > NetKVM > w10 > amd64 > Next
      3. Load Driver > Browse > CD Drive (E:) > qxldod > w10 > amd64 > Next
      4. Next
  4. In windows Guest OS
    1. Open the virtio drivers CD
    2. Run virtio-win-guest-tools.exe

Bonus: Add and run a virtual machine using a command (does not work)

sudo virt-install \
--name Windows_10 \
--ram 6144 \
--disk path=/home/th/kvm/images/Windows_10.img,size=50 \
--cpu host-passthrough \
--vcpus=4 \
--os-variant=win10 \
--network bridge=br0 \
--graphics vnc,listen=0.0.0.0,password=password \
--video virtio \
--cdrom /home/th/Downloads/Win10_22H2_EnglishInternational_x64.iso \
--features kvm_hidden=on,smm=on \
--tpm backend.type=emulator,backend.version=2.0,model=tpm-tis \
--boot loader=/usr/share/OVMF/OVMF_CODE.secboot.fd,loader_ro=yes,loader_type=pflash,nvram_template=/usr/share/OVMF/OVMF_VARS.ms.fd 

Sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment