Linux host as as Windows gaming machine?

Hello,

I have Ryzen 9 7950 X (with mini GPU inside), and Radeon 7900 XT. (and problematic Windows :nauseated_face: but I need it)

Simple version of my question would be how hard it is to set this up as gaming machine, with windows running as an VM?

My additional requirements, that do not make it so simple:

  • Windows needs to see the GPU! (otherwise games will not work well or at all)
  • Windows needs pretty fast access to the disk (if it would be easier, it can be exclusive, I have enough NVMe drives to make one exclusive, no clue how far is virtualization since I last checked, maybe it is unnecessary, because there is near 0 overhead)
  • I would like to have one “VM” (or whatever) per group of applications, so they do not affect each other
  • I would like "VM"s to share as much as possible, to save disk space, but not at cots of one application polluting the drive for others
  • Would be nice if I could use the GPU directly too, so I do not need to run Windows for every game
  • I know some basic linux commands, but I am no expert, so the setup should be easy enough (I have RPi as my home server)
  • I have 4k monitor, and use desktop resolution scaling 150% (long time ago this wasn’t working well on Linux)

I know there is an Looking glass, but last time I used it (many many years ago), it was not working too well.

Because I have “technically” 2 GPUs it should be possible to use the integrated one as default one, and give the big one to the currently running VM, right?

How realistic do you think such setup would be?

What distro would you recommend for this?

Anything else I did not think about?

I’m not sure what do you mean with VM’s for group of applications but rest seems possible. How hard it will be depends how good you are at googling or asking questions :stuck_out_tongue:

About gaming be aware some anticheats detect VMs and will not work (like valorant). And most of games works on Linux, windows is needed only for few.

Since you’ll be using iGPU as host gpu I’d advise against looking glass. But without it you either need second monitor or connect 2 cables (one to iGPU one to 7900 XT) to one monitor and switch inputs.

About speed, virtual disks are usually fast enough but you can pass entire disk if you want. Virtual disks also can be used to “share” between VMs or even host (but can only be mounted to one running VM at time).

If you want to use GPU on host too you should make sure only apps you want will use gpu and those apps will get killed before starting vm.
So make UDEV rule to make GPU be owned by some custom group and start apps with this group permissions for example with sudo -g <groupname>.
AMD gpu seems to unbind from host while some apps are using it (and kill those apps) but done that way reattaching not always works.

Also if you have Resizable bar enabled in bios you’d either have to disable it or change bar sizes before starting VM.

Any distro will do. But most “direct” informations that are easy to find are probably for Arch based distros (other distros might have different location of files etc.).

1 Like

Any Distro will work for this. If you are new to this, I would recommand to stick to a mainline distro. I have setup a couple VMs this year (in Debian, Fedora, Redhat, Centos, Opensuse) with gpupassthrough for testing. Usually I’m in a working windows desktop within an hour (including Downloads), but the process is pretty involved. It’s not like you have to push a button and it works.

Since you want fast harddrive speeds I would recommand a dedicated SSD per VM.

I figured one would have 3 basic options when setting up a gaming vm.
Use two gpus, passthrough your input devices and output to a different monitor(-input).
Use Looking Glass (but the fact, that audio comes from a different spice-device freaks me out)
Use one gpu, passhtrough your input devices (my favorit option)

By that I mean, that I would prefer something more lightweight than VM, because Windows is big, but if full VM is best option, then having multiple applications in VM is easy. And I remeber seeing some magic with VMs, that allow them run apps directly as single window, but at the time, it was limited to single application from a VM. I really wanted to get an sanity check before trying to implement it.

I do not play Valorant so not a problem for me. And last time I checked (before now) like 95% of games I played did not work with wine :cry: . This time I checked also ProtonDB and quite surprised to see games being “garbage” on wine, but “platinum” on proton, so list is much shorter (thanks to proton), but still there.

2 Cables to an monitor should not be an problem.

IGpu should be enough for video, IDEs, text editor, and internet browser (I hope) so it can be default. I think I need real GPU only for games, and one other application, that needs windows anyway.
I did not know anything about UDEV, but by quickly looking I think I should be able to figure that out.
Because I think I will use it only for games, I do not think unbind while application is running should be an problem.

Resizable bar is needed for more and more games, and is enabled by default now.
Why would I need to change the bar size before starting VM? My understanding is that with passtrough Windows will get full view of the GPU.

Arch? :open_mouth: last time I was trying to use linux most people was saying that Arch is only for masochist and not recommended for most people, did that change?

Interesting that you advice “against” Arch, while materus suggested it.

VMs will never run at same time, so do not see an issue with them all having same SSD attached.

Connection both GPUs to the monitor seems fine, and audio also passes trough GPU to the monitor. Can you please elaborate on those 3 options? Why is 3 your favorite? Do I understand it correctly that in case 3 you are not able to access any application on the host, while the VM is running? (because the GPU is exclusively given to the VM)

I dont like the “archway” of doing things. Just my preference.

Windows can be a bit iffy at times. It could lead to troubles where there should be none, if you run different vms from the same windows install. Why even bother with setting up multiple vms, if you boot off the same storage device? I cant see any benefit to such setup.

Running option 3 is less involved. I dont have to switch input devices or output devices. I dont have to deal with audio latency. Usually i run the vm when i want to game. I dont need access to the host while gaming. Also my main GPU is available while in Linux. Usually in a dual gpu setup the gpu for the vm cannot be used under Linux.

Oh my mistake did not state it clearly, I did not mean it as an install drive, but games and data drive, they would have separate "C:" (windows) drive, but the game storage would be the fast NVMe attached directly to VM.

My current understanding is quite the opposite, that with single GPU you need to run VM, install things like browser to a VM, because there is no way to get back to host to check something on the internet, and after closing the VM do some semi automatable magic to attach th GPU back to the host, without seeing anything on the screen. While dual GPU setup allows to (de)atttach the main GPU freely while seeing what you do all the time. Can you please explain why this is not the case?

I do have scripts which kill all graphical applications, unload the drivers when starting the vm and do the reverse when shutting down the vm. So yes, there happens some automation magic in the background and you dont have access to the host while running the vm. If you wanted to use the gpu on the host and on the guest in a dual gpu setup you would have to do kind of the same thing anyway. I dont feel there is a benefit in “seeing” an output on another gpu.

If you want access to the host while running a dualgpu setup you would have to have additional input/output devices which you dont passthrough to the vm, a kvm-switch, use looking glass or come up with a more involved setup.

:thinking: actually good point about the inputs, I was still thinking about it as “normal VM”, where you get back to host by pressing of an button (so the inputs are shared).

Having one more USB and one more DP cable does not seem like a problem, switching monitor to another input is 2 presses of a button, and USB just one (already have that set up because of work PC).
That brings me to really nice idea, I have 4 USB 3.* host controllers, so I can easily connect two to the switch and pass one to the VMs.
To me that sounds like the simplest solution, with least “complex” setup required, and no risk to screw up “magic” scripts, that would force me to reboot PC if anything goes wrong with VM.
I should also be able to give VM half of the CPU, which might also slightly improve performance in some games, because they will see more unified 8/16 core/threads CPU. And while running something without VM it will have access to everything.

Am I oversimplifying it? Am I forgetting something?

Well, I said Arch based, not clean arch. Clean Arch is a lot to configure by yourself. Also, any distro will work, just said most easy to find informations are for arch so for other distro’s you might need to “translate” those informations. I personally use NixOS but that’s definitely not something I would recommend for most people

Enabling ReBar in BIOS makes bar sizes to maximum in linux from what I’ve seen. And if you pass gpu with this you’ll just get black screen (Code 43).
You don’t need to disable it in bios but if you won’t you’ll have to resize them in vm starting script (or using udev rules but in that case might as well disable in bios).

I remember seeing something about running apps from vm as window on host if thats what you talking about but it still required full windows in vm and I don’t think it would work with accelerated graphic from GPU Passthrough, it was using some RDP trickery from what I remember.

About UDEV rules, I was talking about this since you wanted to use gpu also on host if I understood your first post.

My idea was that some games work trough proton, so would not require VM to run, and for that the GPU would need to be used in the host OS, or do you think it would be better to run all windows applications in windows natively?

I use linux for as many things I can, so idea to run via proton sounds better in my opinion. But that needs those udev rules for passthrough.

I stand corrected. Looking-Glass does audio since the latest (?) Version and the latency issue is pretty much gone.