quickpassthrough/lib/set_MODULES.sh
HikariKnight ee3e886a3a
Change modules to no longer be hardcoded for the graphic card.
Let the users control that instead with their bootloader
2022-03-09 15:03:40 +01:00

75 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
function set_MODULES () {
# Get the config paths
source "$SCRIPTDIR/lib/paths.sh"
# Write "/etc/modules"
printf "
# Generated by vfio-setup
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
" >> "$SCRIPTDIR/$MODULES"
# Write "/etc/initramfs-tools/modules"
printf "
# Generated by vfio-setup
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
" >> "$SCRIPTDIR/$INITRAMFS/modules"
# Assign the GPU device ids to a variable
GPU_DEVID="$1"
# Get the kernel_args file content
CMDLINE=$(cat "$SCRIPTDIR/config/kernel_args")
# Ask if we shall disable video output on this card
read -p "Do you want to force disable video output in linux on this card? [Y/n]: " DISABLE_VGA
case "${DISABLE_VGA}" in
[Yy]*)
GPU_DEVID="${GPU_DEVID} disable_vga=1"
# Update kernel_args file
echo "${CMDLINE} vfio_pci.ids=${GPU_DEVID} vfio_pci.disable_vga=1" > "$SCRIPTDIR/config/kernel_args"
;;
[Nn]*)
echo ""
;;
*)
GPU_DEVID="${GPU_DEVID} disable_vga=1"
# Update kernel_args file
echo "${CMDLINE} vfio_pci.ids=${GPU_DEVID} vfio_pci.disable_vga=1" > "$SCRIPTDIR/config/kernel_args"
;;
esac
# Write the vfio modprobe config
printf "# This is an autogenerated file that stubs your graphic card for use with vfio
## This file should be placed inside /etc/modprobe.d/
# Uncomment the line below to \"hardcode\" your graphic card to be bound to the vfio-pci driver.
# In most cases this should not be neccessary, it will also prevent you from turning off vfio in the bootloader.
#options vfio_pci ids=%s
# Make sure vfio_pci is loaded before these modules: nvidia, nouveau, amdgpu and radeon
softdep nvidia pre: vfio vfio_pci
softdep nouveau pre: vfio vfio_pci
softdep amdgpu pre: vfio vfio_pci
softdep radeon pre: vfio vfio_pci
" "${GPU_DEVID}" > "$SCRIPTDIR/$MODPROBE/vfio.conf"
exec "$SCRIPTDIR/lib/get_USB_CTL.sh"
}
function main () {
SCRIPTDIR=$(dirname "$(which $0)" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
set_MODULES "$1"
}
main "$1"