Debian Wheezy Gaming with KVM (BF3)

WARNUNG WARNUNG WARNUNG

Dieser Artikel ist auf Englisch. Solltest du dieser Sprache nicht mächtig sein wirst du vermutlich auch nicht zur Einrichtung fähig sein.

WARNING WARNING WARNING

This is a very advanced guide. This is NOT a Step by Step guide. You have to be skilled with Linux or YOU WILL FAIL.

 

There are a lot of people like me who would love to only run Linux on their main rig but need a native Windows Install for DX11 Games like Battlefield 3.

Wine doesn’t support them and Virtual machines are just too slow. Not anymore. Don’t believe me? This is my 3dmark11 Score in KVM

Using a recent Kernel with CONFIG_VFIO_PCI_VGA=y you can pass through a real GPU and use its real performance.

Here’s a demo Video by someone else:

You will need:

  • A CPU with VT-d or VT-x
  • Multiple Monitors
  • At least 2 GPUs (Intel iGPU is fine)
  • Linux
  • A Windows ISO Image
  • Spare Time

My Setup:

  • Asrock z77 Fatal1ty Performance
  • i5-3570
  • 8GB Ram
  • GTX 680
  • Debian Wheezy

 

The first thing you will have to do is compiling the latest stable Kernel with said option. If you want to use your Intel GPU for Linux you will also need to patch the Kernel beforehand with this patch.

Next step is installing qemu and qemu-kvm from the wheezy-backports repository. Add „intel_iommu=on i915.enable_hd_vgaarb=1“ to your kernel commandline. (If you have an Intel CPU and want to use the Intel GPU)

Add the following modules to /etc/modules: pci_stub vfio vfio_iommu_type1 vfio_pci kvm kvm_intel

Find out what the PCI ID of your NVIDIA GPU is (lspci -nn | grep NVIDIA) and add it to /etc/initramfs-tools/modules like so: pci_stub ids=10de:1180

Run update-initramfs -u afterwards.

Install the Kernel and reboot.

Next step is to create a file for the virtual HDD using dd (80GB): dd if=/dev/zero of=windows.img bs=1M seek=80000 count=0

echo 0000:01:00.0 > /sys/bus/pci/devices/0000\:01\:00.0/driver/unbind
echo 0000:01:00.1 > /sys/bus/pci/devices/0000\:01\:00.1/driver/unbind
echo 10de 1180 > /sys/bus/pci/drivers/vfio-pci/new_id
echo 10de 0e0a > /sys/bus/pci/drivers/vfio-pci/new_id

Run this (as root) (but don’t forget to change the IDs to your values. Use lspci to find them) everytime you want to boot your VM but only once every Linux boot.

This is my command line to launch the VM ( You will need to edit IDs and paths. The links at the end of this Article will help you.)

qemu-system-x86_64 -enable-kvm -M q35 -m 4096 -cpu host,kvm=off -smp 4,sockets=1,cores=4,threads=1 -bios /usr/share/qemu/bios.bin -vga none -device ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 -device piix4-ide,bus=pcie.0,id=piix4-ide -device vfio-pci,host=01:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on -device vfio-pci,host=01:00.1,bus=pcie.0 -usb -usbdevice host:17ef:6009 -soundhw ac97 -drive file=/home/hypfer/windows_kvm_v1.img,id=disk,format=raw -device ide-hd,bus=piix4-ide.0,drive=disk -drive file=/home/hypfer/Win7_64Bit_Professional_digitalriver.iso,id=isocd -device ide-cd,bus=piix4-ide.1,drive=isocd -device ich9-intel-hda,bus=pcie.0,addr=1b.0,id=sound0 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0

 

 

To find out more about this topic I suggest looking at the following links

https://bbs.archlinux.org/viewtopic.php?id=162768

https://wiki.debian.org/VGAPassthrough

http://vfio.blogspot.de/2014/08/vfiovga-faq.html

http://www.pugetsystems.com/labs/articles/Multiheaded-NVIDIA-Gaming-using-Ubuntu-14-04-KVM-585/

 

As always, you can write a comment if you need help with this and I will try my best to fix your problem.

Tagged , . Bookmark the permalink.

One Response to Debian Wheezy Gaming with KVM (BF3)

  1. Very nice! I will be moving from vSphere to KVM soon. I currently use vSphere’s IOMMU tech but I’d like Linux OS for BTRFS & KVM/vpio Geforce passthrough functionality. Will be cool to have a more functional base OS as well. Thanks for the guide!

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.