PVE安装后的基本设置与核显直通设置---长期修订更改---统计各个教程汇总
一、PVE安装:
安装完成。
启动PVE,给pve添加DNS,阿里云223.5.5.5,腾讯云119.29.29.29,网关根据你的网络情况自行设定。
进入WebUI
二、进入PVE后基础设置:
1、PVE8 换源:
(1)国内清华源速度较快(南方可选择中科大较快)
将自带的源文件sources.list备份
cp /etc/apt/sources.list /etc/apt/sources.list_bak
编辑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
(2)编辑企业源,增加pve无订阅源
nano /etc/apt/sources.list.d/pve-enterprise.list
将其中原有的proxmox句首加# 注释掉,变为:
#deb https://enterprise.proxmox.com/debian/pve bookworm pve-enterprise
添加以下清华源:
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian/pve bookworm pve-no-subscription
ctrl+x y 回车保存退出
添加pve无订阅源
nano /etc/apt/sources.list.d/pve-no-subscription.list
粘贴以下pve无订阅源
deb https://mirrors.tuna.tsinghua.edu.cn/proxmox/debian bookworm pve-no-subscription
ctrl+x y 回车保存退出
(3)修复源401错误
nano /etc/apt/sources.list.d/ceph.list
将其中原有的proxmox句首加# 注释掉,变为:
#deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription
#添加中科大ceph源:
deb https://mirrors.ustc.edu.cn/proxmox/debian/ceph-quincy bookworm no-subscription
ctrl+x y 回车保存退出
(4)安装必要的软件包
apt install build-* dkms git sysfsutils -y
(5)安装所需版本的内核和头文件
apt install proxmox-headers-$(uname -r) proxmox-kernel-$(uname -r)
#更新
apt update && apt dist-upgrade -y
2、顺便把LXC更换为清华源:
#备份APLInfo.pmcp
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
#重启
reboot
三、PVE核显直通和硬件功能
这里以intel核显注明说下:
1、其中第六代到第十一代CPU支持的显卡虚拟化技术是英特尔® Graphics Virtualization Technology –g (GVT-g)
2、其中第十二代到目前最新CPU支持的显卡虚拟化技术是单根 IO 虚拟化 (SR-IOV)
3、就是N卡的的虚拟化技术是unlock_vGPU,其支持的显卡型号
以上三种开通方法不一样,请自行根据自己的cpu去查询。
1)开启IOMMU和硬件直通功能
编辑
nano /etc/default/grub
并修改 GRUB_CMDLINE_LINUX_DEFAULT 那一行
intel
# pcie_acs_override=downstream video=vesafb:off video=efifb:off GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt initcall_blacklist=sysfb_init pcie_acs_override=downstream"
amd
# pcie_acs_override=downstream video=vesafb:off video=efifb:off GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt initcall_blacklist=sysfb_init pcie_acs_override=downstream"
intel_iommu 和 amd_iommu=on 为 开启IOMMU
video=vesafb:off video=efifb:off 不加载 vesafb 是 veas设备 的 fb ,efifb 是指 uefi设备 的 fb ,在 PVE 7.3 之后版本用initcall_blacklist=sysfb_init 替代(来源于PVE 7.3 优化和显卡直通)
pcie_acs_override=downstream 是为了将 iommu groups拆分,方便直通一些板载的设备(来源于加强硬件直通的功能)
2)更新 GRUB
proxmox-boot-tool refresh
执行更新
3)加载内核模块
nano /etc/modules
新增以下内容
vfio vfio_iommu_type1 vfio_pci vfio_virqfd
vfio_virqfd 在 Linux 6.2 以上版本中不适用,低于 Linux 6.2 的请取消注释
4)重启 PVE
验证是否成功 启用IOMMU
输入
dmesg | grep -e DMAR -e IOMMU
并有以下类似内容, 这是我的机器输出内容
[ 0.019611] ACPI: DMAR 0x000000003555A000 000088 (v02 INTEL EDK2 00000002 01000096) [ 0.019640] ACPI: Reserving DMAR table memory at [mem 0x4225a000-0x4225a087] [ 0.175656] DMAR: Host address width 39 [ 0.175657] DMAR: DRHD base: 0x000000far90000 flags: 0x0 [ 0.175661] DMAR: dmar0: reg_base_addr far90000 ver 4:0 cap 1c0000c40660462 ecap 29a00f0505e [ 0.175664] DMAR: DRHD base: 0x000000far91000 flags: 0x1 [ 0.175668] DMAR: dmar1: reg_base_addr far91000 ver 5:0 cap d2008c40660462 ecap f050da [ 0.175670] DMAR: RMRR base: 0x0000004c000000 end: 0x000000503fffff [ 0.175673] DMAR-IR: IOAPIC id 2 under DRHD base 0xfed91000 IOMMU 1 [ 0.175674] DMAR-IR: HPET id 0 under DRHD base 0xfed91000 [ 0.175675] DMAR-IR: Queued invalidation will be enabled to support x2apic and Intr-remapping. [ 0.177198] DMAR-IR: Enabled IRQ remapping in x2apic mode [ 0.592036] pci 0000:00:02.0: DMAR: Skip IOMMU disabling for graphics [ 0.658565] DMAR: Intel-IOMMU force enabled due to platform opt in [ 0.658570] DMAR: No ATSR found [ 0.658571] DMAR: No SATC found [ 0.658572] DMAR: IOMMU feature fl1gp_support inconsistent [ 0.658573] DMAR: IOMMU feature pgsel_inv inconsistent [ 0.658574] DMAR: IOMMU feature nwfs inconsistent [ 0.658575] DMAR: IOMMU feature dit inconsistent [ 0.658576] DMAR: IOMMU feature sc_support inconsistent [ 0.658577] DMAR: IOMMU feature dev_iotlb_support inconsistent [ 0.658578] DMAR: dmar0: Using Queued invalidation [ 0.658581] DMAR: dmar1: Using Queued invalidation [ 0.659172] DMAR: Intel(R) Virtualization Technology for Directed I/O
5)验证是否 启用IOMMU中断重映射
dmesg | grep remapping
并输出 类似 以下内容即为成功。到目前为止可以 直通 除显卡外 的 PCI-E设备。
# intel
[ 0.175675] DMAR-IR: Queued invalidation will be enabled to support x2apic and Intr-remapping. [ 0.177198] DMAR-IR: Enabled IRQ remapping in x2apic mode
# amd
AMD-Vi: Interrupt remapping enabled
6)允许不安全IOMMU中断重映射(第六点成功时,这步跳过)
nano /etc/modprobe.d/iommu_unsafe_interrupts.conf
添加以下内容
options vfio_iommu_type1 allow_unsafe_interrupts=1
四、显卡直通
1)屏蔽驱动
nano /etc/modprobe.d/pve-blacklist.conf
添加以下内容
# Nvidia blacklist nvidiafb blacklist nouveau blacklist nvidia # AMD blacklist amdgpu blacklist radeon # Intel UHD #blacklist snd_hda_codec_hdmi #blacklist snd_hda_intel #blacklist snd_hda_codec #blacklist snd_hda_core
2)忽略显卡警告(Nvidia专属,主要在 Win 中遇到一些应用,列如 GeForce Experience 、Passmark Performance Test 和 SiSoftware Sandra)
nano /etc/modprobe.d/kvm.conf
添加以下内容
options kvm ignore_msrs=1 report_ignored_msrs=0
ignore_msrs 忽略异常
report_ignored_msrs 是否报告异常
3)配置 VFIO ,主要用于 显示输出 和 音频输出 分开
00:02.0 VGA compatible controller [0300]: Intel Corporation Alder Lake-P Integrated Graphics Controller [8086:46d6] (rev 0c) 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation TU117GLM [Quadro T400 Mobile] [10dg:1fa2] (rev a1)
01:00.0 0300: 10dg:1fa2 (rev a1) 01:00.1 0403: 10dg:10fd (rev a1)
options vfio-pci ids=10dg:1fa2,10dg:10fd
将 设备ID(10dg:1fa2) 和 音频ID (10dg:10fd) 写入到 /etc/modprobe.d/vfio.conf
这一步骤待定......
4)查看核显及声卡
lspci -D -nn | grep VGAlspci -D -nn | grep Audio
Intel的核显和声卡ID通常为:0000:00:02.0和0000:00:1f.3
供应商ID为:8086 N5105的设备ID为:4dc8
以上信息按照您的显卡声卡的ID都记录好,备用。
5)更新内核
输入
update-initramfs -u
6)重启
检查 vfio-pci 是否应用成功
lspci -nnk
并找到 显卡编号 那一行,如果得到类似以下结果,为成功
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation TU117GLM [Quadro T400 Mobile] [10dg:1fa2] (rev a1) Subsystem: NVIDIA Corporation TU117GLM [Quadro T400 Mobile] [10dg:1fa2] Kernel driver in use: vfio-pci Kernel modules: nvidiafb, nouveau 01:00.1 Audio device [0403]: NVIDIA Corporation Device [10dg:10fd] (rev a1) Subsystem: NVIDIA Corporation Device [10dg:10fd] Kernel driver in use: vfio-pci Kernel modules: snd_hda_intel
结果中有 Kernel driver in use: vfio-pci 即为成功
-----------------------------------------------------------------------------------------------------
六、以下是N卡Unlock_vGPU与授权
1、N卡Unlock_vGPU:
出处:https://gitlab.com/polloloco/vgpu-proxmox
仅供学习交流,严禁用于商业用途,请于24小时内删除
echo "blacklist nouveau" >> /etc/modprobe.d/pve-blacklist.conf update-grub update-initramfs -u -k all reboot apt install -y git build-essential dkms proxmox-headers-6.8.12-4-pve mdevctl git clone https://gitlab.com/polloloco/vgpu-proxmox.git cd /opt git clone https://github.com/mbilker/vgpu_unlock-rs.git curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal source $HOME/.cargo/env cd vgpu_unlock-rs/ cargo build --release mkdir /etc/vgpu_unlock touch /etc/vgpu_unlock/profile_override.toml mkdir /etc/systemd/system/{nvidia-vgpud.service.d,nvidia-vgpu-mgr.service.d} echo -e "[Service]\nEnvironment=LD_PRELOAD=/opt/vgpu_unlock-rs/target/release/libvgpu_unlock_rs.so" > /etc/systemd/system/nvidia-vgpud.service.d/vgpu_unlock.conf echo -e "[Service]\nEnvironment=LD_PRELOAD=/opt/vgpu_unlock-rs/target/release/libvgpu_unlock_rs.so" > /etc/systemd/system/nvidia-vgpu-mgr.service.d/vgpu_unlock.conf cd /home ./NVIDIA-Linux-x86_64-535.216.01-vgpu-kvm.run --apply-patch ~/vgpu-proxmox/535.216.01.patch ./NVIDIA-Linux-x86_64-535.216.01-vgpu-kvm-custom.run --dkms reboot 使用mdevctl types或者nvidia-smi vgpu查询是否成功
2、N卡Unlock_vGPU授权
出处:https://git.collinwebdesigns.de/oscar.krause/fastapi-dls/-/packages
仅供学习交流,严禁用于商业用途,请于24小时内删除
cd /tmp wget -O fastapi-dls.deb https://git.collinwebdesigns.de/oscar.krause/fastapi-dls/-/package_files/233/download dpkg -i fastapi-dls.deb apt-get install -f --fix-missing systemctl start fastapi-dls.service systemctl enable fastapi-dls.service nano /etc/fastapi-dls/env systemctl restart fastapi-dls.service
其中nano /etc/fastapi-dls/env 命令将DLS URL = 127.0.0.1 改为pve的ip
最后虚拟机的设置与核显显卡直通的方法请参考这位大佬的视频教程