PCI passthrough via PCI bus address when drive is encrypted

I’ve ended up running into a unique situation with GPU passthrough that I thought I would share and get input on improving what I did as it works but not sure if it’s the best way to do it. This is kind of lengthy as it’s how I came to the current solution and includes what I tried and failed.

Background

I’ve been running GPU passthrough for many years now and I’ve always used the device ID method and after a few GPU changes going from a 1080ti to a 9070 XT for the virtual machine and now from a 7600 to a 9070 for my Linux host machine, I needed to switch to using PCI bus address since the 9070 XT and 9070 share the same device ID. Upgrading the Linux host to an 9070 was needed due to an EAC update early this year that flags virtual machines and caused games not to lunch any more, so to be able to play games again that I already bought before this EAC update, Linux needed an upgraded GPU to play them well enough for my liking through wine/proton.

System as of 04/10/2026:
Ubuntu 26.04.1 LTS
Linux 7.0.0-38-generic
AMD Ryzen 7 5800X
64GB RAM
AMD Radeon RX 9070 (Linux host)
AMD Radeon RX 9070 XT (Windows virtual machine)
ROG Strix X570-F Gaming

The journey to getting it working

Since I had a working passthrough setup and just needed to change to using PCI bus address, I started looking through the arch wiki and mainly this part of the wiki

From here you get this script for the use case I wanted and then modify it for my own bus address

/usr/local/bin/vfio-pci-override.sh

#!/bin/sh

DEVS="0000:0e:00.0 0000:0e:00.1"

if [ ! -z "$(ls -A /sys/class/iommu)" ]; then
    for DEV in $DEVS; do
        echo "vfio-pci" > /sys/bus/pci/devices/$DEV/driver_override
    done
fi

modprobe -i vfio-pci

Which you then need to need to modify /etc/modprobe.d/vfio.conf and add the following line:

install vfio-pci /usr/local/bin/vfio-pci-override.sh

I thought to myself this would be nice and easy but on reboot I get the following message before it asks me for my password to unlock my drive as it’s encrypted.

“/usr/local/bin/vfio-pci-override.sh file not found”

So a lot more complicated than I thought.

After searching online for possible solutions, I ended up finding out about /etc/initramfs-tools/scripts/ and reading through it, thought to myself, this might be how to do it so I ended up doing the following by placing the arch wiki scrip into the following place:

/etc/initramfs-tools/scripts/local-top/vfio-pci-override.sh

#!/bin/sh

DEVS="0000:0e:00.0 0000:0e:00.1"

if [ ! -z "$(ls -A /sys/class/iommu)" ]; then
    for DEV in $DEVS; do
        echo "vfio-pci" > /sys/bus/pci/devices/$DEV/driver_override
    done
fi

modprobe -i vfio-pci

I regenerated the initramfs and rebooted and I get progress but not fully working how it should be. When I rebooted my pc and checked to see if the 9070 XT was bound to vfio-pci, it wasn’t but it also wasn’t bound to amdgpu so I decided to try launching the windows virtual machine and vfio-pci grabbed the GPU and booted fine. When I decided to shutdown the virtual machine as I figured, this would be good enough that’s when I noticed an issue, the amdgpu driver grabbed the 9070 XT which caused the Linux host to now add an extra display and sound device. This was an issue as it caused discord to crash and also locked up my machine one time (guessing AMD reset bug maybe) while I was testing if I could live with this quirk.

I start looking around on how to bind the 9070 XT to vfio-pci since I got to the stage it’s not bound to anything so time to bind it so it doesn’t cause problems down the line and looking around I came across this and modified it for my use:

echo "0000:0e:00.0" > /sys/bus/pci/drivers/vfio-pci/bind
echo "0000:0e:00.1" > /sys/bus/pci/drivers/vfio-pci/bind

I first decided to try adding those lines to the /etc/initramfs-tools/scripts/local-top/vfio-pci-override.sh but on reboot I got an I/O error which I’m guessing it’s because, drive encrypted or maybe at the wrong place for the initramfs tools scripts as there’s different ones for different stages but again after changing to other script locations I was getting the I/O error so decided probably due to it being an encrypted drive and too early for the bind to work.

I end up making this script /usr/local/bin/vfio-pci-bind.sh because I know if that can run then everything should be mounted file system wise and just needed to figure out a stage where to start that script so it binds.

#!/bin/sh

echo "0000:0e:00.0" > /sys/bus/pci/drivers/vfio-pci/bind
echo "0000:0e:00.1" > /sys/bus/pci/drivers/vfio-pci/bind

After looking around on auto starting scripts online as I wanted this to start as early as possible for the whole system and not just when I login like an auto start script lunching discord or steam, I decided to make a systemd service just to start it which I feel is not the best way to do it but I’m also not an expect on Linux so who knows.

/etc/systemd/system/GPU_bind_vfio.service

[Unit]
Description=Bind GPU to vfio.

[Service]
Type=simple
ExecStart=/bin/bash /usr/local/bin/vfio-pci-bind.sh

[Install]
WantedBy=multi-user.target

After doing all this and enabling the GPU_bind_vfio.service I reboot my pc and it works. When I check what kernal driver the 9070 XT is using it shows “Kernel driver in use: vfio-pci” so success it now works great and I haven’t run into any problems

The scripts at the end of the journey

/etc/modprobe.d/vfio.conf left over from when I used device ID since I figured it wouldn’t hurt leaving it

softdep drm pre: vfio-pci

/etc/initramfs-tools/scripts/local-top/vfio-pci-override.sh

#!/bin/sh

DEVS="0000:0e:00.0 0000:0e:00.1"

if [ ! -z "$(ls -A /sys/class/iommu)" ]; then
    for DEV in $DEVS; do
        echo "vfio-pci" > /sys/bus/pci/devices/$DEV/driver_override
    done
fi

modprobe -i vfio-pci

/usr/local/bin/vfio-pci-bind.sh

#!/bin/sh

echo "0000:0e:00.0" > /sys/bus/pci/drivers/vfio-pci/bind
echo "0000:0e:00.1" > /sys/bus/pci/drivers/vfio-pci/bind

/etc/systemd/system/GPU_bind_vfio.service

[Unit]
Description=Bind GPU to vfio.

[Service]
Type=simple
ExecStart=/bin/bash /usr/local/bin/vfio-pci-bind.sh

[Install]
WantedBy=multi-user.target

Hopefully this helps someone out who might be in a similar situation and I welcome any feedback since there’s probably better ways to do it