因为项目并没有支持到内核 6.8 ,所以,推荐大家下载 PVE 8.1.2 版本,或是降级来进行!

可以使用 PVE 安装包 8.1.2 ,内核 6.5.11-8

准备工作

1、大于 2G 的 U 盘(存放 Proxmox Virtual Environment ISO 镜像)

2、刻录工具( 推荐 balenaEtcher ) 点击下载

3、Proxmox Virtual Environment ISO 镜像 点击下载

4、SSH 登录工具 FinalShell(支持 MacOS、Windows)点击下载

5、自行准备 OpenWRT 的固件,用于 PVE 设置过程中的外网访问(若是有其他解决办法,请忽略)

去除 PVE 的登录弹窗

Proxmox VE 6.3 / 6.4 / 7.0 / 7.1 / 7.2 / 7.3 / 7.4 / 8.0 / 8.1 去掉未订阅的提示

注意:去除订阅弹窗提醒以后,必须清除浏览器的缓存数据(清理浏览器缓存)后生效

sed -i_orig "s/data.status === 'Active'/true/g" /usr/share/pve-manager/js/pvemanagerlib.js
sed -i_orig "s/if (res === null || res === undefined || \!res || res/if(/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
sed -i_orig "s/.data.status.toLowerCase() !== 'active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
systemctl restart pveproxy

更换 PVE 源

非必须

wget https://v2rayssr.com/tool/yuan.sh -O yuan.sh && chmod +x yuan.sh && ./yuan.sh

直通 PCIe 设备

若你是想开启核显的 SR-IOV (需要 CPU 的支持),请使用如下命令直通 PCIE 设备:

sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT/c\GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt pcie_acs_override=downstream i915.enable_guc=3 i915.max_vfs=7"' /etc/default/grub
echo -e "vfio\nvfio_iommu_type1\nvfio_pci\nvfio_virqfd" | tee -a /etc/modules
update-grub
update-initramfs -u -k all
reboot

若你的 CPU 不支持 SR-IOV,或是不想开启 SR-IOV,请使用如下命令直通 PCIE 设备:

sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT/c\GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt pcie_acs_override=downstream"' /etc/default/grub
echo -e "vfio\nvfio_iommu_type1\nvfio_pci\nvfio_virqfd" | tee -a /etc/modules
update-grub
update-initramfs -u -k all
reboot

检验 PCIE 直通结果

Shell 窗口输入 lspci ,回显如下(里面包含你所有的 PCIe 设备列表):

root@pve:~# lspci
0000:00:00.0 Host bridge: Intel Corporation Device 4640 (rev 02)
0000:00:01.0 PCI bridge: Intel Corporation 12th Gen Core Processor PCI Express x16 Controller #1 (rev 02)
0000:00:02.0 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
0000:00:06.0 System peripheral: Intel Corporation RST VMD Managed Controller
0000:00:0a.0 Signal processing controller: Intel Corporation Platform Monitoring Technology (rev 01)
0000:00:0e.0 RAID bus controller: Intel Corporation Volume Management Device NVMe RAID Controller
0000:00:14.0 USB controller: Intel Corporation Alder Lake-S PCH USB 3.2 Gen 2x2 XHCI Controller (rev 11)
0000:00:14.2 RAM memory: Intel Corporation Alder Lake-S PCH Shared SRAM (rev 11)
0000:00:15.0 Serial bus controller: Intel Corporation Alder Lake-S PCH Serial IO I2C Controller #0 (rev 11)
0000:00:15.1 Serial bus controller: Intel Corporation Alder Lake-S PCH Serial IO I2C Controller #1 (rev 11)
0000:00:15.2 Serial bus controller: Intel Corporation Alder Lake-S PCH Serial IO I2C Controller #2 (rev 11)
0000:00:16.0 Communication controller: Intel Corporation Alder Lake-S PCH HECI Controller #1 (rev 11)
0000:00:17.0 System peripheral: Intel Corporation RST VMD Managed Controller
0000:00:1a.0 System peripheral: Intel Corporation RST VMD Managed Controller
0000:00:1b.0 PCI bridge: Intel Corporation Device 7ac0 (rev 11)
0000:00:1c.0 PCI bridge: Intel Corporation Alder Lake-S PCH PCI Express Root Port #1 (rev 11)
0000:00:1c.2 PCI bridge: Intel Corporation Device 7aba (rev 11)
0000:00:1d.0 PCI bridge: Intel Corporation Alder Lake-S PCH PCI Express Root Port #9 (rev 11)
0000:00:1f.0 ISA bridge: Intel Corporation Z690 Chipset LPC/eSPI Controller (rev 11)
0000:00:1f.3 Audio device: Intel Corporation Alder Lake-S HD Audio Controller (rev 11)
0000:00:1f.4 SMBus: Intel Corporation Alder Lake-S PCH SMBus Controller (rev 11)
0000:00:1f.5 Serial bus controller: Intel Corporation Alder Lake-S PCH SPI Controller (rev 11)
0000:01:00.0 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
0000:01:00.1 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
0000:01:00.2 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
0000:01:00.3 Ethernet controller: Intel Corporation Ethernet Controller X710 for 10GbE SFP+ (rev 02)
0000:05:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V (rev 03)
0000:06:00.0 PCI bridge: ASMedia Technology Inc. Device 1806 (rev 01)
0000:07:00.0 PCI bridge: ASMedia Technology Inc. Device 1806 (rev 01)
0000:07:02.0 PCI bridge: ASMedia Technology Inc. Device 1806 (rev 01)
0000:07:06.0 PCI bridge: ASMedia Technology Inc. Device 1806 (rev 01)
0000:07:0e.0 PCI bridge: ASMedia Technology Inc. Device 1806 (rev 01)
0000:08:00.0 Ethernet controller: Intel Corporation Ethernet Controller I226-V (rev 04)
0000:09:00.0 Ethernet controller: Intel Corporation Ethernet Controller I226-V (rev 04)
0000:0a:00.0 Ethernet controller: Intel Corporation Ethernet Controller I226-V (rev 04)
0000:0b:00.0 Ethernet controller: Intel Corporation Ethernet Controller I226-V (rev 04)
10000:e0:06.0 PCI bridge: Intel Corporation 12th Gen Core Processor PCI Express x4 Controller #0 (rev 02)
10000:e0:17.0 SATA controller: Intel Corporation Alder Lake-S PCH SATA Controller [AHCI Mode] (rev 11)
10000:e0:1a.0 PCI bridge: Intel Corporation Alder Lake-S PCH PCI Express Root Port #25 (rev 11)
10000:e0:1b.0 System peripheral: Intel Corporation RST VMD Managed Controller
10000:e0:1b.4 PCI bridge: Intel Corporation Device 7ac4 (rev 11)
10000:e1:00.0 Non-Volatile memory controller: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (rev 01)
10000:e2:00.0 Non-Volatile memory controller: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1602 (rev 01)
10000:e3:00.0 Non-Volatile memory controller: MAXIO Technology (Hangzhou) Ltd. NVMe SSD Controller MAP1202 (rev 01)
root@pve:~# 

开启核显的 SR-IOV

什么是SR-IOV?这里引用 Oracle 的说明 SR-IOV 技术是一种基于硬件的虚拟化解决方案,可提高性能和可伸缩性。SR-IOV 标准允许在虚拟机之间高效共享 PCIe(Peripheral Component Interconnect Express,快速外设组件互连)设备,并且它是在硬件中实现的,可以获得能够与本机性能媲美的 I/O 性能。SR-IOV 规范定义了新的标准,根据该标准,创建的新设备可允许将虚拟机直接连接到 I/O 设备。 简单来说,允许将一个PCIe设备虚拟化成多个设备,且每个虚拟化出来的设备都可以获得与物理设备相近的性能 如果显卡开启SR-IOV就可以给多台虚拟机同时配上显卡 网卡之类的设备也支持SR-IOV,但是不如显卡这么有用(毕竟虚拟化出来的网卡性能也没差多少,还不需要自己安装驱动)

在以下的 SR - IOV 设置中,请开启 PVE 的外网访问(需要访问 GitHub ),博主是已经提前在 PVE 部署了 OpenWRT,用于旁路由。

具体命令如下

# 测试版本为 8.1.2,内核版本为:6.5.11-8-pve
apt update -y
proxmox-boot-tool kernel pin 6.5.11-8-pve
apt install pve-headers-6.5.11-8-pve
apt-get install --no-install-recommends git mokutil sysfsutils -y
proxmox-boot-tool kernel list # 列出内核,检查是否为 6.5.11-8-pve
KERNEL=$(uname -r); KERNEL=${KERNEL%-pve}
cd ~
git clone https://github.com/strongtz/i915-sriov-dkms.git
cd ~/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
cat ~/i915-sriov-dkms/dkms.conf
apt install --reinstall dkms -y
dkms add .
cd /usr/src/i915-sriov-dkms-$KERNEL
dkms status
dkms install -m i915-sriov-dkms -v $KERNEL -k $(uname -r) --force -j 1
dkms status  # 回显显示:i915-sriov-dkms/6.5.13-1, 6.5.13-1-pve, x86_64: installed -- 成功安装
lspci | grep VGA  # 请记录当前的核显ID,修改下行的ID后执行下面的代码。
echo "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 7" > /etc/sysfs.conf
mokutil --import /var/lib/dkms/mok.pub
注册 MOK、继续、是、<密码>、重新启动
reboot

如果使用 Proxmox 8.1 或更高版本并启用安全启动,则必须设置 MOK。在 Proxmox 主机重启时,监控启动过程并等待执行 MOK 管理窗口,出现 MOK 窗口,需要按任意键继续,不然就自动跳过了。如果错过了第一次重启,则需要重新运行 mokutil 命令并再次重启。以后就不必了!

重启之后,在 SHELL 窗口输入 lspci | grep VGA ,回显如下所示,SR-IOV 开启成功,成功虚拟出了 7 个核显。

root@pve:~# lspci | grep VGA
0000:00:02.0 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
0000:00:02.1 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
0000:00:02.2 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
0000:00:02.3 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
0000:00:02.4 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
0000:00:02.5 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
0000:00:02.6 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
0000:00:02.7 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
root@pve:~#