You are not logged in.
I honestly don't know if this should be here, or in a more advanced segment, but I will start from here and move it or retype it if the need arises.
the scenario is as Convoluted as it sound. I have my arch system running and performing to mild success. however, this was the result of various Frankensteining of different features to temporarily fix or deal with an issue which have to be eventually properly fixed for the system to survive long term.
The first issue is Games GPU switching.
Originally, what I planned to do was to use something like Optimus Manager or Prime to have a semi? dynamic GPU allocation system which would allow my main system to use my Intel Internal GPU, and let my more demanding applications and Games that I run either through lutris / steam / wine (or what have you) call on the NVIDIA GPU to function. sadly, despite trying to follow the guide on the wiki, and trying numerous times, it failed which led me to eventually just have the NVIDIA GPU do everything and pass it through my Intel Internal GPU. I can clearly see this when I check my NVIDIA SMI:
________________________________________________________________________________________________________________________________________________________________________________________
Update: Last time I checked, NVIDIA was doing everything regarding basic system rendering, but When I'm trying to call it right now, it is only running a very resource non intensive
0 N/A N/A 1089 G /usr/bin/kwin_wayland 1MiB
If I can cause it to become the main GPU again, I will type it in the following messages in this topic, but until than, ignore that problem.
________________________________________________________________________________________________________________________________________________________________________________________
The actual problem right now, is that I want to make a small system to use Virtualization with GPU pass through using KVM/QEMU. However, I thought it would be great if Instead of cutting off the NVIDIA GPU from Grub at boot, I could instead have my system run normally; then, when we need to turn on and use a virtual machine, we would run a script that handled the clean detachment of the external GPU and allocate it to VFIO, and than have another script which would rebind it to the host system.
My research regarding non GRUB based GPU breakthroughs and Script breakthroughs was not high, so I tried to use AI to at least get an idea on what to do, Originally, it managed to hand me a decent script which Could--when I booted the system with IOMMU bindings from bios with my Dedicated GPU bound to VFIO-- return the system to normal, and give me my second monitor. However, when I deleted the IOMMU lines from my BIOS and tried to use a script to switch GPU to VFIO, it kept getting progressively more obtuse and incomprehensible.
Currently the script I have is something like this:
```
#!/bin/bash
echo "Switching GPU to VFIO mode..."
# Check current display setup
echo "Current GPU usage:"
nvidia-smi --query-gpu=name,display_active --format=csv,noheader,nounits
# Stop display manager and switch to multi-user target
sudo systemctl stop sddm
sudo systemctl isolate multi-user.target
# Kill all processes using the GPU
sudo pkill -f kwin_wayland 2>/dev/null || true
sudo pkill -f plasmashell 2>/dev/null || true
sudo pkill -f Xorg 2>/dev/null || true
sudo fuser -k /dev/nvidia* 2>/dev/null || true
sleep 3
# Create environment variable to force Intel graphics
sudo mkdir -p /etc/environment.d
sudo tee /etc/environment.d/50-intel-graphics.conf > /dev/null << EOF
__GLX_VENDOR_LIBRARY_NAME=mesa
DRI_PRIME=0
EOF
# Create Wayland session config to use Intel
sudo mkdir -p /etc/sddm.conf.d
sudo tee /etc/sddm.conf.d/intel-graphics.conf > /dev/null << EOF
[General]
DisplayServer=wayland
GreeterEnvironment=QT_QPA_PLATFORM=wayland,__GLX_VENDOR_LIBRARY_NAME=mesa,DRI_PRIME=0
[Wayland]
SessionCommand=/usr/bin/startplasma-wayland
EOF
# Unload NVIDIA modules
sudo modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
# Load VFIO modules
sudo modprobe vfio-pci
# Unbind GPU from nvidia driver
echo "0000:01:00.0" | sudo tee /sys/bus/pci/devices/0000:01:00.0/driver/unbind 2>/dev/null || true
echo "0000:01:00.1" | sudo tee /sys/bus/pci/devices/0000:01:00.1/driver/unbind 2>/dev/null || true
# Bind GPU to vfio-pci
echo "10de 1f99" | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id
echo "10de 10fa" | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id
# Restart display manager
sudo systemctl start sddm
echo "GPU bound to VFIO - ready for VM"
echo "System should now be using Intel graphics"
```
I have started researching a bit on how to Actually do a GPU passthrough via scripts or other methods from a few searching in the thread, but I did want to know if all this effort is going anywhere or not?
my specs are
OS: Arch Linux x86_64
Kernel: Linux 6.15.6-arch1-1
Packages: 1224 (pacman)
Shell: bash 5.3.0
Display (SME2020): 1600x900 @ 60 Hz in 20" [External]
Display (CMN1521): 1920x1080 @ 144 Hz in 16" [Built-in] *
DE: KDE Plasma 6.4.2
WM: KWin (Wayland)
Terminal: konsole 25.4.3
CPU: Intel(R) Core(TM) i7-10870H (16) @ 5.00 GHz
GPU 1: NVIDIA GeForce GTX 1650 Mobile / Max-Q [Discrete]
GPU 2: Intel UHD Graphics @ 1.15 GHz [Integrated]
If anyone has questions on my setup, I will paste them all beneath this topic, but I really want to know if I just cut my losses and figure out a Boot Based GRUB VFIO binding, or if it is pheasable to make a script base system
UPDATE: if you are curious as to why i dont use the IOMMU bios passthrough, its because i have a dual monitor setup and my laptop will only load my internal GPU if I dedicate my dedicated GPU to IOMMU, this means that in that setup, unless i have a GPU passthrough also working to make my Internal GPU send images through the Dedicated to my second monitor, I wouldnt have my second monitor accessible to me most of the time? at least that is what I took from it
Last edited by Mylzerie (2025-07-13 14:36:33)
Offline