1、 Confirm whether your motherboard CPU supports the Vt-d function

Without support, there is no direct connection. Intel only supports chipsets above b75. That is to say, Intel 4 generation Core processors and above support it. Amd unknown. If it is supported, you need to go to the motherboard to start vt-d.

2、 Open iommu

 vi /etc/default/grub

Found in: GRUB_CMDLINE_LINUX_DEFAULT="quiet"

Then change it to: GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"

If it is an amd cpu, please change it to: GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iomu=on"

After modification, directly update grub

 update-grub

*#AMD CPU can also execute

 pve-efiboot-tool refresh

3、 Load the corresponding kernel module

 echo vfio >> /etc/modules echo vfio_iommu_type1 >> /etc/modules echo vfio_pci >> /etc/modules echo vfio_virqfd >> /etc/modules

Or use vi /etc/modules Add at the end

 vfio vfio_iommu_type1 vfio_pci vfio_virqfd

Then restart PVE

4、 Verify whether iommu is enabled

After restart, input at the terminal

 dmesg | grep 'remapping'

The following example appears. Means success

AMD-Vi: Interrupt remapping enabled
perhaps
DMAR-IR: Enabled IRQ remapping in x2apic mode

Enter the command at this time

find /sys/kernel/iommu_groups/ -type l
*#If there are many direct groups, it means success. If there is nothing, it is not opened

Start PCI-E pass through

1. Shielded graphics card

Check the video card, many devices, and see which one is

 lspci

83:00.0 3D controller: NVIDIA Corporation GP106 [P106-090] (rev a1)


83:00 is the representative group name. 83:00.0 is the first device representing the 83:00 group

 Lspci - n - s 83:00 # View all pci devices in the 83:00 group

83:00.0 0302: 10de:1c09 (rev a1)


It is directly masked, so that the system does not enable it.

 echo "blacklist radeon" >> /etc/modprobe.d/blacklist.conf  echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf  echo "blacklist nvidia" >> /etc/modprobe.d/blacklist.conf  echo "blacklist nvidiafb" >> /etc/modprobe.d/blacklist.conf  echo "blacklist amdgpu" >> /etc/modprobe.d/blacklist.conf  echo "blacklist snd_hda_intel" >> /etc/modprobe.d/blacklist.conf  echo "blacklist snd_hda_codec_hdmi" >> /etc/modprobe.d/blacklist.conf  echo "blacklist i915" >> /etc/modprobe.d/blacklist.conf

Add graphics card to pass through group

 echo "options vfio-pci ids=10de:1381,10de:0fbc" > /etc/modprobe.d/vfio.conf

*#Note that the above command, ids=, is followed by all devices in the passthrough group. The middle is separated by English commas. Replace your own equipment.


After the above operations are completed, check whether to replace the sample content with your own. Use the following command to view.

 cat /etc/modprobe.d/blacklist.conf cat /etc/modprobe.d/vfio.conf

Restart after check

2. Start straight through

First, determine whether your graphics card supports UEFI.
Generally, graphics cards after amd r9 support uefi. Nvidia. All graphics cards above Generation 9 support UEFI.

The video card of uefi needs to use ovmf bios. You cannot use win7.

 Create a new virtual machine. The bios type, according to the graphics card support, does not support uefi selection. The CPU type is set to host, and the muma is enabled. The memory must be static, that is, the maximum and minimum are the same.

After the system is installed. Start configuring pass through

 Vi/etc/pve/qemu server/100. conf # Please replace the 100 here with your own vmid

add to

 hostpci0: 83:00,pcie=1,x-vga=on

The above is the pass through setting.