Elementary OS 5.0 / Ubuntu 18.XX - VFIO PCIe passthrough guide / tutorial

added link to original tutorial to make it easier for people to navigate through, awesome work

1 Like

Thank you so much for this tutorial. I’ve got Windows installed and running, the Nvidia drivers are working, etc.

I’m wondering what your keyboard and mouse setup is, though. In order to setup Windows, I had to PCI passthrough my mouse and keyboard.

Of course, this doesn’t allow me to easily disconnect the two. There must be a better way, right? Are the normal mouse and keyboard in the devices panel supposed to work after Windows is installed?

You could get a kvm switch that allows you to use the same devices on both Linux and Windows at the flick of a switch.

https://www.amazon.ca/TESmart-HDMI-Ultra-Switch-3840x2160/dp/B07G883R35/ref=sr_1_5?ie=UTF8&qid=1547142226&sr=8-5&keywords=kvm+switch

There are probably good cheaper ones too that may better suite your setup.

In my case, where the VM is just for gaming and monitors have multiple video inputs with a relatively easy way to switch between input sources, it is just easier to have 2 cordless keyboards and mice (one for main use and one really cheap). So the switch seems like overkill.

Isn’t ElementaryOS 5 amazing? I am really in love with this OS. Great guide!

2 Likes

to be honest, i had to tweak it a lot. Single click to open folders/files just sucks, changed to typical double-click, then switched to dark theme, added minimize button back into UI and moved all header buttons to the right, but overlay im happy with it :smiley:

Used my own tutorial at work while moving to linux, since i need Windows VM to run Photoshop + for testing as well i guess (web dev)

Runs fine, Windows VM has few BSODs, but whats weird that photoshop keeps freezing up from time to time, but that could be related to something else, cuz im loading files from SMB share from my linux host, so windows may be just derping connecting to that

i was thinking about this a lot, first tried just RDP into Windows VM, but quality+performance was poor even connecting to local VM, then had KVM in mind, but that would be too much work to keep switching between host/client all the time. Decided to just buy synergy instead, works fine :smiley:

but it really depends, if your VM has dedicated monitor, kvm switch/synergy would be fine, if you have fake monitor plug, guess you could try setting up looking glass.

I decided to just dedicate one monitor, since i had one monitor just for photoshop when i was full Windows anyway

@elixir77 I thought about getting a KVM switch but instead I’m using a “soft switch”, essentially just run a script to disconnect / connect the moose and keyboard from the VM. There’s a little bit of delay but at the moment I have to physically swap the monitor connection (another cable is coming soon) between Mobo and GPU so it’s fine.

I can write up a little guide for that if anyone’s interested.


@wUFr yeah I’ve been planning on trying out synergy but it doesn’t support Wayland yet which is unfortunate. Luckily it’s not too difficult to switch back to X for the time being. I’ll probably use synergy when I get my new monitor.


One more thing, wanted to share these guides. Have some useful information for optimization.

3 Likes

also, decided to change title of this thread a bit, since all this should work on Ubuntu 18+ as well and removed “beta” since i managed to set this all up in fully released EOS 5

1 Like

update on my setup

everything works fine, except storage, which i assume is VIRTIO driver issue in Windows 10 VM, sometimes it gets terrible read speeds or even BSODs… to be fair i may f-cked it myself, when i was trying to use memory balooning feature, which seemed broken. It would still use all the ram in host OS and Windows VM ram would still show 16GB with only difference it being almost always full - which i assume was some driver issue… idk :smiley:

kinda sad, considering hyper-V can do dynamic memory with Windows VM, so im gonna blame VIRTIO drivers :stuck_out_tongue:

PS: Windows VM drive is dedicated sata SSD

wasnt it because of gpu passthrough you cannot use dynamic memory at the same time? i think it was the same on hyper-v but not sure, cant remember…
virtio drivers are latest?

idk. Drivers should be latest, but i dont even remember, where i pulled them from by now. I think i had to dig them from some redhat site :smiley:

ok, tried these settings and it seems to work way better now

image

before:

image

after:

image

I followed this guide but only the audio device seems to have the correct kernel driver identified.

06:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP104 [GeForce GTX 1080] [10de:1b80] (rev a1)
(prog-if 00 [VGA controller])
Subsystem: eVga.com. Corp. GP104 [GeForce GTX 1080] [3842:6288]
Flags: bus master, fast devsel, latency 0, IRQ 97, NUMA node 0
Memory at de000000 (32-bit, non-prefetchable) [size=16M]
Memory at c0000000 (64-bit, prefetchable) [size=256M]
Memory at d0000000 (64-bit, prefetchable) [size=32M]
I/O ports at 6000 [size=128]
[virtual] Expansion ROM at 000c0000 [disabled] [size=128K]
Capabilities: [60] Power Management version 3
Capabilities: [68] MSI: Enable+ Count=1/1 Maskable- 64bit+
Capabilities: [78] Express Legacy Endpoint, MSI 00
Capabilities: [100] Virtual Channel
Capabilities: [250] Latency Tolerance Reporting
Capabilities: [128] Power Budgeting <?>
Capabilities: [420] Advanced Error Reporting
Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
Capabilities: [900] #19
Kernel driver in use: nvidia
Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia

06:00.1 Audio device [0403]: NVIDIA Corporation GP104 High Definition Audio Controller [10de:10f0] (rev a1)
Subsystem: eVga.com. Corp. GP104 High Definition Audio Controller [3842:6288]
Flags: bus master, fast devsel, latency 0, IRQ 5, NUMA node 0
Memory at df080000 (32-bit, non-prefetchable) [size=16K]
Capabilities: [60] Power Management version 3
Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [78] Express Endpoint, MSI 00
Capabilities: [100] Advanced Error Reporting
Kernel driver in use: vfio-pci
Kernel modules: snd_hda_intel

weird, id say check all configs again, if you put in both PCI-E IDs and without typos then see :slight_smile:

note, if you’re trying to passthrough USB controller (PCI-E card in my case), check if its not in same group as other stuff.

i had to move my card from 1x slot to 16x slot, then it is just “click 2 add” in QEMU/KVM gui :slight_smile:

… so many hours raging why it does not work, lol. Turned out 1x slot is in same IOMMU group as my network cards on board itself…

Guide updated with link to “GPUs with identical ID” how-to

https://forum.level1techs.com/t/vfio-in-2019-pop-os-how-to-general-guide-though-draft/142287

I’m on a i7 9700k + rtx 2070, I got to the “reboot and pray” but I don’t think I prayed enough because I’m getting a black screen, Intel integrated graphics are enabled in the bios but I don’t thing Linux picks up on it, I’m just getting a black screen after the reboot. Help what do I do :joy:

hmm, id start by checking GPU priority in bios - make sure it uses iGPU first. Then maybe boot live “CD” and double check your configs

also one non-related “isssue” (may help someone).

If you have GPUs with same IDs and connect new monitor to the VM passed GPU, you may need to reboot WHOLE pc for it to detect correctly.

got new 4K monitor at work for my windows VM and was pretty scared its not working properly or cable is bad, but it simply needed rig reboot to get detected properly. My guess is, its due the way GPU is passed when having same ID as host GPU

Wow. Old thread. I dusted off my PCI passthrough endeavours. I am happy to report that I got it “working” with an old secondary AMD card.

1 Like