add directory paths into a config file
This commit is contained in:
parent
3b6f09ab59
commit
6b773a22e2
4 changed files with 74 additions and 16 deletions
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
function get_GROUP () {
|
function get_GROUP () {
|
||||||
clear
|
clear
|
||||||
|
# Get the config paths
|
||||||
|
source "$SCRIPTDIR/lib/paths.sh"
|
||||||
|
|
||||||
printf "
|
printf "
|
||||||
For this card to be passthrough-able, it must contain only:
|
For this card to be passthrough-able, it must contain only:
|
||||||
* The GPU/Graphic card
|
* The GPU/Graphic card
|
||||||
|
@ -27,18 +30,18 @@ read -p "Enter the ids for all devices you want to passthrough: " GPU_DEVID
|
||||||
|
|
||||||
if [[ $GPU_DEVID =~ : ]];
|
if [[ $GPU_DEVID =~ : ]];
|
||||||
then
|
then
|
||||||
# Make the directory
|
|
||||||
mkdir "$SCRIPTDIR/config"
|
|
||||||
|
|
||||||
# Get the PCI ids
|
# Get the PCI ids
|
||||||
PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4 | perl -pe "s/\n/ /" | perl -pe "s/\s$//")
|
local PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4 | perl -pe "s/\n/ /" | perl -pe "s/\s$//")
|
||||||
|
|
||||||
echo "# This is an autogenerated file that stubs your graphic card for use with vfio" > "$SCRIPTDIR/config/vfio.conf"
|
|
||||||
echo "options vfio_pci ids=$GPU_DEVID" >> "$SCRIPTDIR/config/vfio.conf"
|
|
||||||
echo "GPU_PCI_ID=($PCI_ID)" > "$SCRIPTDIR/config/qemu-vfio_vars.conf"
|
|
||||||
echo "USB_CTL_ID=\"\"" >> "$SCRIPTDIR/config/qemu-vfio_vars.conf"
|
|
||||||
|
|
||||||
exec "$SCRIPTDIR/lib/get_USB_CTL.sh"
|
# Write the currently unused vfio config for quickemu
|
||||||
|
printf "GPU_PCI_ID=($PCI_ID)
|
||||||
|
USB_CTL_ID=\"\"" > "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
|
||||||
|
|
||||||
|
# Get the PCI_ID
|
||||||
|
local ROM_PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "vga" | grep -i "group $1" | cut -d " " -f 4)
|
||||||
|
"$SCRIPTDIR/lib/get_GPU_ROM.sh" "$ROM_PCI_ID"
|
||||||
|
|
||||||
|
exec "$SCRIPTDIR/lib/set_MODULES.sh" $GPU_DEVID
|
||||||
else
|
else
|
||||||
exec "$SCRIPTDIR/lib/get_GPU.sh"
|
exec "$SCRIPTDIR/lib/get_GPU.sh"
|
||||||
fi
|
fi
|
||||||
|
@ -46,8 +49,9 @@ fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function main () {
|
function main () {
|
||||||
SCRIPTDIR=$(dirname `which $0`)
|
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//")
|
||||||
SCRIPTDIR="$SCRIPTDIR/.."
|
SCRIPTDIR="$SCRIPTDIR/.."
|
||||||
|
|
||||||
get_GROUP $1
|
get_GROUP $1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
function get_USB_CTL_GROUP () {
|
function get_USB_CTL_GROUP () {
|
||||||
clear
|
clear
|
||||||
|
# Get the config paths
|
||||||
|
source "$SCRIPTDIR/lib/paths.sh"
|
||||||
|
|
||||||
printf "
|
printf "
|
||||||
For this USB controller device to be passthrough-able, it must be the ONLY device in this group!
|
For this USB controller device to be passthrough-able, it must be the ONLY device in this group!
|
||||||
|
|
||||||
|
@ -23,7 +26,7 @@ then
|
||||||
# Get the PCI ids
|
# Get the PCI ids
|
||||||
PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4)
|
PCI_ID=$($SCRIPTDIR/utils/ls-iommu | grep -i "group $1" | cut -d " " -f 4)
|
||||||
|
|
||||||
exec perl -pi -e "s/USB_CTL_ID=\"\"/USB_CTL_ID=\"$PCI_ID\"/" "$SCRIPTDIR/config/qemu-vfio_vars.conf"
|
exec perl -pi -e "s/USB_CTL_ID=\"\"/USB_CTL_ID=\"$PCI_ID\"/" "$SCRIPTDIR/$QUICKEMU/qemu-vfio_vars.conf"
|
||||||
else
|
else
|
||||||
exec "$SCRIPTDIR/lib/get_USB_CTL.sh"
|
exec "$SCRIPTDIR/lib/get_USB_CTL.sh"
|
||||||
fi
|
fi
|
||||||
|
@ -31,8 +34,9 @@ fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function main () {
|
function main () {
|
||||||
SCRIPTDIR=$(dirname `which $0`)
|
SCRIPTDIR=$(dirname `which $0` | perl -pe "s/\/\.\.\/lib//")
|
||||||
SCRIPTDIR="$SCRIPTDIR/.."
|
SCRIPTDIR="$SCRIPTDIR/.."
|
||||||
|
|
||||||
get_USB_CTL_GROUP $1
|
get_USB_CTL_GROUP $1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
lib/paths.sh
Normal file
6
lib/paths.sh
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
MODPROBE="config/etc/modprobe.d"
|
||||||
|
INITRAMFS="config/etc/initramfs-tools"
|
||||||
|
MODULES="config/etc/modules"
|
||||||
|
DEFAULT="config/etc/default"
|
||||||
|
QUICKEMU="config/quickemu"
|
50
vfio-setup
50
vfio-setup
|
@ -4,6 +4,9 @@
|
||||||
SCRIPTDIR=$(dirname `which $0`)
|
SCRIPTDIR=$(dirname `which $0`)
|
||||||
cd $SCRIPTDIR
|
cd $SCRIPTDIR
|
||||||
|
|
||||||
|
# Get the config paths
|
||||||
|
source "$SCRIPTDIR/lib/paths.sh"
|
||||||
|
|
||||||
# Clear the screen
|
# Clear the screen
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
@ -22,6 +25,8 @@ clear
|
||||||
|
|
||||||
printf "This script assumes a few things:
|
printf "This script assumes a few things:
|
||||||
* You have already enabled IOMMU, VT-d and/or AMD-v inside your UEFI/BIOS advanced settings.
|
* You have already enabled IOMMU, VT-d and/or AMD-v inside your UEFI/BIOS advanced settings.
|
||||||
|
* You have already added \"iommu=pt intel_iommu=on\" or \"iommu=pt amd_iommu=on\" to your
|
||||||
|
kernel boot arguments and booted your system with these kernel arguments active.
|
||||||
* You are comfortable with navigating and changing settings in your UEFI/BIOS.
|
* You are comfortable with navigating and changing settings in your UEFI/BIOS.
|
||||||
* You know how edit your bootloader configuration.
|
* You know how edit your bootloader configuration.
|
||||||
* Your Linux distribution is an EFI installation (important to get VFIO working).
|
* Your Linux distribution is an EFI installation (important to get VFIO working).
|
||||||
|
@ -32,18 +37,57 @@ NOTE: If your computer no longer fully shut down after enabling IOMMU, then ther
|
||||||
quirk with IOMMU on some boards.
|
quirk with IOMMU on some boards.
|
||||||
|
|
||||||
This is a list of prerequisites you will be needing before starting with VFIO:
|
This is a list of prerequisites you will be needing before starting with VFIO:
|
||||||
* 2 GPUs (iGPU/APU included)
|
* 2 very different GPUs (iGPU/APU included), the easiest combination is to have 2 from different vendors (amd/intel/nvidia)
|
||||||
|
if both cards share the same device id (ex: both are identified as 1022:145c), then passthrough will most likely
|
||||||
|
not be possible unless you swap out one of the cards.
|
||||||
* A \"ghost display\" dummy plug for your second graphic card (or having it hooked to a separate input on your monitor).
|
* A \"ghost display\" dummy plug for your second graphic card (or having it hooked to a separate input on your monitor).
|
||||||
* If you are planning to use the inegrated GPU on your CPU, make sure your monitor is connected to it before continuing.
|
* If you are planning to use the inegrated GPU on your CPU, make sure your monitor is connected to it before continuing.
|
||||||
* Preferably a motherboard verified to work with IOMMU and with good IOMMU groups.
|
* Preferably a motherboard verified to work with IOMMU and with good IOMMU groups.
|
||||||
https://reddit.com/r/vfio is a good resource for this info.
|
https://reddit.com/r/vfio is a good resource for this info.
|
||||||
(If you are unsure, you will find out while using this script)
|
(If you are unsure, you will find out while using this script)
|
||||||
|
|
||||||
Press ENTER to start creating your config.
|
Press ENTER to start creating your config from scratch.
|
||||||
|
NOTE: continuing will delete the contents of \"$SCRIPTDIR/config\"
|
||||||
"
|
"
|
||||||
read ENTER
|
read ENTER
|
||||||
clear
|
clear
|
||||||
|
|
||||||
|
if [ -d "$SCRIPTDIR/config" ];
|
||||||
|
then
|
||||||
|
rm -r "$SCRIPTDIR/config"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make the directories
|
||||||
|
mkdir -p "$SCRIPTDIR/$MODPROBE"
|
||||||
|
mkdir -p "$SCRIPTDIR/$DEFAULT"
|
||||||
|
mkdir -p "$SCRIPTDIR/$INITRAMFS"
|
||||||
|
mkdir -p "$SCRIPTDIR/$QUICKEMU"
|
||||||
|
|
||||||
|
# Copy system configs into our config folder so we can safely edit them
|
||||||
|
|
||||||
|
if [ -f "/etc/modules" ];
|
||||||
|
then
|
||||||
|
# This copies /etc/modules without the vfio module lines
|
||||||
|
grep -v "vfio" "/etc/modules" > "$SCRIPTDIR/$MODULES"
|
||||||
|
else
|
||||||
|
touch "$SCRIPTDIR/$MODULES"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "/etc/default/grub" ];
|
||||||
|
then
|
||||||
|
# Currently we do not modify bootloaders, will ask users to do it instead
|
||||||
|
#cp "/etc/default/grub" "$SCRIPTDIR/$DEFAULT/grub"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "/etc/initramfs-tools/modules" ];
|
||||||
|
then
|
||||||
|
# This copies /etc/initramfs-tools/modules without the vfio modules
|
||||||
|
grep -v "vfio" "/etc/initramfs-tools/modules" > "$SCRIPTDIR/$INITRAMFS"
|
||||||
|
else
|
||||||
|
touch "$SCRIPTDIR/$INITRAMFS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run ls-iommu so we can verify that IOMMU properly working
|
||||||
"$SCRIPTDIR/utils/ls-iommu"
|
"$SCRIPTDIR/utils/ls-iommu"
|
||||||
|
|
||||||
printf "
|
printf "
|
||||||
|
@ -63,4 +107,4 @@ case "${YESNO}" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
"$SCRIPTDIR/lib/get_GPU.sh"
|
exec "$SCRIPTDIR/lib/get_GPU.sh"
|
Loading…
Add table
Add a link
Reference in a new issue