PVE直通SATA控制器(直通卡等)

发布时间 2023-07-24 11:27:11作者: Rogunt

通过传统的硬盘映射 qm set 方法会损失部分性能,且无法使用硬盘管理等功能。因此采用直通硬盘控制器的方法。

本人按照网上的大多数方法,在添加了pci设备,开机后,pve的根目录会变成只读。
image
推测为直通时把主机的nvme设备等其他控制器一起直通过去了。
我当前要直通的是我的阵列卡,而系统盘等硬盘是直接插在主板上的,按理说不应该出现这种状况,但是却依旧出现了。

解决方法:添加pcie_acs_override=downstream,multifunction在grub文件中

root@pve:~# cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`

GRUB_CMDLINE_LINUX_DEFAULT="quiet video=efifb:off amd_iommu=on iommu=pt pcie_acs_override=downstream,multifunction"

GRUB_CMDLINE_LINUX=""
...

更新grub

update-grub

重启电脑,查看是否启用了iommu设备分组

shopt -s nullglob
for g in $(find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V); do
    echo "IOMMU Group ${g##*/}:"
    for d in $g/devices/*; do
        echo -e "\t$(lspci -nns ${d##*/})"
    done;
done;

此时会输出分组后的pci设备,找到自己要直通的控制器

...
IOMMU Group 14:
        01:00.0 Serial Attached SCSI controller [0107]: Broadcom / LSI SAS2308 PCI-Express Fusion-MPT SAS-2 [1000:0086] (rev 05)
...

我的group是14。
重新添加pci设备到虚拟机
image
image
之后ok就能开机了。

参考:
https://zhuanlan.zhihu.com/p/438793914
https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Ensuring_that_the_groups_are_valid
https://github.com/ivanhao/pvetools/issues/34