[Script/Service] - Passthrough Helper

Ramalama

Well-Known Member
Dec 26, 2020
851
197
53
35
Hi, i've camed in another thread to the Problem, that there is no easy way to bind vfio-pci to a bus device.
This is neccessary if you can't do it with vendor:device id, because you have multiple devices and you need them on your host too.
For example, if you want to passthrough one of four nic ports or you have 2 identical graphic cards, or sr-iov that you use on the host and you want to passthrough too.

Okay, you need 3 things:
1. /etc/systemd/system/vfio-helper.service
Code:
[Unit]
Description=Script to bind Devices on boot
Before=pve-guests.service

[Service]
Type=oneshot
EnvironmentFile=-/etc/vfio-helper.conf
ExecStart=/usr/bin/vfio-pci-bind.sh $BIND_DEVICES

[Install]
WantedBy=multi-user.target

2. /etc/vfio-helper.conf
Code:
# Modify first and uncomment the line below!
# The line below is just an example, you can bind devices based on BUS or vendor:devid
# You can add as many devices you want, space separated.
# Below are 2 lines as example, if you want to bind one or multiple devices!
#BIND_DEVICES="0000:23:00.0"
#BIND_DEVICES="0000:23:00.1 0000:06:00.0 10de:1b06 10de:10ef"

3. /usr/bin/vfio-pci-bind.sh
Code:
wget https://raw.githubusercontent.com/andre-richter/vfio-pci-bind/master/vfio-pci-bind.sh
mv vfio-pci-bind.sh /usr/bin/
chmod +x /usr/bin/vfio-pci-bind.sh

Credits goes to this guy: https://github.com/andre-richter/vfio-pci-bind

That script works without the need of a reboot, the service is just to not run it everytime if you reboot the host.
To confirm that it worked for example with 0000:23:00.1, you can simply check with:
lspci -vvs 0000:23:00.1 | grep driver
-> Kernel driver in use: vfio-pci
if there isn't vfio-pci, well it didn't worked xD


Just wanted to share, whoever needs this, here you go.

Cheers
 
Last edited:
This has been hugely helpful to me. Is this setup expected to re-map all the PCIE drivers at boot? I am finding that I need to re-run the remap script every time I boot. I have a hookscript built on my opnsense VM to run it right before Opnsense boots. It has worked so far, though I'd love to find a way to make the mappings permanent, or at least re-map after reboot.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!