quickpassthrough/lib/set_MODULES.sh
2022-03-01 09:02:29 +01:00

64 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
function set_MODULES () {
# Get the config paths
source "$SCRIPTDIR/lib/paths.sh"
# Write "/etc/modules"
printf "vfio
vfio_iommu_type1
vfio_pci ids=$1
vfio_virqfd
" >> "$SCRIPTDIR/$MODULES"
# Write "/etc/initramfs-tools/modules"
printf "vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
" >> "$SCRIPTDIR/$INITRAMFS/modules"
# Assign the GPU device ids to a variable
GPU_DEVID="$1"
# Update the kernel_args file
CMDLINE=$(cat "$SCRIPTDIR/config/kernel_args")
echo "$CMDLINE vfio_pci.ids=$GPU_DEVID" > "$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"
;;
[Nn]*)
echo ""
;;
*)
GPU_DEVID="$GPU_DEVID disable_vga=1"
;;
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/
options vfio_pci ids=$GPU_DEVID
# 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
" > "$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