Skip to content

Instantly share code, notes, and snippets.

@DevSrSouza
Forked from miooochi/pve-tricks.txt
Created July 7, 2023 12:12
Show Gist options
  • Save DevSrSouza/68e4e2c2d5b0cc8c52e30f8c7d0929b2 to your computer and use it in GitHub Desktop.
Save DevSrSouza/68e4e2c2d5b0cc8c52e30f8c7d0929b2 to your computer and use it in GitHub Desktop.
---
PVE delte local-lvm partition
Reference: https://post.smzdm.com/p/awkv4pq4/
lvremove pve/data
lvextend -l +100%FREE -r pve/root
Datacenter >> remove `local-lvm` partition >> edit `local` >> select all options
---
Change apt source (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
sed -i 's/deb/#&/g' /etc/apt/sources.list.d/pve-enterprise.list
---
GPU Passthrough
# Update Grub:
vim /etc/default/grub
Intel:
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt nomodeset pcie_acs_override=downstream,multifunction nofb textonly initcall_blacklist=sysfb_init"
# video=vesafb:off video=efifb:off video=simplefb:off --> turn off framebuffer to prevent GPU from being accessed.
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
# Local modules
vim /etc/modules
# add the following modules
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
# Prohibit driver load (GPU Passthrough ONLY)
# When PVE boots, it will attempt to load GPU driver, so we need to prohibit it from being loaded.
vim /etc/modprobe.d/pve-blacklist.conf 
# add the following lines
# 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
# ignored RDMSR warning (Nvidia GPU ONLY)
echo "options kvm ignore_msrs=1 report_ignored_msrs=0" > /etc/modprobe.d/kvm.conf
# pve shell >> `lspci -nn` >> locate the hardware 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)
# format should be `xxxx:xxxx` e.g. G5400 iGPU hardward ID is 8086:3e90。
vim /etc/modprobe.d/vfio.conf
# add the following contents, update `10de:1381` to your GPU hardware id
options vfio-pci ids=10de:1381,10de:0fbc disable_vga=1
# Update kernel
update-initramfs -u
# reboot the machine
reboot
---
Install 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
References: https://www.reddit.com/r/homelab/comments/b5xpua/the_ultimate_beginners_guide_to_gpu_passthrough/
# /etc/pve/qemu-server/<vmid>.conf
cpu: host,hidden=1,flags=+pcid
args: -cpu 'host,+kvm_pv_unhalt,+kvm_pv_eoi,,kvm=off,hv_time,kvm=off,-hypervisor,rdtscp=off,hv_vendor_id=NV43FIX'
---
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/
---
How to convert OVA image to QCOW2 format on Linux
Reference: https://dannyda.com/2020/06/25/how-to-use-qemu-img-command-to-convert-between-vmdk-raw-qcow2-vdi-vhd-vhdx-formats-disk-images-qemu-img-create-snapshot-resize-etc/
# To convert VDI image to QCOW2 format
qemu-img convert -O qcow2 input.vdi output.qcow2
To convert VMDK image to QCOW2 format
qemu-img convert -O qcow2 input.vmdk output.qcow2
---
Import QCOW disk to VM
qm importdisk <vmid> <source> <storage> [OPTIONS]
# e.g.
# qm importdisk 102 ./EVE-COM-5-0.vmdk local-zfs -format raw
---
Upgrade Kernel
Reference: https://github.com/xiangfeidexiaohuo/ProxmoxVE-7.0-DIY
# stable
apt search pve-kernel
apt install pve-kernel-5.19.7-2-pve
# edge
curl -1sLf 'https://dl.cloudsmith.io/public/pve-edge/kernel/gpg.8EC01CCF309B98E7.key' | gpg --dearmor -o /usr/share/keyrings/pve-edge-kernel.gpg
echo "deb [signed-by=/usr/share/keyrings/pve-edge-kernel.gpg] https://dl.cloudsmith.io/public/pve-edge/kernel/deb/debian bullseye main" > /etc/apt/sources.list.d/pve-edge-kernel.list
apt update
apt install pve-kernel-6.0-edge
# update kernel with custom args
update-initramfs -u
# rollback
proxmox-boot-tool kernel pin <kernel version before the upgrade>
# e.g.
# proxmox-boot-tool kernel pin 5.15.64-1-pve
proxmox-boot-tool refresh
---
Remove deprecated kernels
Reference: https://github.com/jordanhillis/pvekclean
```bash
git clone https://github.com/jordanhillis/pvekclean && cd pvekclean
chmod +x pvekclean.sh
./pvekclean.sh
apt autoremove —purge -y
```
---
zfs storage
# create a new zfs.conf file
vim /etc/modprobe.d/zfs.conf
# Setting up ZFS ARC size on Proxmox host as per your needs
# Set Max ARC size => 2GB == 2147483648 Bytes
options zfs zfs_arc_max=2147483648
# Set Min ARC size => 1GB == 1073741824 Bytes
options zfs zfs_arc_min=1073741824
# update an existing initramfs for Linux kernel
update-initramfs -u
---
Intel integrated gpu passthrough (Inside the VM)
# upgrade kernel > 5.15.x
# https://github.com/pimlie/ubuntu-mainline-kernel.sh
# inspect guc|huc status
dmesg | grep -iE "guc|huc"
# enable guc|huc
# /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="i915.enable_guc=3 quiet"
update-grub
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment