顺带接有偿部署,有需要可以加博主微信
微信:ha_July

英特尔持续推动英特尔®图形处理器上的图形虚拟化技术。这些技术中的最新技术是单根 IO 虚拟化 (SR-IOV),它取代了之前的 英特尔® Graphics Virtualization Technology –g (GVT-g)要了解每个英特尔®显卡家族支持哪种显卡虚拟化技术,请参阅下表:
注意,11代Alchemist代号并不支持SR-IOV,也不支持GVT-g
支持列表

PVE基本设置

安装PVE过程略过,提前将pve安装好,推荐安装PVE8版本,如要正常使用11-14代核显SR-IOV,需要将内核更新到6.1以上。并在BIOS提前开启VT-d,SR-IOV,Above 4GB(如有可以开)

本篇文章将大量使用nano文本编辑命令,至于怎么使用自行百度,这里不重复造轮子了。 知道如何保存就行Ctrl +X 输入“Y”回车保存

更换系统源

国内清华源

# 编辑sources.list
nano /etc/apt/sources.list
# 将原有的源链接在句首加 # 注释掉,更换以下清华源信息
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

更换企业源

国内清华源

# 编辑pve-enterprise.list
nano /etc/apt/sources.list.d/pve-enterprise.list
# 将原有的源链接在句首加 # 注释掉,更换以下清华源信息
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian bookworm pve-no-subscription

修复源401错误

# 编辑ceph.list
nano /etc/apt/sources.list.d/ceph.list
# 将原有的源链接在句首加 # 注释掉,添加中科大ceph源
deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription

执行更新软件源

apt update 

LXC容器更源

国内清华源

# 备份APLInfo.pm
cp /usr/share/perl5/PVE/APLInfo.pm /usr/share/perl5/PVE/APLInfo.pm_back
# 替换为清华源:
sed -i 's|http://download.proxmox.com|https://mirrors.tuna.tsinghua.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm
# 重启服务后生效
systemctl restart pvedaemon.service

PVE常用优化脚本


1) 去掉登录订阅提示
2) 合并local-lvm以最大化利用硬盘空间
3) 添加CPU频率硬盘温度
4) 删掉不用的内核等信息

# 下载pve_source二进制文件到/root目录
wget https://yangwenqing.com/files/pve/pve_source && chmod +x pve_source && ./pve_source

intel 11-14代开启SRIOV核显虚拟化

以下设置是11-14代开启SRIOV核显的设置,GVT-g的往下翻。

安装headers和firmware并重启

apt install pve-headers-$(uname -r)
# 安装成功后重启
reboot

开启硬件直通和i915guc

需要提前在主板BIOS开启虚拟化功能,才能开启硬件直通。在BIOS开启vt-dSRIOV
使用nano命令编辑/etc/default/grub

nano /etc/default/grub 
# 开启iommu分组和i915guc,在里面找到:GRUB_CMDLINE_LINUX_DEFAULT="quiet"项将其修改为
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt i915.enable_guc=3 i915.max_vfs=7 pcie_acs_override=downstream,multifunction"
# 更新grub
update-grub

加载内核模块

编辑nano /etc/modules

vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd

执行更新initramfs

# 更新initramfs
update-initramfs -u -k all
# 重启
reboot

验证是否开启直通

# 验证是否开启iommu
dmesg | grep iommu
或者
dmesg | grep -e DMAR -e IOMMU -e AMD-Vi

出现如下例子。则代表成功

[ 1.341100] pci 0000:00:00.0: Adding to iommu group 0
[ 1.341116] pci 0000:00:01.0: Adding to iommu group 1
[ 1.341126] pci 0000:00:02.0: Adding to iommu group 2
[ 1.341137] pci 0000:00:14.0: Adding to iommu group 3
[ 1.341146] pci 0000:00:17.0: Adding to iommu group 4

此时输入命令

find /sys/kernel/iommu_groups/ -type l 
#出现很多直通组,就代表成功了。如果没有任何东西,就是没有开启
lsmod | grep vfio
# 检测模块是否加载
vfio_pci               16384  4
vfio_pci_core          94208  1 vfio_pci
vfio_iommu_type1       49152  2
vfio                   57344  17 vfio_pci_core,vfio_iommu_type1,vfio_pci
iommufd                73728  1 vfio
irqbypass              16384  41 vfio_pci_core,kvm
#出现这类信息,就代表成功了。

拉取i915-sriov驱动

# 安装git工具及dkms
apt install -y git build-* dkms
# 拉取i915-sriov-dkms
git clone https://github.com/strongtz/i915-sriov-dkms.git

编译i915-sriov驱动

Linux i915-sriov驱动程序目前只支持6.1-6.5内核,低于或者高于该阶段的内核请先进行升级或者降级内核。

# 进入i915-sriov-dkms目录
cd i915-sriov-dkms
# 使用nano命令编辑dkms.conf文件
nano dkms.conf
将第一行改为PACKAGE_NAME="i915-sriov-dkms"
将第二行改为PACKAGE_VERSION="6.5"
Ctrl +X输入Y回车保存退出nano
# 安装i915-sriov
dkms add .
dkms install -m i915-sriov-dkms -v 6.5

如何安装6.5内核?

# 安装6.5内核
apt install pve-kernel-6.5
# 查看当前安装的内核
proxmox-boot-tool kernel list
# 如 6.5.13-5-pve
# 将装好的6.5内核设置成第一启动项
proxmox-boot-tool kernel pin 6.5.13-5-pve


经过漫长等待完成后,检查安装是否成功,运行

modinfo i915|grep vf 
# 反馈如下表示成功:
parm:           max_vfs:Limit number of virtual functions to allocate. (0 = no VFs [default]; N = allow up to N VFs) (uint)
# 如安装不成功请删除此模块,重新安装,直至有以上成功反馈信息。
dkms remove -m i915-sriov-dkms -v 6.5
dkms install -m i915-sriov-dkms -v 6.5

安装sysfsutils

apt install -y sysfsutils

添加VFs核显数量

按需设置最高7个,设置1个时性能最强。

# 开启3个VFs核显数量
echo "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 3" > /etc/sysfs.conf 
# 重启
reboot

验证是否开启核显SRIOV

使用lspci命令查看核显信息,有如下内容则成功开启核显
注意:物理核显02.0不能直通,否则所有虚拟核显消失

00:02.0 VGA compatible controller: Intel Corporation Alder Lake-S GT1 [UHD Graphics 770](物理核显)
00:02.1 VGA compatible controller: Intel Corporation Alder Lake-S GT1 [UHD Graphics 770] (虚拟核显1)
00:02.2 VGA compatible controller: Intel Corporation Alder Lake-S GT1 [UHD Graphics 770] (虚拟核显2)
00:02.3 VGA compatible controller: Intel Corporation Alder Lake-S GT1 [UHD Graphics 770] (虚拟核显3)

创建核显SR-IOV的Win虚拟机参数

按以下虚拟机参数模板建立好虚拟机,打上核显驱动就能正常使用核显了。


SR-IOV的Win虚拟机参数
i5-12500T核显SR-IOV驱动正常

intel 6-10代开启GVT-g核显虚拟化

开启硬件直通和GVT-g

需要提前在主板BIOS开启虚拟化功能,才能开启硬件直通。在BIOS开启vt-d
使用nano命令编辑/etc/default/grub

nano /etc/default/grub 
# 开启iommu分组和GVT-g,在里面找到:GRUB_CMDLINE_LINUX_DEFAULT="quiet"项将其修改为
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt i915.enable_gvt=1 pcie_acs_override=downstream,multifunction"
# 更新grub
update-grub

加载内核模块

编辑nano /etc/modules

vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
kvmgt

执行更新initramfs

# 更新initramfs
update-initramfs -u -k all
# 重启
reboot

验证是否开启核显GVT-g

ls /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types
# 显示有2个或者更多即成功,UHD630核显最多可以开2个
i915-GVTg_V5_4  i915-GVTg_V5_8

创建核显GVT-g的Win虚拟机参数

按以下虚拟机参数模板建立好虚拟机,打上核显驱动就能正常使用核显了。


GVT-g的Win虚拟机参数
i3-9100核显GVT-g驱动正常

资源驱动下载

# virtIO驱动ISO:
https://yun.yangwenqing.com/Linux/DD/virtio-win-0.1.229.iso
# 7-10代核显驱动:
https://www.intel.cn/content/www/cn/zh/download/776137/intel-7th-10th-gen-processor-graphics-windows.html
# 11-13代核显驱动:
https://www.intel.cn/content/www/cn/zh/download/785597/intel-arc-iris-xe-graphics-windows.html

相关文章参考

爱折腾的老高博客-Intel 11(Tigerlake)/12/13/14代SRIOV vGPU虚拟核显直通应用
佛西博客-PVE开启显卡虚拟化intel GVT-g

Last modification:May 25th, 2024 at 07:32 pm
If you think my article is useful to you, please feel free to appreciate