Skip to content

Instantly share code, notes, and snippets.

@hyperparabolic
Created September 25, 2018 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyperparabolic/ecdf900f4a32139fb3967436464f50c7 to your computer and use it in GitHub Desktop.
Save hyperparabolic/ecdf900f4a32139fb3967436464f50c7 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This is a script for binding vfio-pci drivers to
# video cards when there are multiple copies of the
# same card and ids cannot be used.
# install this to /sbin, and add this to modprobe.d:
# install vfio-pci /sbin/vfio-pci-override.sh
for i in /sys/devices/pci*/*/*/boot_vga; do
if [ $(cat "$i") -eq 0 ]; then
GPU="${i%/boot_vga}"
AUDIO="$(echo "$GPU" | sed -e "s/0$/1/")"
echo "vfio-pci" > "$GPU/driver_override"
if [ -d "$AUDIO" ]; then
echo "vfio-pci" > "$AUDIO/driver_override"
fi
fi
done
modprobe -i vfio-pci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment