Tested using Fedora (tips (red)hat)
Here’s what I do, starting with a fresh install with compatible hardware and bios settings.
I’m laying out this document as I have personally prepared it for my own personal use if I ever needed to quickly reset the PC to a fully functional PCI-passthrough machine with a very functional Linux host that I use for daily computing + office work. I took pieces here and there (from the interwebs, this forum, etc). For me, it works, 100% of the time. Thanks for all of those involved in making this possible!
Set Repositories/Install RPM Fusion + Installing Software + Installing Sound/Video
su -c 'dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm'
sudo dnf install vlc audacity pdfshuffler evince firefox gimp libreoffice openshot obs-studio filezilla p7zip-gui.x86_64 mediawriter.x86_64 simple-scan unrar vim htop nethogs screenfetch lm_sensors.x86_64 hddtemp gnome-terminal-nautilus wine @virtualization
*also check for visual studio code online
sudo dnf install gstreamer1-libav gstreamer1-plugins-good gstreamer1-plugins-ugly gstreamer1-plugins-bad-free gstreamer-ffmpeg gstreamer-plugins-good gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-plugins-bad-free gstreamer-plugins-bad-nonfree
sudo dnf install clalsadrv.x86_64 alsa-firmware.noarch alsa-lib.x86_64 alsa-utils.x86_64 alsamixergui.x86_64
sudo modprobe snd-oxygen
sudo modprobe snd-pcm-oss
sudo modprobe snd-mixer-oss
sudo modprobe snd-seq-oss
alsamixer
For DGX Sound Card
***Set multichannel
***Analog Surround 4.0
For Thinkpad Laptops
sudo dnf install tlp
systemctl enable tlp.service
systemctl enable tlp-sleep.service
sudo tlp start
*** Verification of IOMMU groupings if needed
-
gedit ls-iommu.sh
#!/bin/bash
for d in /sys/kernel/iommu_groups//devices/; do
n=${d#/iommu_groups/}; n=${n%%/}
printf 'IOMMU Group %s ’ "$n"
lspci -nns "${d##/}"
done -
chmod +x ./ls-iommu.sh
./ls-iommu.sh
Choose your method for passthrough: pci-stub or vfio
- Passthrough with pci-stub
- Check Hardware IDs
lspci -nn | grep AMD
- Add the following to Kernel Line in /etc/grub2-efi.cfg or /etc/default/grub - This Gives the VM (in my case) Graphics Card Video/Audio, Disables HDMI audio of Main Card and Passthrough Motherboard Audio. You passthrough whatever hardware you desire, just make sure to match your hardware IDs.
amd_iommu=on pci-stub.ids=1002:6899,1002:aa50,1002:4383
3.sudo grub2-mkconfig -o /boot/grub2/grub.cfg
-
Reboot
-
To Check if pci-stub Worked
dmesg | grep pci-stub
- Passthrough with VFIO
- Add to Kernel Line in /etc/default/grub
iommu=1 amd_iommu=on rd.driver.pre=vfio-pci
- To Get IDs
lspci -nn
- Add in /etc/modprobe.d/kvm.conf and comment out kvm stuff
options vfio-pci ids=1002:6899,1002:aa50,1002:4383
- Create a vfio.conf in /etc/dracut.conf.d with
add_drivers+=“vfio vfio_iommu_type1 vfio_pci vfio_virqfd”
-
dracut -f --kver `uname -r`
-
grub2-mkconfig > /etc/grub2-efi.cfg
-
Reboot
Setup for Virtmanager
CPU allocation: 8 out of 8
CPU model: Hypervisor Default
Don’t copy host configuration
Manually set CPU topology : 1/8/1
RAM: 16000 MB
LAN: macvtap enp7s0 VEPA rtl8139
Disks: /dev/sdd and /dev/sde
UEFI
- I’m using an AMD 8320 and 2 dedicated disks for the Windows VM. You’ll have to play around with this as you see fit with your own hardware. At least it’s a GUI, amirite. Here, you tell the software which devices you want to assign to it. If you’re curious, the GPUs I have tested this with are R9 280 and an old HD 5850.
Setup for LookingGlass
-
sudo dnf install git SDL2-devel SDL2_ttf-devel openssl-devel spice-protocol fontconfig-devel libX11-devel gnu-free-mono-fonts ivshmem-tools libgle-devel.x86_64
-
sudo dnf groupinstall "Development Tools" "Development Libraries"
-
git clone https://github.com/gnif/LookingGlass.git
-
cd LookingGlass/client
make
-
sudo usermod -aG qemu yourusername
-
Edit /etc/libvirt/qemu.conf and set
user = "qemu"
group = "qemu"
dynamic_ownership = 1
-
Edit /etc/selinux/config and set to permissive
-
virsh edit WindowsVMname
add the following under kvm (next to it add xmlns:qemu=‘http://libvirt.org/schemas/domain/qemu/1.0’)
qemu:commandline
<qemu:arg value=’-device’/>
<qemu:arg value=‘ivshmem-doorbell,chardev=ivshmem,vectors=1’/>
<qemu:arg value=’-chardev’/>
<qemu:arg value=‘socket,path=/home/yourusername/ivshmem_socket,id=ivshmem’/>
</qemu:commandline>
sudo -u qemu ivshmem-server -p /tmp/ivshmem.pid -S /tmp/ivshmem_socket -l 16M -n 8
If you need to reset server at some point
sudo rm /tmp/ivshmem_socket
- Give read/write access to /tmp/ivshmem_socket
sudo chmod 600 /tmp/ivshmem_socket
-
Run VM on Linux
-
Install drivers and exe on Windows
-
Run exe on Windows
-
Run
./client/bin/looking-glass-client
Have fun!
I’ll update as recommendations come in.