Skip to main content

GPU Passtrough on Linuxmint 21

Install virt-manager

sudo apt-get install virt-manager bridge-utils

Create a Linux Bridge

add the following to /etc/network/interfaces

auto enp4s0

iface enp4s0 inet dhcp

add the following to /etc/network/interfaces.d/br0

# static ip config file for br0 ##
auto br0
iface br0 inet static
        address 192.168.178.10
        broadcast 192.168.178.255
        netmask 255.255.255.0
        gateway 192.168.178.1
        # If the resolvconf package is installed, you should not edit 
        # the resolv.conf configuration file manually. Set name server here
        dns-nameservers 192.168.178.1
        # If you have muliple interfaces such as eth0 and eth1
        # bridge_ports eth0 eth1  
        bridge_ports enp4s0
        bridge_stp off       # disable Spanning Tree Protocol
        bridge_waitport 0    # no delay before a port becomes available
        bridge_fd 0          # no forwarding delay

Step 1: Enable IOMMU

edit /etc/default/grub at the line GRUB_CMDLINE_LINUX_DEFAULT so that it reads like

GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt"

Then reconfigure Grub

sudo grub-mkconfig -o /boot/grub/grub.cfg

Step 2: Tell VFIO we want to pass through the NVIDIA card

lspci -nnk

In my case the id of the GPU is 10de:17c8 and the HDMI sound output is 10de:0fb0. Note the part beneath the GPU where it says Kernel driver in use: nouveau.. If everything works correctly that should change by the time we're done. To flag the card for use by VFIO, create the file /etc/modprobe.d/vfio.conf with the contents:

softdep nouveau pre: vfio-pci
softdep snd_hda_intel pre: vfio-pci
options vfio-pci ids=10de:17c8,10de:0fb0

Then run

sudo update-initramfs -u

to update the boot filesystem image with that config. You'll need to reboot at this point. To check if everything worked correctly, run lspci -nnk again and find the GPU. Beneath both of the NVIDIA devices we passed through you should see Kernel driver in use: vfio-pci.