自建AIO记录
一、开启IO-MMU和启用SR-IOV
1.修改grub文件
nano /etc/default/grub在GRUB_CMDLINE_LINUX_DEFAULT项末尾加上下面的内容
quiet intel_iommu=on pcie_aspm=off pcie_acs_override=downstream,multifunction video=efifb:off,vesafb:off,simplefb:off iommu=pt#解释
intel_iommu=on 开启 IOMMU,是适用于intel平台,对于 AMD CPU 需要使用 amd_iommu=on
iommu=pt:pt 是 passthrough 的缩写,可以提高性能
pcie_acs_override=downstream,multifunction: 可以将同一 Group 中的设备分开直通
video=efifb:off:禁用 efifb 驱动,防止出现报错 BAR 3: cannot reserve [mem]
pci=assign-busses和iommu=pt 是开启sr-iov需要的参数
pcie_aspm=off关闭ASPM
更新update-grub
update-grub2.加载直通内核模块
nano /etc/modules添加如下
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd3.重启查看参数
查看所有网卡(82599ES)
lspci -nn|grep Eth03:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 06)
0b:00.0 Ethernet controller [0200]: Qualcomm Atheros Killer E220x Gigabit Ethernet Controller [1969:e091] (rev 10)
0c:00.0 Ethernet controller [0200]: Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection [8086:10fb] (rev 01)
查看BF(网卡名为enp5s0f0f0)
更换debian源:
nano /etc/apt/sources.list删除默认的源,替换为:
deb http://mirrors.ustc.edu.cn/debian/ buster main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian/ buster main contrib non-free
deb http://mirrors.ustc.edu.cn/debian/ buster-updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian/ buster-updates main contrib non-free
deb http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free
# deb-src http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free更新
apt update安装lshw-gtk
apt install lshw -y使用lshw-gtk查看
lshw -c network -businfo
Bus info Device Class Description
=============================================================
pci@0000:03:00.0 network RTL8111/8168/8411 PCI Express Gig
pci@0000:0b:00.0 enp11s0 network Killer E220x Gigabit Ethernet Con
pci@0000:0c:00.0 enp5s0f0f0 network 82599ES 10-Gigabit SFI/SFP+ Netwo
usb@2:6 enx000ec6711984 network Ethernet interface
vmbr0 network Ethernet interface
ztnfag5sip network Ethernet interface
tap888i0 network Ethernet interface
查看SR-IOV开启状态(最后一项是支持sr-iov的)
lspci -s 05:00.0 -vvv | grep Capabilitiespcilib: sysfs_read_vpd: read failed: Input/output error
Capabilities: [40] Power Management version 3
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Capabilities: [70] MSI-X: Enable+ Count=64 Masked-
Capabilities: [a0] Express (v2) Endpoint, MSI 00
Capabilities: [e0] Vital Product Data
Capabilities: [100 v1] Advanced Error Reporting
Capabilities: [140 v1] Device Serial Number 00-1b-21-ff-ff-ba-bf-e6
Capabilities: [150 v1] Alternative Routing-ID Interpretation (ARI)
Capabilities: [160 v1] Single Root I/O Virtualization (SR-IOV)
查看网口链路状态(10000MB全双工)
ethtool enp5s0f0f0Settings for enp5s0f0f0:
Supported ports: [ FIBRE ]
Supported link modes: 10000baseT/Full
Supported pause frame use: Symmetric
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: 10000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: 10000Mb/s
Duplex: Full
Auto-negotiation: off
Port: FIBRE
PHYAD: 0
Transceiver: internal
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
查看网卡驱动版本(这个只需了解一下)
ethtool -i enp5s0f0driver: ixgbe
version: 5.13.19-1-pve
firmware-version: 0x00012b2c
expansion-rom-version:
bus-info: 0000:0c:00.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: yes
查看网卡支持多少VF(82599支持单根虚拟63个网卡)
cat /sys/bus/pci/devices/0000:0c:00.0/sriov_totalvfs63
4.利用开机脚本自动启用指定网卡的SR-iov虚拟数量,设定对应mac地址,在开机过程中打开SR-IOV VFs
nano /etc/init.d/net-sriov下面是net-sriov启动脚本示例内容,可根据具体情况修改,此处为转载
记得把编辑好的脚本粘贴到net-sriov里面。
原文:在PVE环境下打开SRIOV - Allegro的文章 - 知乎 https://zhuanlan.zhihu.com/p/356437308
#! /bin/sh
#
# Copyright (C) 2011, 2012, 2016 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
### BEGIN INIT INFO
# Provides: openvswitch-switch
# Required-Start: $network $named $remote_fs $syslog $openvswitch-switch
# Required-Stop: $remote_fs $openvswitch-switch
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: SR-IOV initialization.
#Description: Initializing VM's network with sriov support.
### END INIT INFO
start () {
#enable Sriov 把enp5s0f0f0虚拟12个网卡
echo 12 > /sys/class/net/enp5s0f0f0/device/sriov_numvfs
ip link set dev enp5s0f0f0 up
ip link set dev enp5s0f0f0 vf 0 mac aa:bb:cc:dd:ee:f1
ip link set dev enp5s0f0f0 vf 1 mac aa:bb:cc:dd:ee:f2
ip link set dev enp5s0f0f0 vf 2 mac aa:bb:cc:dd:ee:f3
ip link set dev enp5s0f0f0 vf 3 mac aa:bb:cc:dd:ee:f4
ip link set dev enp5s0f0f0 vf 4 mac aa:bb:cc:dd:ee:f5
ip link set dev enp5s0f0f0 vf 5 mac aa:bb:cc:dd:ee:f6
ip link set dev enp5s0f0f0 vf 6 mac aa:bb:cc:dd:ee:f7
ip link set dev enp5s0f0f0 vf 7 mac aa:bb:cc:dd:ee:f8
ip link set dev enp5s0f0f0 vf 8 mac aa:bb:cc:dd:ee:f9
ip link set dev enp5s0f0f0 vf 9 mac aa:bb:cc:dd:ee:a0
ip link set dev enp5s0f0f0 vf 10 mac aa:bb:cc:dd:ee:a1
ip link set dev enp5s0f0f0 vf 11 mac aa:bb:cc:dd:ee:a2
#initial OVS bridge
systemctl restart networking
# ovs-vsctl --no-wait add-br br0-ovs
# ovs-vsctl add-port br0-ovs enp5s0f0f0
# Manager Interface
# ip link set dev enp5s0f0f0v3 up
# ip address add 192.168.0.99/24 dev enp5s0f0f0v3
# ip route add default via 192.168.0.1
}
stop () {
[ "$READ_INTERFACES" != "no" ] && network_interfaces ifdown
ovs_ctl stop
}
case $1 in
start)
start
;;
stop | force-stop)
stop
;;
*)
echo "Usage: $0 {start|stop}" >&2
exit 1
;;
esac
exit 0
#! /bin/sh
#
# Copyright (C) 2011, 2012, 2016 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
### BEGIN INIT INFO
# Provides: openvswitch-switch
# Required-Start: $network $named $remote_fs $syslog $openvswitch-switch
# Required-Stop: $remote_fs $openvswitch-switch
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: SR-IOV initialization.
#Description: Initializing VM's network with sriov support.
### END INIT INFO
start () {
#enable Sriov 把enp5s0f0虚拟12个网卡
echo 12 > /sys/class/net/enp5s0f0/device/sriov_numvfs
ip link set dev enp5s0f0 up
ip link set dev enp5s0f0 vf 0 mac aa:bb:cc:dd:ee:f1
ip link set dev enp5s0f0 vf 1 mac aa:bb:cc:dd:ee:f2
ip link set dev enp5s0f0 vf 2 mac aa:bb:cc:dd:ee:f3
ip link set dev enp5s0f0 vf 3 mac aa:bb:cc:dd:ee:f4
ip link set dev enp5s0f0 vf 4 mac aa:bb:cc:dd:ee:f5
ip link set dev enp5s0f0 vf 5 mac aa:bb:cc:dd:ee:f6
ip link set dev enp5s0f0 vf 6 mac aa:bb:cc:dd:ee:f7
ip link set dev enp5s0f0 vf 7 mac aa:bb:cc:dd:ee:f8
ip link set dev enp5s0f0 vf 8 mac aa:bb:cc:dd:ee:f9
ip link set dev enp5s0f0 vf 9 mac aa:bb:cc:dd:ee:a0
ip link set dev enp5s0f0 vf 10 mac aa:bb:cc:dd:ee:a1
ip link set dev enp5s0f0 vf 11 mac aa:bb:cc:dd:ee:a2
#initial OVS bridge
systemctl restart networking
# ovs-vsctl --no-wait add-br br0-ovs
# ovs-vsctl add-port br0-ovs enp5s0f0
# Manager Interface
# ip link set dev enp5s0f0v3 up
# ip address add 192.168.0.99/24 dev enp5s0f0f0v3
# ip route add default via 192.168.0.1
}
stop () {
[ "$READ_INTERFACES" != "no" ] && network_interfaces ifdown
ovs_ctl stop
}
case $1 in
start)
start
;;
stop | force-stop)
stop
;;
*)
echo "Usage: $0 {start|stop}" >&2
exit 1
;;
esac
exit 05.对net-sriov脚本赋予可执行权限,启用sr-iov
chmod +x /etc/init.d/net-sriov
systemctl enable net-sriov6.重启pve
reboot检查pve网络界面有没有出现很多网卡
检查网卡mac地址是否设定成功
ip a二、显卡直通
1.修改grub文件
nano /etc/default/grub加入
video=efifb:off,vesafb:off,simplefb:off更新update-grub
update-grub2.加载直通内核模块
nano /etc/modules添加如下
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd3.屏蔽显卡
Intel核显:
echo "blacklist snd_hda_intel" >> /etc/modprobe.d/pve-blacklist.conf
echo "blacklist snd_hda_codec_hdmi" >> /etc/modprobe.d/pve-blacklist.conf
echo "blacklist i915" >> /etc/modprobe.d/pve-blacklist.confA卡:
echo "blacklist radeon" >> /etc/modprobe.d/pve-blacklist.conf
echo "blacklist amdgpu" >> /etc/modprobe.d/pve-blacklist.confN卡:
echo "blacklist nouveau" >> /etc/modprobe.d/pve-blacklist.conf
echo "blacklist nvidia" >> /etc/modprobe.d/pve-blacklist.conf
echo "blacklist nvidiafb" >> /etc/modprobe.d/pve-blacklist.conf如果是N卡还需要加入下面的配置到kvm.conf(据老外说是避免一些莫名其妙的错误):
echo "options kvm ignore_msrs=1" > /etc/modprobe.d/kvm.conf4.更新内核:
update-initramfs -k all -ureboot5.重启后检查模块是否正常加载:
lsmod | grep vfioroot@home:~# lsmod | grep vfio
vfio_pci 57344 0
vfio_virqfd 16384 1 vfio_pci
irqbypass 16384 2 vfio_pci,kvm
vfio_iommu_type1 36864 0
vfio 36864 2 vfio_iommu_type1,vfio_pci
6.把显卡绑定到vfio-pci
使用lspci 查看自己的显卡PCI地址
root@home:~# lspci
00:00.0 Host bridge: Intel Corporation Device 9b33 (rev 01)
00:01.0 PCI bridge: Intel Corporation 6th-10th Gen Core Processor PCIe Controller (x16) (rev 01)
00:02.0 VGA compatible controller: Intel Corporation CometLake-S GT2 [UHD Graphics 630] (rev 05) #核显 00:02.0
00:14.0 USB controller: Intel Corporation Comet Lake PCH-V USB Controller
00:16.0 Communication controller: Intel Corporation Device a3ba
00:17.0 SATA controller: Intel Corporation 400 Series Chipset Family SATA AHCI Controller
00:1b.0 PCI bridge: Intel Corporation Device a3e9 (rev f0)
00:1c.0 PCI bridge: Intel Corporation Device a392 (rev f0)
00:1c.3 PCI bridge: Intel Corporation Device a393 (rev f0)
00:1c.4 PCI bridge: Intel Corporation Device a394 (rev f0)
00:1d.0 PCI bridge: Intel Corporation Device a398 (rev f0)
00:1f.0 ISA bridge: Intel Corporation Device a3c8
00:1f.2 Memory controller: Intel Corporation Memory controller
00:1f.3 Audio device: Intel Corporation Device a3f0 #板载声卡 00:1f.3
00:1f.4 SMBus: Intel Corporation Comet Lake PCH-V SMBus Host Controller
01:00.0 VGA compatible controller: NVIDIA Corporation GK208B [GeForce GT 730] (rev a1) #独显 01:00.0
01:00.1 Audio device: NVIDIA Corporation GK208 HDMI/DP Audio Controller (rev a1) #独显声卡 01:00.1
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 05)
05:00.0 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)
05:00.1 Ethernet controller: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 (rev 01)
05:10.0 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:10.2 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:10.4 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:10.6 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:11.0 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:11.2 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:11.4 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:11.6 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:12.0 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:12.2 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:12.4 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
05:12.6 Ethernet controller: Intel Corporation X540 Ethernet Controller Virtual Function (rev 01)
06:00.0 Non-Volatile memory controller: KIOXIA Corporation Device 0008 (rev 01)
使用lspci -n 查看显卡的did和vid
root@home:~# lspci -n
00:00.0 0600: 8086:9b33 (rev 01)
00:01.0 0604: 8086:1901 (rev 01)
00:02.0 0300: 8086:9bc5 (rev 05) #核显 8086:9bc5
00:14.0 0c03: 8086:a3af
00:16.0 0780: 8086:a3ba
00:17.0 0106: 8086:a382
00:1b.0 0604: 8086:a3e9 (rev f0)
00:1c.0 0604: 8086:a392 (rev f0)
00:1c.3 0604: 8086:a393 (rev f0)
00:1c.4 0604: 8086:a394 (rev f0)
00:1d.0 0604: 8086:a398 (rev f0)
00:1f.0 0601: 8086:a3c8
00:1f.2 0580: 8086:a3a1
00:1f.3 0403: 8086:a3f0 #板载声卡 8086:a3f0
00:1f.4 0c05: 8086:a3a3
01:00.0 0300: 10de:1f82 (rev a1) #独显 10de:1f82
01:00.1 0403: 10de:10fa (rev a1) #独显声卡 10de:10fa
04:00.0 0200: 10ec:8125 (rev 05)
05:00.0 0200: 8086:1528 (rev 01)
05:00.1 0200: 8086:1528 (rev 01)
05:10.0 0200: 8086:1515 (rev 01)
05:10.2 0200: 8086:1515 (rev 01)
05:10.4 0200: 8086:1515 (rev 01)
05:10.6 0200: 8086:1515 (rev 01)
05:11.0 0200: 8086:1515 (rev 01)
05:11.2 0200: 8086:1515 (rev 01)
05:11.4 0200: 8086:1515 (rev 01)
05:11.6 0200: 8086:1515 (rev 01)
05:12.0 0200: 8086:1515 (rev 01)
05:12.2 0200: 8086:1515 (rev 01)
05:12.4 0200: 8086:1515 (rev 01)
05:12.6 0200: 8086:1515 (rev 01)
06:00.0 0108: 1e0f:0008 (rev 01)
绑定到vfio-pci
echo "options vfio-pci ids=1e0f:0008,8086:9bc5,8086:a3f0,10de:1f82,10de:10fa disable_vga=1" > /etc/modprobe.d/vfio.conf
#注意,上面这条命令,ids=后面跟直通组的所有设备。中间以英文逗号隔开。如果无法输出到外接显示器,取消disable_vga=1参数试试
echo "options vfio-pci ids=1e0f:0008,8086:9bc5,8086:a3f0,10de:1f82,10de:10fa" > /etc/modprobe.d/vfio.conf7.上述操作完成之后,再检查一下,是否将例子内容替换成自己的。使用以下命令查看。
cat /etc/modprobe.d/pve-blacklist.conf
cat /etc/modprobe.d/vfio.conf刷新更改
update-grub
update-initramfs -k all -u重启
reboot检查是否配置成功
lspci -nnkroot@home:~# lspci -nnk
00:00.0 Host bridge [0600]: Intel Corporation Device [8086:9b33] (rev 01)
DeviceName: Onboard - Other
Subsystem: ASUSTeK Computer Inc. Device [1043:8694]
Kernel driver in use: skl_uncore
00:01.0 PCI bridge [0604]: Intel Corporation 6th-10th Gen Core Processor PCIe Controller (x16) [8086:1901] (rev 01)
Kernel driver in use: pcieport
00:02.0 VGA compatible controller [0300]: Intel Corporation CometLake-S GT2 [UHD Graphics 630] [8086:9bc5] (rev 05)
DeviceName: Onboard - Video
Subsystem: ASUSTeK Computer Inc. Device [1043:8694]
Kernel driver in use: vfio-pci
Kernel modules: i915
如果看到Kernel driver in use: vfio-pci,表示应用成功
8.设置虚拟机conf配置:
编辑 /etc/pve/qemu-server/100.conf 文件,增加一行args
nano /etc/pve/qemu-server/100.conf添加一行
args: -cpu host,kvm=off,hv_time,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff,hv_vendor_id=NV43FIXargs: 一行是用来隐藏虚拟机环境,因为原神等游戏禁止在虚拟机启动。如果是 N 卡,此处 hv_vendor_id=intel 可改成 hv_vendor_id=NV43FIX,如果是 AMD的cpu,hv_vendor_id=amd,作为解决错误代码 43 问题的其中一个步骤 ;如果不行,pci设备高级选项勾选pcie选项。
解决错误代码 43:修改/etc/default/grub ,GRUB_CMDLINE_LINUX_DEFAULT参数增加initcall_blacklist=sysfb_init,用于屏蔽pve内核自动启动的默认显示输出设备simplefb。
确保启用了所有 Hyper-V Enlightenment,包含全套 Hyper-V 参数,推荐
三、安装破解内核,解决iommu分组问题
1.下载破解内核
yfdoor/PVE-Kernel: Compile PVE-Kernel for IOMMU Group (YFDOOR) (github.com)
2.安装内核
将内核放置到pve主机下的一个目录,如我的是/root下面
root@home:~# ls
pve-kernel-5.13.18-1进入新内核文件夹,可以看到有多个deb文件。这些就是破解后的内核文件。
cd pve-kernel-5.13.18-1/
lslinux-tools-5.13_5.13.18-1_amd64.deb pve-headers-5.13.18-1-pve_5.13.18-1_amd64.deb pve-kernel-libc-dev_5.13.18-1_amd64.deb linux-tools-5.13-dbgsym_5.13.18-1_amd64.ddeb pve-kernel-5.13.18-1-pve_5.13.18-1_amd64.deb
使用命令
dpkg -i *.deb开始安装内核。
正常的情况如下,如果不是,请注意!不要继续。
root@pve2:~/PVE-Kernel/pve-kernel-5.13.18-1# dpkg -i *.deb
(Reading database ... 180164 files and directories currently installed.)
Preparing to unpack linux-tools-5.13_5.13.18-1_amd64.deb ...
Unpacking linux-tools-5.13 (5.13.18-1) over (5.13.14-1) ...
Preparing to unpack linux-tools-5.13-dbgsym_5.13.18-1_amd64.ddeb ...
Unpacking linux-tools-5.13-dbgsym (5.13.18-1) over (5.13.14-1) ...
Preparing to unpack pve-headers-5.13.18-1-pve_5.13.18-1_amd64.deb ...
Unpacking pve-headers-5.13.18-1-pve (5.13.18-1) over (5.13.18-1) ...
Selecting previously unselected package pve-kernel-5.13.18-1-pve.
Preparing to unpack pve-kernel-5.13.18-1-pve_5.13.18-1_amd64.deb ...
Unpacking pve-kernel-5.13.18-1-pve (5.13.18-1) ...
Preparing to unpack pve-kernel-libc-dev_5.13.18-1_amd64.deb ...
Unpacking pve-kernel-libc-dev (5.13.18-1) over (5.13.14-1) ...
Setting up linux-tools-5.13 (5.13.18-1) ...
Setting up linux-tools-5.13-dbgsym (5.13.18-1) ...
Setting up pve-headers-5.13.18-1-pve (5.13.18-1) ...
Setting up pve-kernel-5.13.18-1-pve (5.13.18-1) ...
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 5.13.18-1-pve /boot/vmlinuz-5.13.18-1-pve
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 5.13.18-1-pve /boot/vmlinuz-5.13.18-1-pve
update-initramfs: Generating /boot/initrd.img-5.13.18-1-pve
Running hook script 'zz-proxmox-boot'..
Re-executing '/etc/kernel/postinst.d/zz-proxmox-boot' in new private mount namespace..
No /etc/kernel/proxmox-boot-uuids found, skipping ESP sync.
run-parts: executing /etc/kernel/postinst.d/proxmox-auto-removal 5.13.18-1-pve /boot/vmlinuz-5.13.18-1-pve
run-parts: executing /etc/kernel/postinst.d/zz-proxmox-boot 5.13.18-1-pve /boot/vmlinuz-5.13.18-1-pve
Re-executing '/etc/kernel/postinst.d/zz-proxmox-boot' in new private mount namespace..
No /etc/kernel/proxmox-boot-uuids found, skipping ESP sync.
run-parts: executing /etc/kernel/postinst.d/zz-update-grub 5.13.18-1-pve /boot/vmlinuz-5.13.18-1-pve
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.13.18-1-pve
Found initrd image: /boot/initrd.img-5.13.18-1-pve
Found linux image: /boot/vmlinuz-5.11.22-5-pve
Found initrd image: /boot/initrd.img-5.11.22-5-pve
Found linux image: /boot/vmlinuz-5.4.124-1-pve
Found initrd image: /boot/initrd.img-5.4.124-1-pve
Found linux image: /boot/vmlinuz-5.4.106-1-pve
Found initrd image: /boot/initrd.img-5.4.106-1-pve
Found memtest86+ image: /boot/memtest86+.bin
Found memtest86+ multiboot image: /boot/memtest86+_multiboot.bin
Adding boot menu entry for EFI firmware configuration
done
Setting up pve-kernel-libc-dev (5.13.18-1) ...
Processing triggers for man-db (2.9.4-2) ...内核安装完成之后,在grub文件里添加一个参数
pcie_acs_override=downstream内核启动是优先版本最新的,需要手动切换内核启动顺序 方法如下两种:
grep menuentry /boot/grub/grub.cfg 检查启动顺序 看到名为"Advanced options for Proxmox VE GNU/Linux"的二级菜单下有"Proxmox VE GNU/Linux, with Linux 5.13.18-1-pve"的内核
nano /etc/default/grub第一种:修改 GRUB_DEFAULT="1>2" #(数字为启动项顺序)
第二种:直接修改GRUB_DEFAULT=
GRUB_DEFAULT="Advanced options for Proxmox VE GNU/Linux>Proxmox VE GNU/Linux, with Linux 5.13.18-1-pve" 随后进行保存,并且更新内核,更新grub
update-grub
update-initramfs -k all -u 随后重启
reboot3.验证
使用命令验证
for d in /sys/kernel/iommu_groups/*/devices/*; do n=${d#*/iommu_groups/*}; n=${n%%/*}; printf 'IOMMU Group %s ' "$n"; lspci -nns "${d##*/}"; done;我的输出如下
IOMMU Group 0 00:00.0 Host bridge [0600]: Intel Corporation Device [8086:9b33] (rev 01)
IOMMU Group 10 00:1d.0 PCI bridge [0604]: Intel Corporation Device [8086:a398] (rev f0)
IOMMU Group 11 00:1f.0 ISA bridge [0601]: Intel Corporation Device [8086:a3c8]
IOMMU Group 11 00:1f.2 Memory controller [0580]: Intel Corporation Memory controller [8086:a3a1]
IOMMU Group 11 00:1f.3 Audio device [0403]: Intel Corporation Device [8086:a3f0]
IOMMU Group 11 00:1f.4 SMBus [0c05]: Intel Corporation Comet Lake PCH-V SMBus Host Controller [8086:a3a3]
IOMMU Group 12 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK208B [GeForce GT 730] [10de:1287] (rev a1)
IOMMU Group 12 01:00.1 Audio device [0403]: NVIDIA Corporation GK208 HDMI/DP Audio Controller [10de:0e0f] (rev a1)
IOMMU Group 13 04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller [10ec:8125] (rev 05)
IOMMU Group 14 05:00.0 Ethernet controller [0200]: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 [8086:1528] (rev 01)
IOMMU Group 15 05:00.1 Ethernet controller [0200]: Intel Corporation Ethernet Controller 10-Gigabit X540-AT2 [8086:1528] (rev 01)
IOMMU Group 16 06:00.0 Non-Volatile memory controller [0108]: KIOXIA Corporation Device [1e0f:0008] (rev 01)
IOMMU Group 17 05:10.0 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 18 05:10.2 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 19 05:10.4 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 1 00:01.0 PCI bridge [0604]: Intel Corporation 6th-10th Gen Core Processor PCIe Controller (x16) [8086:1901] (rev 01)
IOMMU Group 20 05:10.6 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 21 05:11.0 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 22 05:11.2 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 23 05:11.4 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 24 05:11.6 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 25 05:12.0 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 26 05:12.2 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 27 05:12.4 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 28 05:12.6 Ethernet controller [0200]: Intel Corporation X540 Ethernet Controller Virtual Function [8086:1515] (rev 01)
IOMMU Group 2 00:02.0 VGA compatible controller [0300]: Intel Corporation CometLake-S GT2 [UHD Graphics 630] [8086:9bc5] (rev 05)
IOMMU Group 3 00:14.0 USB controller [0c03]: Intel Corporation Comet Lake PCH-V USB Controller [8086:a3af]
IOMMU Group 4 00:16.0 Communication controller [0780]: Intel Corporation Device [8086:a3ba]
IOMMU Group 5 00:17.0 SATA controller [0106]: Intel Corporation 400 Series Chipset Family SATA AHCI Controller [8086:a382]
IOMMU Group 6 00:1b.0 PCI bridge [0604]: Intel Corporation Device [8086:a3e9] (rev f0)
IOMMU Group 7 00:1c.0 PCI bridge [0604]: Intel Corporation Device [8086:a392] (rev f0)
IOMMU Group 8 00:1c.3 PCI bridge [0604]: Intel Corporation Device [8086:a393] (rev f0)
IOMMU Group 9 00:1c.4 PCI bridge [0604]: Intel Corporation Device [8086:a394] (rev f0)
四、创建win11虚拟机
安装完独显驱动后需手动禁用默认集显,否则不会默认使用独显
五.设置硬盘直通
1.查看硬盘ID
ls -l /dev/disk/by-id2.使用命令设置硬盘直通
qm set VMID -sata1 /dev/disk/by-id/硬盘识别符qm set 100 -sata0 /dev/disk/by-id/nvme-KIOXIA-EXCERIA_PLUS_G2_SSD_21PA22SGK6V3
qm set 100 -sata1 /dev/disk/by-id/ata-WDC_WD10EZEX-08RKKA0_WD-WCC1S68375003.如果直通的物理磁盘已经有分区了,也可以用这个命令挂载
qm set 100 --sata1 /dev/sdb4.显示所有磁盘信息
fdisk -ll如果有多块就sata2、sata3,还不够就ide0、ide1……,但是不要用scsi,系统可能无法直接识别
5.U盘直通,109 虚拟机号 -USB0 第一个usb设备 host...设备号
root@homelab02:~# qm set 109 -usb0 host=13fe:3e006.虚拟磁盘直通挂载
#选中面板左侧菜单pve→Shell输入以下命令:
qm importdisk+空格+虚拟机ID+空格+刚复制的的固件路径+空格+local-lvm
#回车后ssh开始滚动代码,当出现Successfully字样表示转换虚拟磁盘成功。
#例如我的这个虚拟机
qm importdisk 101 /var/lib/vz/template/iso/****.img local-lvm
#这个时候shell跑代码,知道出线下面字样即说明完成
Successfully imported disk as 'unused0:local-lvm:vm-101-disk-0'7.删除直通命令
qm set 101 -delete sata0qm 命令
set 选项
101 虚拟机编号
-delete 删除命令
sata0 要删除的设备名