N100主机PVE使用sriov将核显通到win10虚拟机

发布时间 2024-01-02 18:33:54作者: InspirationPlace

参考:
https://www.derekseaman.com/2023/11/proxmox-ve-8-1-windows-11-vgpu-vt-d-passthrough-with-intel-alder-lake.html
https://www.bilibili.com/video/BV1AN4y1D7Bh/?spm_id_from=333.337.search-card.all.click&vd_source=53719373d625cf6347183b633b60f7c9
https://www.right.com.cn/forum/thread-8258222-1-1.html
main: https://www.bilibili.com/read/cv25910613/?spm_id_from=333.999.0.0
非常感谢以上大佬的教程
主机:CPU: N100 内存16G
PVE版本:8.1.3 内核版本:Linux 6.5.11-4-pve (2023-11-20T10:19Z)
Windows版本: 2021_LTSC

  1. 可选-替换国内源
    修改软件源为国内源
    8.0的PVE对应的Debian版本为Debian 12 Bookworm
    可以直接搜索Debian 12替换国内源
    这是我的/etc/apt/sources.list文件参考,其他的源基本用不到
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bookworm pve-no-subscription

最后一个源在安装驱动时会用到,不然会无法搜索到pve头文件
2. 修改GRUB
修改/etc/default/grub文件的GRUB_CMDLINE_LINUX_DEFAULT项, 添加"quiet intel_iommu=on iommu=pt i915.enable_guc=3 i915.max_vfs=7"
3. 安装驱动
源: https://github.com/strongtz/i915-sriov-dkms
安装headers,用于安装驱动
apt update && apt install pve-headers-$(uname -r)
安装驱动编译需要软件包
apt install build-* dkms
克隆GitHub库
git clone https://github.com/strongtz/i915-sriov-dkms
修改库配置并设置内核版本
cp -a i915-sriov-dkms/dkms.conf{,.bak}
sed -i 's/"@_PKGBASE@"/"i915-sriov-dkms"/g' i915-sriov-dkms/dkms.conf
sed -i 's/"@PKGVER@"/"'"$KERNEL"'"/g' i915-sriov-dkms/dkms.conf
sed -i 's/ -j$(nproc)//g' i915-sriov-dkms/dkms.conf
cat i915-sriov-dkms/dkms.conf
移动到指定位置
mv i915-sriov-dkms /usr/src/i915-sriov-dkms-6.5.11-4
编译并安装驱动
dkms install --force -m i915-sriov-dkms -v 6.5.11-4
检查一下驱动安装情况
dkms status
如果有多行或者报错
dkms remove
4. 更新 GRUB 与 initrramfs
update-grub && update-initramfs -u
5. 安装sysfsutils(这一步只有宿主机需要执行!!!)
apt install sysfsutils
6. 查找iGPU所在总线
lspci | grep VGA
一般N100为00:02.0
然后修改/etc/sysfs.conf
echo "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 1" > /etc/sysfs.conf
这里的数字为你想虚拟出来的显卡数量, 1-7根据需求来
7. 重启系统, 确认是否成功
lspci | grep VGA
dmesg | grep i915
正常情况下, 应该能看到你设置的VGA VF数以及Enabled 7 VFs, 并确保没有出现错误
8. PVE windows配置


在装完windows之后, 需要设置RDP或者安装远程软件(要不然你直通了之后就看不到控制台虚拟机画面了), 再直通虚拟显卡, 添加PCI设备