跳转至

Proxmox

启用 IOMMU:

更改 Grub 选项:

/etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet split_lock_detect=off intel_iommu=on pcie_aspm=off pcie_acs_override=downstream,multifunction iommu=pt vfio_iommu
更新 grub 配置并重启:
update-grub #更新
新增所需模块

/etc/modules
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
更新 initramfs 并重启

update-initramfs -u -k all
reboot

直通 N 卡

# 查看显卡id:
╭─root@pve /mnt/pve/XFS_POOL/images/4100
╰─# lspci -nn | grep NVIDIA
lspci -nnk -s 01:00
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107GL [Quadro 410] [10de:0fff] (rev a1)
01:00.1 Audio device [0403]: NVIDIA Corporation GK107 HDMI Audio Controller [10de:0e1b] (rev a1)
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107GL [Quadro 410] [10de:0fff] (rev a1)
        Subsystem: NVIDIA Corporation Device [10de:094a]
        Kernel driver in use: nouveau
        Kernel modules: nvidiafb, nouveau
01:00.1 Audio device [0403]: NVIDIA Corporation GK107 HDMI Audio Controller [10de:0e1b] (rev a1)
        Subsystem: NVIDIA Corporation Device [10de:094a]
        Kernel driver in use: snd_hda_intel
        Kernel modules: snd_hda_intel
#配置VFIO
╭─root@pve /mnt/pve/XFS_POOL/images/4100
╰─# echo "options vfio-pci ids=10de:0fff,10de:0e1b" > /etc/modprobe.d/vfio.conf

#在proxmox主机屏蔽掉显卡的驱动:
╭─root@pve /mnt/pve/XFS_POOL/images/4100
╰─#echo "# NVIDIA" >> /etc/modprobe.d/blacklist.conf 
echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf 
echo "blacklist nvidia" >> /etc/modprobe.d/blacklist.conf 
echo "blacklist nvidiafb" >> /etc/modprobe.d/blacklist.conf
echo "blacklist nvidia_drm" >> /etc/modprobe.d/blacklist.conf
echo "" >> /etc/modprobe.d/blacklist.conf

#允许不安全的中断 
╭─root@pve /mnt/pve/XFS_POOL/images/4100
╰─# echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf

#为 NVIDIA 卡添加稳定性修复和优化 
╭─root@pve /mnt/pve/XFS_POOL/images/4100
╰─# echo "options kvm ignore_msrs=1 report_ignored_msrs=0" > /etc/modprobe.d/kvm.conf

#改完看一下是否配置成功
╭─root@pve /mnt/pve/XFS_POOL/images/4100
╰─# cat /etc/modprobe.d/blacklist.conf

# NVIDIA
blacklist nouveau
blacklist nvidia
blacklist nvidiafb
blacklist nvidia_drm

╭─root@pve /mnt/pve/XFS_POOL/images/4100
╰─# cat /etc/modprobe.d/vfio.conf

options vfio-pci ids=10de:0fff,10de:0e1b
╭─root@pve /mnt/pve/XFS_POOL/images/4100
╰─#

更新 initramfs 并重启

update-initramfs -u -k all
reboot

UPS 配置

╭─root@pve ~
╰─# apt install -y nut
╭─root@pve ~
╰─# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 003: ID 090c:1000 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.) Flash Drive
Bus 001 Device 004: ID 0cf2:7750 ENE Technology, Inc. 6K7750
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
╭─root@pve ~
╰─# nut-scanner -U

Cannot load SNMP library (libnetsnmp.so.40) : file not found. SNMP search disabled.
Cannot load XML library (libneon.so.27) : file not found. XML search disabled.
Cannot load IPMI library (libfreeipmi.so.17) : file not found. IPMI search disabled.
Scanning USB bus.
[nutdev1]
        driver = "usbhid-ups"
        port = "auto"
        vendorid = "051D"
        productid = "0002"
        product = "Back-UPS BK650M2-CH FW:294803G -292804G"
        serial = "9B2227A23138"
        vendor = "American Power Conversion"
        bus = "001"
        device = "002"
        busport = "005"
        ###NOTMATCHED-YET###bcdDevice = "0106"

额外挂载物理硬盘

以设备/dev/nvme0n1p1使用 xfs文件系统 为例:

╭─root@pve /mnt/pve
╰─# mkfs.xfs -L "XFS_POOL" /dev/nvme0n1p1

meta-data=/dev/nvme0n1p1         isize=512    agcount=8, agsize=61047296 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=1
         =                       reflink=1    bigtime=1 inobtcount=1 nrext64=1
         =                       exchange=0   metadir=0
data     =                       bsize=4096   blocks=488378368, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1, parent=0
log      =internal log           bsize=4096   blocks=238466, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
         =                       rgcount=0    rgsize=0 extents
Discarding blocks...Done.
╭─root@pve /mnt/pve
╰─# mkdir -p /mnt/pve/XFS_POOL
╭─root@pve /mnt/pve
╰─# mount /dev/nvme0n1p1 /mnt/pve/XFS_POOL
╭─root@pve /mnt/pve
╰─# vi /etc/fstab
╭─root@pve /mnt/pve
╰─# cat /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/pve/root / ext4 errors=remount-ro 0 1
UUID=A782-C48A /boot/efi vfat defaults 0 1
/dev/pve/swap none swap sw 0 0
proc /proc proc defaults 0 0

/dev/nvme0n1p1 /mnt/pve/XFS_POOL xfs defaults,nofail 0 0

╭─root@pve /mnt/pve
╰─# systemctl daemon-reload