2024.09.21已更新:最新保姆级PVE8.2安装教程!虚拟机PCIE设备及SR-IOV核显直通,最多分配7个虚拟化单独核显!最强虚拟机!


提示

更新日期:2024.09.04

作者的项目已经更新到支持内核 6.8 ,所以,推荐大家下载 PVE 8.2.2 最新版本安装

至于内核小于 6.5 的,这边教程就不显示了!

已经测试的支持内核范围 6.5.13-3-pve ~ 6.8.12-1-pve ,具体看项目支持情况

2024 09 21 测试情况:教程支持最新 PVE 8.2.5 内核版本:6.8.12-2-pve

准备工作

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 的支持,博主使用的 i5-13600T),请使用如下命令直通 PCIE 设备:
i915.max_vfs=3 这里的 3 是需要虚拟的核显数量,需要和下面的数量相同

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=3"' /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,用于旁路由。

具体命令如下,若是不太明白,推荐先观看 本期视频

#2024-09-04 支持内核 6.8

#Proxmox VE 主机推荐内核范围:proxmox-kernel-6.5.13-3-pve ~ 6.8.12-1-pve

uname -r       # 已经测试的支持内核范围 6.5.13-3-pve ~ 6.8.12-1-pve ,具体看项目支持情况 

# 2024 09 21 测试情况:教程支持最新 PVE 8.2.5 内核版本:6.8.12-2-pve

# 更换源(可选,但是推荐更换)
wget https://v2rayssr.com/tool/yuan.sh -O yuan.sh && chmod +x yuan.sh && ./yuan.sh

# 更新源
apt update -y

# 更新内核,若刚才 uname -r 的内核版本过小,可以更新内核!更新后,内核大于 6.8.12-1 的情况还未尝试
apt upgrade -y   # 更新内核以后,必须重新启动!(大的更新,都是推荐重启)
reboot

# 更新到最新,但是前提内核不能超过GitHub项目的最新版本(更多内核没进行测试而已)。6.8.12-1
# 后续避免升级内核
uname -r       # 已经测试的支持内核范围 6.5.13-3-pve ~ 6.8.12-1-pve ,具体看项目支持情况 

apt install build-* dkms git sysfsutils -y
apt install proxmox-headers-$(uname -r) proxmox-kernel-$(uname -r)
cd ~
git clone https://github.com/strongtz/i915-sriov-dkms.git
cd ~/i915-sriov-dkms
dkms add .
dkms install -m i915-sriov-dkms -v $(cat VERSION) --force
lspci | grep VGA    # 请记录当前的核显ID,修改下行的ID后执行下面的代码。

# sriov_numvfs = 3 这里的 3 是需要虚拟的核显数量,需要和上面的数量相同
echo "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 3" > /etc/sysfs.conf
reboot

重启之后,在 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:~# 

我就是我,不起眼的那颗烟火!有时候看到自己也会恼火!