I set out to run an Xubuntu desktop, but I also want windows to play games. So instead of dual booting which is annoying, i used the gpu-passthrough method which allows the windows VM direct access to the GPU so it can run games with ease.
There are more tweaks you can do other than whats listed below, like dedicated ram (using hugepages) or a dedicated hard drive or ssd for the windows vm which will increase it’s performance.
CPU: Core i7-4790 (NB! Must support virtualization technology)
GPU: Radeon R9 280 (NB! must be UEFI capable)
Enable Virtualization options in bios, enable primary display as the intel gpu.
(we want the intel gpu for the xubuntu and the dedicated gpu for the windows vm)
Connect a monitor to the intel gpu and another monitor to the dedicated GPU.
Load up Xubuntu.
Install the required packages:
sudo apt-get update
sudo apt-get install qemu-kvm seabios qemu-utils ovmf virt-manager -y
- Next step is to isolate your dedicated gpu for use by the windows VM.
It should give you a list similar to this:
(we are looking for the device ID’s, in this case 1002:679a & 1002:aaa0)
01:00.0 VGA compatible controller : Advanced Micro Devices, Inc. [AMD/ATI] Tahiti PRO [Radeon HD 7950/8950 OEM / R9 280] [1002:679a]
01:00.1 Audio device : Advanced Micro Devices, Inc. [AMD/ATI] Tahiti XT HDMI Audio [Radeon HD 7970 Series] [1002:aaa0]
- Next we need to get xubuntu to load our Vm modules & black list the GPU so it’s free for the windows VM.
- Add the following lines:
- Modify the bootloader
- Modify the following line: (note: AMD cpu’s use amd_iommu=on)
- Update grub
- Blacklist the dedicated gpu so that xubuntu doesnt use it and it’s free for windows VM
- Add the following lines (The hardware ID’s we got above!)
- Rebuild the initramfs
To verify if you have successfully blacklisted the gpu you can run the following command:
(this will show you all devices captured by pci-stub for use in our VM)
- Next: Setup the VM. (I’m going to go into great detail as you should know what you need by now)
I used virtual machine manager GUI for this as it’s fast and easy. (virt-manager)
NB: Make sure you set the bios type to UEFI
- Click Add hardware
- Select “PCI Host Device”
- Select the AMD GPU
- Click finish (repeat the process for the AMD HDMI Audio)
If you’ve done this correctly, when you start the VM, the second monitor attached to the dedicated GPU will come to life with your VM.