Skip to content

Instantly share code, notes, and snippets.

@cdseoo
Forked from miooochi/pve-tricks.txt
Created August 25, 2022 13:51
Show Gist options
  • Save cdseoo/7db5c08c9f0889847cc225f6271d13fd to your computer and use it in GitHub Desktop.
Save cdseoo/7db5c08c9f0889847cc225f6271d13fd to your computer and use it in GitHub Desktop.
---
換源 (https://mirrors.ustc.edu.cn/help/proxmox.html)
vim /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/debian bullseye main contrib
deb http://mirrors.ustc.edu.cn/debian bullseye-updates main contrib
# security updates
deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib
# Release
deb https://mirrors.ustc.edu.cn/proxmox/debian/pve bullseye pve-no-subscription
#deb http://ftp.hk.debian.org/debian bullseye main contrib
#deb http://ftp.hk.debian.org/debian bullseye-updates main contrib
#deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription
---
显卡直通
修改Grub:
vim /etc/default/grub
英特尔:
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt pcie_acs_override=downstream,multifunction nofb textonly nomodeset initcall_blacklist=sysfb_init"
AMD:
GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on iommu=pt pcie_acs_override=downstream,multifunction nofb textonly nomodeset initcall_blacklist=sysfb_init"
update-grub
加载模块
vim /etc/modules
添加以下几个模块,直接复制即可。
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
阻止驱动加载(显卡直通时才需要操作
因为pve启动时会尝试加载显卡驱动,为了避免pve占用显卡,需要阻止pve的显卡驱动加载。
vim /etc/modprobe.d/pve-blacklist.conf 
添加以下内容
# block AMD driver
blacklist radeon
blacklist amdgpu
# block NVIDIA driver
blacklist nouveau
blacklist nvidia
blacklist nvidiafb
# block INTEL driver
blacklist snd_hda_intel
blacklist snd_hda_codec_hdmi
blacklist i915
# IOMMU interrupt remapping
echo "options vfio_iommu_type1 allow_unsafe_interrupts=1" > /etc/modprobe.d/iommu_unsafe_interrupts.conf
echo "options kvm ignore_msrs=1" > /etc/modprobe.d/kvm.conf
更新内核
update-initramfs -u
# pve的shell敲lspci -nn 找找你要直通的id
lspci -nn | grep NVIDIA
lspci -nn | grep 5500
03:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 14 [Radeon RX 5500/5500M / Pro 5500M] [1002:7340] (rev c5)
lspci -nn | grep 630
00:02.0 VGA compatible controller [0300]: Intel Corporation CoffeeLake-S GT2 [UHD Graphics 630] [8086:3e98] (rev 02)
# 找到显卡后记下硬件id,形式是xxxx:xxxx,比如G5400的核心显卡的硬件id是8086:3e90。
vim /etc/modprobe.d/vfio.conf
# 添加以下内容注意!!!!把10de:1381换成你的显卡的硬件id
options vfio-pci ids=10de:1381,10de:0fbc disable_vga=1
# 重启机器
reboot
---
安裝pve tools
apt install git -y
export LC_ALL=en_US.UTF-8
git clone https://github.com/ivanhao/pvetools.git
cd pvetools
./pvetools.sh
---
Windows VM Settings
# /etc/pve/qemu-server/<vmid>.conf
args: -cpu 'host,hv_time,kvm=off,hv_vendor_id=null,-hypervisor,rdtscp=off'
cpu: host,hidden=1,flags=+pcid
---
Recent Issues
https://forum.proxmox.com/threads/problem-with-gpu-passthrough.55918/page-2
https://www.reddit.com/r/Proxmox/comments/vc9hw3/latest_proxmox_7_the_kernel_breaks_my_gpu/?sort=old
---
Detailed Guide
https://www.reddit.com/r/homelab/comments/b5xpua/the_ultimate_beginners_guide_to_gpu_passthrough/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment