编辑
2025-07-16
Linux
0
请注意,本文编写于 145 天前,最后修改于 145 天前,其中某些信息可能已经过时。

目录

一、改源
二、直通SR-IOV
1.查看PVE当前版本
2.安装当前内核版本的头文件
三、配置直通的基础环境
1.开启IOMMU直通功能
2.增加虚拟化驱动,加载vifo系统模块
3.取消屏蔽显卡驱动
四、更新Grub引导配置和initramfs
五、配置开启SR-IOV虚拟化核显
1.安装编译环境依赖
2.添加一个临时的KERNEL环境变量
3.克隆项目
4.检查dkms.conf 配置文件中是否配置正确的内核版本和i915-sriov-dkms
5.创建目录的符号链接到/usr/src/目录下
6.进入到链接到的目录
7.查看已安装的 DKMS 模块及其状态
8.开始编译内核加入i915-sriov驱动
9.查询当前核显ID
10.修改下面代码的核显ID和虚拟核显数
11.重启完检查是否开启成功
三、LXC直通核显配置

前言

无图眼神版,不懂请勿乱来。PVE炸了与我无关。!

一、改源

1.备份源

cp /etc/apt/sources.list /etc/apt/sources.list.backup

2.添加国内源

注意

有两段代码,第一段整段代码一次性复制

cat <<EOF > /etc/apt/sources.list deb http://mirrors.ustc.edu.cn/debian/ bookworm main non-free-firmware deb-src http://mirrors.ustc.edu.cn/debian/ bookworm main non-free-firmware deb https://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib deb http://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free-firmware deb-src http://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free-firmware EOF
echo "deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list

3.PVE CT源

sed -i.bak 's|http://download.proxmox.com|https://mirrors.ustc.edu.cn/proxmox|g' /usr/share/perl5/PVE/APLInfo.pm

4.屏蔽企业源

sed -i 's/^deb https:\/\/enterprise.proxmox.com\/debian\/pve/#deb https:\/\/enterprise.proxmox.com\/debian\/pve/' /etc/apt/sources.list.d/pve-enterprise.list

5.屏蔽 Ceph 源

sed -i 's/^deb https:\/\/enterprise.proxmox.com\/debian\/ceph-quincy/#deb https:\/\/enterprise.proxmox.com\/debian\/ceph-quincy/' /etc/apt/sources.list.d/ceph.list

6.更新源

apt-get update

二、直通SR-IOV

1.查看PVE当前版本

pveversion

2.安装当前内核版本的头文件

apt install pve-headers-6.x.x-x-pve

三、配置直通的基础环境

1.开启IOMMU直通功能

echo -e "vfio\nvfio_iommu_type1\nvfio_pci\nvfio_virqfd" | tee -a /etc/modules

2.增加虚拟化驱动,加载vifo系统模块

echo -e "vfio\nvfio_iommu_type1\nvfio_pci\nvfio_virqfd" | tee -a /etc/modules

3.取消屏蔽显卡驱动

nano /etc/modprobe.d/blacklist.conf

全部删除 如果有的话

四、更新Grub引导配置和initramfs

update-grub
update-initramfs -u -k all

重启

/reboot

五、配置开启SR-IOV虚拟化核显

1.安装编译环境依赖

apt-get install --no-install-recommends git mokutil sysfsutils -y
apt install --reinstall dkms -y

2.添加一个临时的KERNEL环境变量

KERNEL=$(uname -r); KERNEL=${KERNEL%-pve}

3.克隆项目

一行!一行!输入 !!! git clone https://github.com/strongtz/i915-sriov-dkms.git cd i915-sriov-dkms/ sed -i 's/"@_PKGBASE@"/"i915-sriov-dkms"/g' ~/i915-sriov-dkms/dkms.conf sed -i "s/^PACKAGE_VERSION=.*/PACKAGE_VERSION=\"$KERNEL\"/" ~/i915-sriov-dkms/dkms.conf

4.检查dkms.conf 配置文件中是否配置正确的内核版本和i915-sriov-dkms

cat ~/i915-sriov-dkms/dkms.conf

5.创建目录的符号链接到/usr/src/目录下

dkms add .

6.进入到链接到的目录

cd /usr/src/i915-sriov-dkms-$KERNEL

7.查看已安装的 DKMS 模块及其状态

dkms status

8.开始编译内核加入i915-sriov驱动

dkms install -m i915-sriov-dkms -v $KERNEL -k $(uname -r) --force -j 1

注意

编译过程时间稍长,需要等待

检查编译是否成功

dkms status

9.查询当前核显ID

lspci | grep VGA

10.修改下面代码的核显ID和虚拟核显数

echo "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 3" > /etc/sysfs.conf # 0000:00:02.0 这个修改为你的ID # sriov_numvfs = 3里面的3修改为其他值,不要超过7

重启

/reboot

11.重启完检查是否开启成功

lspci | grep VGA

三、LXC直通核显配置

lxc.cgroup2.devices.allow: c 226:0 rwm lxc.cgroup2.devices.allow: c 226:128 rwm lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file lxc.apparmor.profile: unconfined lxc.cap.drop:

本文作者:Tony325

本文链接:

版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!