Proxmox VE PCIe 直通 intel 核显开启 SRIOV
cokebar 2024-04-04 17:35 2024-04-04 17:40 PVE 没有评论
主要参照:
https://pve.proxmox.com/wiki/PCI(e)_Passthrough
https://github.com/strongtz/i915-sriov-dkms
适用于Proxmox VE 8.x版本,内核6.1~6.5.
一、编译安装i915-sriov-dkms
首先确保启用了pve-no-subscription源和debian源,推荐先把debian源换成国内源 如清华源。
然后先更新一下软件包,并安装其他依赖,主要是需要确保内核头文件和内核版本一致,所以干脆全更新到最新版本:
Shell
apt update
apt upgrade -y
apt install -y build-* dkms git pve-headers sysfsutils
全部安装完毕后,需要先重启一下:
Shell
reboot
(有能力的可以尝试卸载旧版本内核和头文件,以节省空间)
重启好以后,接下来下载源码到指定位置:
Shell
cd /usr/src
git clone https://github.com/strongtz/i915-sriov-dkms.git
mv i915-sriov-dkms i915-sriov-dkms-6.1
找到/usr/src/i915-sriov-dkms-6.1/dkms.conf文件,修改如下两行,修改前为:
PACKAGE_NAME=”@_PKGBASE@”
PACKAGE_VERSION=”@PKGVER@”
修改后:
PACKAGE_NAME=”i915-sriov-dkms”
PACKAGE_VERSION=”6.1″
最后编译dkms模块并安装:
Shell
dkms install -m i915-sriov-dkms -v 6.1 –force
二、修改系统设置
定位到/etc/default/grub文件,打开编辑如下高亮这一行:
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=”quiet”
GRUB_CMDLINE_LINUX=””
把高亮的这一行修改为:
GRUB_CMDLINE_LINUX_DEFAULT=”quiet intel_iommu=on iommu=pt intel_iommu=on i915.enable_guc=3 i915.max_vfs=7″
打开/etc/modules文件,添加下面高亮的行:
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with “#” are ignored.
# Parameters can be specified after the module name.
vfio
vfio_iommu_type1
vfio_pci
#vfio_virqfd #not needed if on kernel 6.2 or newer
PVE 8.1内核版本是6.5,大于6.2,最后一行不用写,故注释掉。
运行如下命令,查看显卡的PCI总线地址:
Shell
lspci | grep VGA
命令大致如下:
00:02.0 VGA compatible controller: Intel Corporation Raptor Lake-P [Iris Xe Graphics] (rev 04)
前面的 00:02.0 就是总线地址,不过是缩写地址,省略了前缀 0000: ,完整的是 0000:00:02.0 ,记住这个地址。
添加下面一行到 /etc/sysfs.conf 文件中:
devices/pci0000:00/0000:00:02.0/sriov_numvfs = 7
上面命令中的 0000:00:02.0 就是前面获取的显卡的PCI总线地址,替换成你自己的就可以了。一般情况下intel核显都是 0000:00:02.0 这个地址,不用改。
运行命令:
Shell
update-grub
update-initramfs -u -k all
最后重启:
Shell
reboot
这样就完成了,最后看一下效果,下图中0000:00:02.1~0000:00:02.7这7个就是SRIOV虚拟出来的显卡:
相关文章: