Complete-Single-GPU-Passthr.../README.md

111 lines
3.3 KiB
Markdown
Raw Normal View History

2020-12-01 18:24:52 +00:00
### **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***
```sh
grub-mkconfig -o /boot/grub/grub.cfg
```
#### Reboot your system for the changes to take effect.
2020-10-27 07:00:38 +00:00
2020-12-01 18:24:52 +00:00
### **Verify IOMMU**
#### ***If you don't see any output when running following command, IOMMU is not functioning.***
```sh
dmesg | grep 'IOMMU enabled'
```
2020-10-27 07:00:38 +00:00
2020-12-01 18:24:52 +00:00
### **Install required tools**
2020-10-27 07:00:38 +00:00
<details>
2020-12-01 18:24:52 +00:00
<summary><b>Gentoo Linux</b></summary>
2020-10-27 07:00:38 +00:00
```sh
2020-12-01 18:24:52 +00:00
emerge -av qemu virt-manager libvirt ebtables dnsmasq
2020-10-27 07:00:38 +00:00
```
</details>
<details>
2020-12-01 18:24:52 +00:00
<summary><b>Arch Linux</b></summary>
2020-10-27 07:00:38 +00:00
```sh
2020-12-01 18:24:52 +00:00
pacman -S qemu libvirt edk2-ovmf virt-manager dnsmasq ebtables
2020-10-27 07:00:38 +00:00
```
</details>
<details>
2020-12-01 18:24:52 +00:00
<summary><b>Fedora</b></summary>
2020-10-27 07:00:38 +00:00
```sh
2020-12-01 18:24:52 +00:00
dnf install @virtualization
2020-10-27 07:00:38 +00:00
```
</details>
2020-12-01 18:24:52 +00:00
### **Enable required services**
2020-10-27 07:00:38 +00:00
<details>
2020-12-01 18:24:52 +00:00
<summary><b>SystemD</b></summary>
2020-10-27 07:00:38 +00:00
```sh
2020-12-01 18:24:52 +00:00
systemctl enable --now libvirtd
2020-10-27 07:00:38 +00:00
```
</details>
<details>
2020-12-01 18:24:52 +00:00
<summary><b>OpenRC</b></summary>
2020-10-27 07:00:38 +00:00
```sh
2020-12-01 18:24:52 +00:00
rc-update add libvirtd default
rc-service libvirtd start
2020-10-27 07:00:38 +00:00
```
</details>
2020-12-01 18:28:37 +00:00
#### Sometimes, you might need to start default network manually.
2020-12-01 18:24:52 +00:00
```sh
virsh net-start default
virsh net-autostart default
2020-10-27 07:00:38 +00:00
```
2020-12-01 18:24:52 +00:00
### **Setup Guest OS**
### ***NOTE: You should replace win10 with your VM's name where applicable***
#### ***Download [virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso) driver.***
2020-12-01 18:28:37 +00:00
#### 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.
2020-12-01 18:24:52 +00:00
### **Attaching PCI devices**
2020-12-01 18:28:37 +00:00
#### 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.
2020-12-01 18:24:52 +00:00
----- TODO: vBIOS patching ------
2020-12-01 18:28:37 +00:00
#### To use patched vBIOS, edit VM's configuration
2020-12-01 18:24:52 +00:00
```sh
virsh edit win10
```
```xml
...
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
...
</source>
<rom file='/home/me/patched.rom'/>
...
</hostdev>
...
```
2020-10-27 07:00:38 +00:00
2020-12-01 18:31:47 +00:00
### Libvirt Hooks
#### TODO
2020-10-27 07:00:38 +00:00
<b>See Also</b>
2020-10-27 07:06:44 +00:00
> [Single GPU Passthrough by joeknock90](https://github.com/joeknock90/Single-GPU-Passthrough)<br/>
> [Single GPU Passthrough by YuriAlek](https://gitlab.com/YuriAlek/vfio)<br/>
> [ArchLinux PCI Passthrough](https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF)<br/>
> [Gentoo GPU Passthrough](https://wiki.gentoo.org/wiki/GPU_passthrough_with_libvirt_qemu_kvm)<br/>