Linux Virtual Gaming Machine

You may wonder what’s wrong with this fellow (meaning me, the author). Has he completely lost his mind when he proposes a Linux virtual gaming machine? Before you discredit the idea, let me explain.

Windows virtual gaming machine

Here and elsewhere Linux users run their Microsoft Windows OS as a virtual machine on Linux and pass through a dedicated GPU. Given the right configuration, this “Windows virtual gaming machine” will have little to no performance penalty compared to a native (bare metal) Windows installation.

UsingĀ  KVM and GPU passthrough allows users to play graphic intensive games inside a virtual machine (VM) by using a dedicated GPU for the Windows VM. Typically you assign the IGD or internal graphics device (inside the CPU) to the host and the (powerful) discrete graphics card to the Windows VM.

The IGD or a low-power GPU will handle the less demanding jobs of web surfing, video/movie display and a whole bunch of productivity tasks just fine.

But what if you wish to play a game under Linux? Numerous Linux-based games available today already have higher demands on the graphics device.

Single GPU passthrough

One approach is to make the (powerful) discrete GPU available to Linux/Xorg. The most common approach is “single GPU passthrough”, and several tutorials have focused on that subject. Single GPU passthrough uses one graphics card for the Linux host, which is passed through to the Windows VM when needed. When the Windows VM is shutdown, a program or script resets the graphics card and re-attaches it to the Linux host. As simple as it sounds, this approach has it’s downsides:

  • The graphics card must be reset before it can be used by another windows manager/OS – some cards behave better than others;
  • After booting the VM, the Linux host will no longer have a graphics device, so one cannot switch back and forth between the two;
  • Single GPU passthrough and the way a graphics card is attached to Xorg is still a little experimental.

Yuri, who has written a script and tutorial for single GPU passthrough, writes:

In one command it kills X, frees the GPU from drivers and console, detaches the GPU from the host, starts the VM with the GPU, waits until the VM is off, reattaches the GPU to the host and starts lightdm.

As you can see, there are a lot of things to consider. Also consider what might happen when a Windows VM crashes? Will the graphics card reattach itself to the host? Chances are it won’t.

Linux gaming VM

Assume you already have a Windows VM with VGA passthrough (i.e. a Windows gaming VM). The steps to create a Linux gaming VM are simple. You can literally use your existing Windows VM configuration, make some slight alterations, create a virtual image, and in no time you have a Linux gaming VM using your powerful discrete graphics card.

The process for creating a Linux gaming VM is described in Installing a Linux Mint 19 (Ubuntu 18.04) VM with VGA Passthrough.

Here the benefits of this approach:

  • Your host system and Windows VM remain untouched – no downtime of host system nor availability of Windows VM!
  • Conserve energy – use the low-power IGD while performing normal tasks;
  • Easy to backup/restore linux.img file that holds the entire Linux VM;
  • Create a slim gaming VM with all your games installed.

As disk space is cheap – even for SSD – I can’t see a reason not to run a 30GB-50GB Linux virtual gaming machine.

I look forward to read your comments.

Conclusion

16 months have gone since I wrote the above. In the meantime I created several passthrough VMs running different distros. Sharing files between VMs or host and VM is simple – just create a Samba share on the host. Performance is lightning fast and only limited by the SSD.

In fact, sharing host resources such as a printer has not been an issue at all. Right now I’m running a Manjaro Linux VM for a long term test to see if it fits my needs as the future host OS on a new PC.

I remote mounted my host-side music library folder on my Linux VM using an fstab entry like this:

//myhostname.local/music/flac /home/myuser/Music/ cifs user=myuser,password=xxxxxx,iocharset=utf8,noperm,noauto,x-systemd.automount,nofail 0 0

Above is a quick and dirty way to make host folders available to a VM. A better way is described in How To Use SSHFS to Mount Remote File Systems Over SSH.

I use the ALSA sound system to channel the sound through the host to an Asus Xonar Essence PCI sound card. The Xonar sound card feeds a really enjoyable audiophile system (amp and speakers). What can I say – the music is crystal clear with excellent definition of musical instruments and singers. After several hours of critical listening I cannot hear a difference between playing the music on the host or in the VM. I will do some more listening since this is of critical importance to me.

I still have to run some graphics tests and will update here.

So far I’m happy with this solution – the Linux VMs I’ve run so far perform remarkably good. In fact, the out-of-the-box experience with Linux is better than with Windows. Even multiple updates don’t mess up the system nor the performance.

This site uses Akismet to reduce spam. Learn how your comment data is processed.