Fedora equivalent of Ubuntu initramfs-tools/scripts?

Hi,

I have a .sh script (copied from Archwiki) that binds vfio-pci to the SATA controller (before ahci got binded to it) on another Proxmox machine:

/etc/initramfs-tools/scripts/init-top/bind_vfio.sh

#!/bin/sh

DEVS="0000:03:00.0"

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

modprobe -i vfio-pci

My Fedora Workstation 37 has a USB controller that uses the xhci_hcd driver. I want to bind vfio-pci to it before xhci_hcd can, just like what I did on the Proxmox machine.

I tried putting the script in /lib/dracut/hooks/pre-udev then regenerating initramfs with Dracut, but the USB controller still uses xhcd_hcd. What am I missing?

It’s possible that your script is not being executed during the initramfs boot process. Here are a few things you can try to troubleshoot the issue:

  1. Make sure that the script has execute permissions. You can use the following command to ensure that the script is executable:

bashCopy code

chmod +x /lib/dracut/hooks/pre-udev/bind_vfio.sh
  1. Check the Dracut configuration to see if the script is being included in the initramfs. You can check the contents of /etc/dracut.conf to see if the add_dracutmodules option is including the pre-udev hook:

bashCopy code

grep add_dracutmodules /etc/dracut.conf

The output should include the pre-udev hook, like this:

makefileCopy code

add_dracutmodules+=" pre-udev "
  1. Try adding some debug output to the script to see if it is being executed at all. For example, you can add the following line to the top of the script to log a message to the console:

bashCopy code

echo "Binding vfio-pci to USB controller"

If you don’t see this message when the initramfs boots, then the script is not being executed.
4. Check the kernel logs for any errors related to the script or the binding process. You can view the kernel logs with the following command:

Copy code

dmesg | less

Look for any errors or messages related to vfio-pci or your USB controller.

Hopefully, one of these steps will help you identify the issue and get your script working properly.

1 Like

Hi!

The add_dracutmodules line is not present in my /etc/dracut.conf file.

I have tried adding the add_dracutmodules line to a .conf file inside /etc/dracut.conf.d.
Then I tried rebuilding initramfs with `dracut -f --kver `uname -r`, but it failed because dracut module 'pre-udev' cannot be found or installed.

Reading the dracut manpage, it seems add_dracutmodules only accepts modules located in
/usr/lib/dracut/modules.d. Should I put my script there?