Howto gpu passthrough: Difference between revisions
Line 79: | Line 79: | ||
<size unit='M'>32</size> | <size unit='M'>32</size> | ||
</shmem> | </shmem> | ||
install looking glass client: | |||
yay -S looking-glass | |||
= references = | = references = | ||
* https://github.com/vanities/GPU-Passthrough-Arch-Linux-to-Windows10 | * https://github.com/vanities/GPU-Passthrough-Arch-Linux-to-Windows10 |
Revision as of 11:20, 4 March 2023
configure grub
add the following to /etc/default/grub:
for intel:
GRUB_CMDLINE_LINUX_DEFAULT="quiet ... intel_iommu=on"
for amd:
GRUB_CMDLINE_LINUX_DEFAULT="quiet ... amd_iommu=on"
re-configure your grub:
grub-mkconfig -o /boot/grub/grub.cfg
isolating gpu
find the device id of the gpu:
lspci -nn |grep -E NVIDIA
command output:
1:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA104 [GeForce RTX 3070] [10de:2484] (rev a1) 01:00.1 Audio device [0403]: NVIDIA Corporation GA104 High Definition Audio Controller [10de:228b] (rev a1)
edit /etc/modprobe.d/vfio.conf file and adding the following line with your ids:
options vfio-pci ids=10de:2484,10de:228b
if using the nvidia drivers add the following to /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="vfio-pci.ids=10de:2484,10de:228b"
re-configure your grub:
grub-mkconfig -o /boot/grub/grub.cfg
edit /etc/mkinitcpio.conf and add the following:
MODULES="vfio vfio_iommu_type1 vfio_pci"
In the same file, also add modconf to the HOOKS line:
HOOKS="modconf"
backup your existing initramsfs image:
cp /boot/initramfs-linux.img /boot/default-initramfs-linux.img
rebuild initramfs:
mkinitcpio -g /boot/initramfs-linux.img -c /etc/mkinitcpio.conf
reboot your system:
reboot now
find your gpu and ensure that under “Kernel driver in use:” vfio-pci is displayed:
lspci -nnk
create bridge interface
create the bridge interface:
nmcli connection add type bridge autoconnect yes con-name br0 ifname br0
add device to bridge:
nmcli connection add type bridge-slave autoconnect yes con-name br0-eth0 ifname eth0 master br0
add ip address to bridge interface:
nmcli connection modify br0 ipv4.address 10.44.1.1 ipv4.method manual
active bridge interface:
nmcli connection up br0
create script with iptables rules:
cat > /usr/local/bin/sharenet-wlan0 << EOF #!/bin/bash echo "1" > /proc/sys/net/ipv4/ip_forward iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -t nat -I POSTROUTING -o wlan0 -j MASQUERADE EOF
fix permissions:
chmod +x /usr/local/bin/sharenet-wlan0
run the script:
/usr/local/bin/sharenet-wlan0
configure libvirtd
install virt-manager and ovmf:
pacman -S libvirt virt-manager ovmf qemu
edit /etc/libvirt/qemu.conf and add the following:
nvram = [ "/usr/share/ovmf/x64/OVMF_CODE.fd:/usr/share/ovmf/x64/OVMF_VARS.fd" ]
start and enable the following services:
systemctl start libvirtd.service systemctl start virtlogd.socket systemctl enable libvirtd.service systemctl enable virtlogd.socket
add yourself to the libvirt group:
gpasswd -a username libvirt
install windows
install virtio windows drivers:
yay -S virtio-win
looking glass
add the following to your libvirt machine configuration inside the ‘devices’ section by running:
<shmem name='looking-glass'> <model type='ivshmem-plain'/> <size unit='M'>32</size> </shmem>
install looking glass client:
yay -S looking-glass