[TUTORIAL] Windows 11 VM for gaming setup guide

MichaelBernasconi

New Member
Dec 3, 2023
12
16
3
I just finished migrating my Windows 11 gaming VM from Unraid to Proxmox. Along the way I encountered some obstacles. To hopefully save other people some time I'm writing a detailed guide here on how I set up my system.

Disclaimer: I am by no means an expert on this stuff. It is entirely possible that I made some mistakes in this setup. If you notice something that is clearly wrong or something that could be improved please add your suggestions in the comments.

ProxmoxVE Version
I am writing this guide using ProxmoxVE version 8.1.3.

Hardware
This guide works for the following hardware:
CPU: Ryzen 7950x​
Mainboard: Gigabyte X670 Gaming X AX​
GPU1: RTX A6000 (in main PCIe slot and not used for the Windows VM)​
GPU2: RTX 3070 (in second PCIe slot and used for the Window VM)​
Note: You have enable a bunch of virtualization options in the BIOS. Essentially enable everything setting that has "virtualization", "VT", or "IOMMU" in the name.

Checking IOMMU Groups
The first step is checking your IOMMU groups. Open a shell and run pvesh get /nodes/{nodename}/hardware/pci --pci-class-blacklist "". Here, {nodename} refers to the name you gave to your proxmox server. This should give you a list of all your PCIe devices which their respective IOMMU group. Find the GPU you want to pass to your VM and check if there are any other devices in the same IOMMU group. If there are no other devices in the same IOMMU group you can skip the next step.

Splitting IOMMU Groups
Disclaimer: Splitting your IOMMU groups has some security implications! Please read up on it and decide if this is acceptable for your use case! Don't just blindly follow what some guy wrote on the internet!

So...your GPU was not in it's own IOMMU group. This can be fixed by adding pcie_acs_override=downstream,multifunction to the kernel parameters.
Most of the guides I found online tell you to edit the kernel parameters in /etc/default/grub. However, my installation of proxmox does not grub. Instead it uses systemd-boot. So in my case I had the kernel parameters to /etc/kernel/cmdline.

The /etc/kernel/cmdline file now looks like this for me:
root=ZFS=rpool/ROOT/pve-1 boot=zfs pcie_acs_override=downstream,multifunction
In order for the change to take effect you need to run update-initramfs -u and then reboot the server.

Once the server is rebooted you can verify that the kernel parameters were actually added by running cat /proc/cmdline. If you don't see pcie_acs_override=downstream,multifunction in the output it did not work. Either you did something wrong or your installation might be using grub instead of systemd-boot.

Now run pvesh get /nodes/{nodename}/hardware/pci --pci-class-blacklist "" and verify that your GPU is in it's own IOMMU group. You might notice that your GPU was split into two devices - a VGA device and an audio device. Don't worry. This is fine. What is important is that no other devices share an IOMMU group with your GPU.

Getting the GPU ready for passthrough
In order for GPU passthrough to work you need to ensure two things. First, some vfio kernel modules need to be loaded, and second, the GPU driver itself must not be loaded.

To make sure the vfio kernel modules are available add the three lines
vfio
vfio_iommu_type1
vfio_pci
to /etc/modules. Now run update-initramfs -u and reboot the server. Once the server is rebooted run lsmod and verify that the three modules are actually available.

To make sure that GPU drivers are not loaded you must blacklist them in /etc/modprobe.d/. I added the lines
blacklist nvidiafb
blacklist nouveau
blacklist nvidia*
to the file /etc/modprobe.d/pve-blacklist.conf. You could also create a separate .conf file in the same folder if you want to keep things separated. Now run update-initramfs -u and reboot the server. Once the server is rebooted run lspci -nnk and look for your GPU. If there is a line Kernel driver in use: <some_driver> your GPU still has a driver loaded. Add that driver to the blacklist, run update-initramfs -u, reboot, and check again. If the Kernel driver in use: <some_driver> line is no longer there you are good to go.

Create a VM
Since we are setting up a gaming VM we want to make sure that (1) the VM performs well and (2) the VM does not know it's a VM. The reason why we don't want the VM to know it's a VM is because some anti cheat software (like EasyAntiCheat) will not let you play on a VM. It goes without saying...please don't cheat in games.

Disclaimer: Not all of the following steps might be necessary for Window 11 to not know it's running in a VM. The following setting did, however, give me a VM which did not know it was a VM and the performance is nearly identical to a bare metal Windows 11 install. So I'm not gonna spend the time to test all possible combinations to figure out which settings are really needed.

Step 1: Get a Windows 11 iso
Step2: Upload the iso to Proxmox using the WebGUI (Datacenter -> {nodename} -> local(nodename) -> ISOImages -> Upload
Step3: Click on "Create VM" (top right in the GUI)
Step4 (General): Give your VM a name and an ID. Also select the "Advanced" option at the bottom of the window. We'll need some advanced settings later.
Step5 (OS): Select the ISO you uploaded and select "Microsoft Windows" as the Guest OS type. Note: We do not need any VirtIO drivers!
Step6 (System):
  • Graphics card: Default
  • Machine: q35
  • BIOS: OVMF (UEFI)
  • Add EFI Disk: yes
  • SCSI Controller: LSI 53C895A
  • Qemu Agent: no
  • Add TPM: yes
Step7 (Disks):
  • Bus/Device: SATA
  • Cache: Write back
Step8 (CPU):
  • Sockets: 1
  • Cores: However many cores you want
  • Type: host
Step9 (Memory):
  • Memory: however much memory you want
  • Ballooning Device: no
Step10 (Network):
  • Model: Intel E1000
Step11: Confirm your settings, create the VM, but don't start it yet!

Note: The reason why we choose LSI for our SCSI controller, SATA for your disks, and the Intel E1000 network card is because we don't need any virtio drivers for any of those. In my experience, as soon as you add the Qemu gest agent or add any virtio drivers, Windows knows it's a VM.

Now, we add our GPU to the VM.
Select your VM in the menu on the left, then click on "Hardware". Now click "add" and select "PCI Device". Select "Raw Device" and find your GPU in the drop down menu. Make sure you select the GPU and not the audio controller! Tick the "Primary GPU" and "PCI-Express" boxes. For the "PCI-Express" box you need to select "Advanced" at the bottom of the window. Do not select the "All Functions" checkbox!
Repeat the process for the GPUs audio device but this time don't tick the "Primary GPU" checkbox.

Do not start the VM yet! We need some additional settings.
Run dmidecode -t 0 and dmidecode -t 1. This gives you some information about your mainboard.
Navigate to your VM in the webGUI and select Options -> SMBIOS settings (type1). Enter as much information as you can find there. For me this is:
UUID: <redacted>
Manufacturer: Gigabyte Technology Co., Ltd.
Product: X670 GAMING X AX
Family: X670 MB
Then, add the following line at the top of the VM config file (/etc/pve/qemu-server/<your_vmid>.conf).
args: -cpu host,-hypervisor,kvm=off, -smbios type=0,vendor=<vendor>,version=<version>,date=<date>
For me this looks like this:
args: -cpu host,-hypervisor,kvm=off, -smbios type=0,vendor="American Megatrends International",version=F8,date="07/10/2023"
Note: Don't forget the quotes for strings with spaces!
Finally, add the hidden=1 option to the cpu. That is, change the line
cpu: host
to
cpu: host,hidden=1

That's it! You are now ready to install windows. Of course you will need a mouse and keyboard attached to the VM to do that. Both can be added to the VM in the "Hardware" tab. Select add -> USB Device, find your mouse and keyboard, and click on add. Now, start the VM.
Note: As soon as the VM starts you need to press a key to boot from the CD. So be ready to press some key!
Note2: If you don't want to deal with a Microsoft account here is a guide on how to avoid that.

Once windows is installed, open the task manager and check whether or not windows thinks it a VM or not. If it thinks it's a VM it will it will say "Virtual machine: Yes". Let's hope it does not say that ;)
Assuming Windows did not detect it is running in a VM press CTRL+R, and start "msinfo32". The entries for your systems Manufacturer and Model, and the BIOS Version/Date should match what you entered earlier. If it says anything am QEMU or any other VM related stuff there EasyAnitCheat will probably detect it (at least in my experience).
Assuming everything looks good you are now ready to install some games and give it a test.

USB passthrough
Passing through USB devices using the WebGUI does work but in my experience it can be a bit hit or miss with headsets and xbox controllers. Also, everything crashes if you accidentally unplug the USB device.
A better solution is passing through a whole USB controller (just like the GPU). So let's see how this can be done.
In theory it's the same as passing through the GPU. In practice it's way more work.

Step1: Figure out which USB ports are connected to the same root USB controller.
To do this run lsusb -t. This shows you all your usb root hubs with their associated ports. To figure out where each port is physically take some usb device, plug it into every physical port, and check each time where it shows up. Once you have happed all the ports, find a usb root hub that is in its own IOMMU group.
Note: If you haven't already you will probably need to split your IOMMU groups now. Splitting the IOMMU groups will change the IOMMU group of your GPU! So you might need to adjust it in the VM config.

Step2: Once you have identified a USB root hub that is in its own IOMMU group you pass it through to the VM just like the GPU. The only difference it that you do not check the "Primary GPU" and the "PCI-Express" check boxes.

Try to start your VM. If it starts you should be able to use the USB ports, which are associated with the USB root hub you passed through, just like a normal USB port.
In my case this would work if nothing was plugged into the USB port when the VM was started. If there was something plugged into the USB port when the VM was starting the whole system would crash, shut off, and then reboot. I think this is due to some issue with the kernel driver not unloading properly which causes the vfio-pci driver not to load. I found two solutions to the problem.

Solution 1: Before starting the VM manually unload the driver by running echo "<PCI ID of the usb root hub>" > /sys/bus/usb/drivers/<the_driver>/unbind. To check which driver is loaded for the usb root hub run lspci -nnk.

Solution 2: The nuclear option. Simply blacklist all the drivers which bind to the USB controller. In my case adding
blacklist xhci_hcd
blacklist xhci_pci
to /etc/modprobe.d/pve-blacklist.conf fixed the issue.

Final thoughts
I hope this was helpful to at least one person struggling to get a VM up and running. If you notice any mistakes or think anything is unclear please leave a comment.
 
OK - I am close to getting things working... I have a Gigabyte RTX 3060 isolated and mapped to a new VM. I have tried the various edits you mentioned to 'mask' the VM but I get BSOD immediately on booting the iso to install. I had to remove these three "args: -cpu host,-hypervisor,kvm=off" to get ti stable - but Task manager does say VM. I will try various combinations to see if I can convince it not to be a VM - but so far no dice. The rest of the notes were great and much appreciated. The case case may not be impacted by anti-cheat so it's not a huge priority for me.
 
Following here since I am trying to do the same.

Adding this Line to args: -smbios type=0,vendor="American Megatrends Inc.",version=1903,date="08/30/2023" gives me a QEUMU error on start up. If I delete this with the kvm off etc. It starts up but is still showing a virtual machine. Any ideas?

swtpm_setup: Not overwriting existing state file.
kvm: type=0,vendor=American Megatrends Inc.,version=1903,date=08/30/2023: Could not open 'type=0,vendor=American Megatrends Inc.,version=1903,date=08/30/2023': No such file or directory
stopping swtpm instance (pid 53071) due to QEMU startup error
TASK ERROR: start failed: QEMU exited with code 1
 
Last edited:
OK - I am close to getting things working... I have a Gigabyte RTX 3060 isolated and mapped to a new VM. I have tried the various edits you mentioned to 'mask' the VM but I get BSOD immediately on booting the iso to install. I had to remove these three "args: -cpu host,-hypervisor,kvm=off" to get ti stable - but Task manager does say VM. I will try various combinations to see if I can convince it not to be a VM - but so far no dice. The rest of the notes were great and much appreciated. The case case may not be impacted by anti-cheat so it's not a huge priority for me.
When exactly does it crash? When you boot from the ISO or once windows is installed and you try to boot the windows install? Do you get any other error messages that might help debug the problem?


Following here since I am trying to do the same.

Adding this Line to args: -smbios type=0,vendor="American Megatrends Inc.",version=1903,date="08/30/2023" gives me a QEUMU error on start up. If I delete this with the kvm off etc. It starts up but is still showing a virtual machine. Any ideas?

swtpm_setup: Not overwriting existing state file.
kvm: type=0,vendor=American Megatrends Inc.,version=1903,date=08/30/2023: Could not open 'type=0,vendor=American Megatrends Inc.,version=1903,date=08/30/2023': No such file or directory
stopping swtpm instance (pid 53071) due to QEMU startup error
TASK ERROR: start failed: QEMU exited with code 1
Could you post the full "args" line you used? Or maybe the full config?
 
When exactly does it crash? When you boot from the ISO or once windows is installed and you try to boot the windows install? Do you get any other error messages that might help debug the problem?



Could you post the full "args" line you used? Or maybe the full config?
args: -cpu host,-hypervisor,kvm=off,-smbios type=0,vendor="American Megatrends Inc.",version=1903,date=“08/30/2023”
balloon: 0
bios: ovmf
boot: order=sata0;ide2;net0
cores: 12
cpu: host,hidden=1
efidisk0: local-lvm:vm-106-disk-0,efitype=4m,pre-enrolled-keys=1,size=4M
ide2: local:iso/Windows-11.iso,media=cdrom,size=5705260K
machine: pc-q35-8.1
memory: 16384
meta: creation-qemu=8.1.2,ctime=1702348524
name: Windows
net0: e1000=XX:XX:XX:XX:XX:XX,bridge=vmbr0,firewall=1
numa: 1
ostype: win11
sata0: local-lvm:vm-106-disk-1,discard=on,size=100G
smbios1: uuid=REDACTED for Privacy
sockets: 1
tpmstate0: local-lvm:vm-106-disk-2,size=4M,version=v2.0
vmgenid: REDACTED for Privacy

My motherboard is an Asus 590-E Gaming Wifi.
 
When exactly does it crash? When you boot from the ISO or once windows is installed and you try to boot the windows install? Do you get any other error messages that might help debug the problem?



Could you post the full "args" line you used? Or maybe the full config?
I used your exact args format changing the string, BIOS version and date to match my MB. The crash is instantly as it try’s to boot the .iso image before windows is installed. No windows screens just a Stop Code message with no number or information. I haven’t tried editing it now that things are installed.
 
I used your exact args format changing the string, BIOS version and date to match my MB. The crash is instantly as it try’s to boot the .iso image before windows is installed. No windows screens just a Stop Code message with no number or information. I haven’t tried editing it now that things are installed.
Oh I think I might have a solution! Change the boot order so your hard drive is first and windows iso is second in line. See if that fixes it.
 
Oh I think I might have a solution! Change the boot order so your hard drive is first and windows iso is second in line. See if that fixes it.
During the installation? The hard drive would be empty and it would then boot the .iso. The .iso boot with the the cpu,hypervisor,and kvm flags crashed during the .iso boot to perform the install. I will try it later when I get home just to figure things out.
 
args: -cpu host,-hypervisor,kvm=off,-smbios type=0,vendor="American Megatrends Inc.",version=1903,date=“08/30/2023”
balloon: 0
bios: ovmf
boot: order=sata0;ide2;net0
cores: 12
cpu: host,hidden=1
efidisk0: local-lvm:vm-106-disk-0,efitype=4m,pre-enrolled-keys=1,size=4M
ide2: local:iso/Windows-11.iso,media=cdrom,size=5705260K
machine: pc-q35-8.1
memory: 16384
meta: creation-qemu=8.1.2,ctime=1702348524
name: Windows
net0: e1000=XX:XX:XX:XX:XX:XX,bridge=vmbr0,firewall=1
numa: 1
ostype: win11
sata0: local-lvm:vm-106-disk-1,discard=on,size=100G
smbios1: uuid=REDACTED for Privacy
sockets: 1
tpmstate0: local-lvm:vm-106-disk-2,size=4M,version=v2.0
vmgenid: REDACTED for Privacy

My motherboard is an Asus 590-E Gaming Wifi.
Not sure if that is the issue but aren't you missing a space between kmv=off and -smbios? Can you check if the following works?

args: -cpu host,-hypervisor,kvm=off, -smbios type=0,vendor="American Megatrends Inc.",version=1903,date=“08/30/2023”
 
  • Like
Reactions: spartandrew18
During the installation? The hard drive would be empty and it would then boot the .iso. The .iso boot with the the cpu,hypervisor,and kvm flags crashed during the .iso boot to perform the install. I will try it later when I get home just to figure things out.
All I remember is that when I had Windows ISO image as first and it said press any key to boot, it would load and then just stop before booting the installation sequence. However, when I switched it to second line it seemed to roll through the install. Not sure why but worth a try.
 
  • Like
Reactions: glorwinger
Not sure if that is the issue but aren't you missing a space between kmv=off and -smbios? Can you check if the following works?

args: -cpu host,-hypervisor,kvm=off, -smbios type=0,vendor="American Megatrends Inc.",version=1903,date=“08/30/2023”
Ok that worked! However it still shows virtualization enabled….
 

Attachments

  • IMG_1129.jpeg
    IMG_1129.jpeg
    570.6 KB · Views: 258
Hey all, great guide but after I boot into Windows 11 I do not see my GPU and only see "Microsoft Basic Display Adapter", how should I debug this and properly pass the GPU?

CPU: 7950X
Mobo: X670E Taichi
GPU: AMD 6600
 
Hey all, great guide but after I boot into Windows 11 I do not see my GPU and only see "Microsoft Basic Display Adapter", how should I debug this and properly pass the GPU?

CPU: 7950X
Mobo: X670E Taichi
GPU: AMD 6600
To me this sounds like a driver issue. If you are able to boot the VM and get video output from you gpu, then gpu passthrough is working. Did you install the amd gpu driver in you vm?
 
To me this sounds like a driver issue. If you are able to boot the VM and get video output from you gpu, then gpu passthrough is working. Did you install the amd gpu driver in you vm?
Yes I am able to boot the VM and get the video output from my GPU but it is at 800x600. The GPU does not show up in device manager under the monitor section.

I was not able to install the amd gpu in the vm as it was throwing an error about not detecting hardware, is there a way to force the install?
 
Yes I am able to boot the VM and get the video output from my GPU but it is at 800x600. The GPU does not show up in device manager under the monitor section.

I was not able to install the amd gpu in the vm as it was throwing an error about not detecting hardware, is there a way to force the install?
Just to double check. You are getting video output from your gpu directly to your monitor. You are not using VNC from the proxmox GUI?

Have you tried a bare metal install of windows? If that gives you the same behaviour maybe your gpu is broken.
 
Just to double check. You are getting video output from your gpu directly to your monitor. You are not using VNC from the proxmox GUI?

Have you tried a bare metal install of windows? If that gives you the same behaviour maybe your gpu is broken.
Yes, I am getting video output from the GPU directly using a DisplayPort cable, VNC gives an error and does not connect.

Yes I tried a bare metal install of Windows prior to Proxmox, the drivers installed and I was running games such as Minecraft and Darksiders 2.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!