You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
QaidVoid 6d3668e3a2 More cleanup... 4 years ago
scripts Shell script for automation, working on it 4 years ago
README.md More cleanup... 4 years ago
setup.sh Shell script for automation, working on it 4 years ago

README.md

Enable IOMMU

Set the kernel paramater depending on your CPU.

For GRUB user, edit grub configuration.

/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="intel_iommu=on iommu=pt ..."
OR
GRUB_CMDLINE_LINUX_DEFAULT="amd_iommu=on iommu=pt ..."

Generate grub.cfg

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

Reboot your system for the changes to take effect.

Verify IOMMU

If you don't see any output when running following command, IOMMU is not functioning.

dmesg | grep 'IOMMU enabled'

Install required tools

Gentoo Linux
emerge -av qemu virt-manager libvirt ebtables dnsmasq
Arch Linux
pacman -S qemu libvirt edk2-ovmf virt-manager dnsmasq ebtables
Fedora
dnf install @virtualization

Enable required services

SystemD
systemctl enable --now libvirtd
OpenRC
rc-update add libvirtd default
rc-service libvirtd start

Sometimes, you might need to start default network manually.

virsh net-start default
virsh net-autostart default

Setup Guest OS

NOTE: You should replace win10 with your VM's name where applicable

Download virtio driver.

Launch virt-manager and create a new virtual machine. Select Customize before install on Final Step.

In Overview section, set Chipset to Q35, and Firmware to UEFI

In CPUs section, set CPU model to host-passthrough, and CPU Topology to whatever fits your system.

For SATA disk of VM, set Disk Bus to virtio.

In NIC section, set Device Model to virtio

Add Hardware > CDROM: virtio-win.iso

Now, Begin Installation. Windows can't detect the virtio disk, so you need to Load Driver and select virtio-iso/amd64/win10 when prompted.

After successful installation of Windows, install virtio drivers from virtio CDROM.

Attaching PCI devices

Remove Channel Spice, Display Spice, Video XQL, Sound ich* and other unnecessary devices.

Now, click on Add Hardware, select PCI Devices and add the PCI Host devices for your GPU's VGA and HDMI Audio

Some GPU vBIOS needs to be patched for UEFI Support.

----- TODO: vBIOS patching ------

To use patched vBIOS, edit VM's configuration

virsh edit win10
  ...
  <hostdev mode='subsystem' type='pci' managed='yes'>
    <source>
      ...
    </source>
    <rom file='/home/me/patched.rom'/>
    ...
  </hostdev>
  ...

See Also

Single GPU Passthrough by joeknock90
Single GPU Passthrough by YuriAlek
ArchLinux PCI Passthrough
Gentoo GPU Passthrough