From d0d972cf9fe82d108731b0f147771c5d3c2a6cd7 Mon Sep 17 00:00:00 2001 From: HikariKnight <2557889+HikariKnight@users.noreply.github.com> Date: Sat, 12 Mar 2022 15:40:56 +0100 Subject: [PATCH] Script to configure dracut modules --- lib/set_DRACUT.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 lib/set_DRACUT.sh diff --git a/lib/set_DRACUT.sh b/lib/set_DRACUT.sh new file mode 100755 index 0000000..76b6b8c --- /dev/null +++ b/lib/set_DRACUT.sh @@ -0,0 +1,30 @@ +#!/bin/bash +function set_DRACUT () { + # Get the config paths + source "$SCRIPTDIR/lib/paths.sh" + + # Write the dracut config + echo "add_drivers+=\" vfio_pci vfio vfio_iommu_type1 vfio_virqfd \"" > "$SCRIPTDIR/$DRACUT" + + # Get the kernel_args file content + CMDLINE=$(cat "$SCRIPTDIR/config/kernel_args") + + # Update kernel_args to load the vfio_pci module early in dracut (as dracut uses kernel arguments for early loading) + echo "$CMDLINE rd.driver.pre=vfio_pci" > "$SCRIPTDIR/config/kernel_args" + + # Bind GPU to VFIO + "$SCRIPTDIR/lib/set_VFIO.sh" "$1" + + # Configure modprobe + "$SCRIPTDIR/lib/set_MODPROBE.sh" "$1" + + exec "$SCRIPTDIR/lib/get_USB_CTL.sh" +} + +function main () { + SCRIPTDIR=$(dirname "$(realpath "$0")" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//") + + set_DRACUT "$1" +} + +main "$1" \ No newline at end of file