Debian bookworm, kernel 6.8.0-rc5, kmod version 30
I'm working with a constrained system and need to unbind some unused PCIe ports to free up IRQs for downstream devices before they load. I am using an install command in modprobe.d/mpt3sas.conf (then rebuilding with update-initramfs -u)
softdep mpt3sas pre: i40e
install mpt3sas /bin/sh /usr/bin/unbind_pcieport.sh; /sbin/modprobe --ignore-install mpt3sas $CMDLINE_OPTS
but unbind_pcieport.sh doesn't fire. I've included echos in unbind_pcieport.sh, outputting to a log file, but no log file is ever created, indicating the script is not running at all.
The unbinding works as expected if I put everything inside mpt3sas.conf like this:
install mpt3sas echo "0000:02:08.0" > /sys/bus/pci/drivers/pcieport/unbind; echo "0000:02:09.0" > /sys/bus/pci/drivers/pcieport/unbind; echo "0000:02:0a.0" > /sys/bus/pci/drivers/pcieport/unbind; /sbin/modprobe --ignore-install mpt3sas $CMDLINE_OPTS
but I'd like to have some logic in my script and it's just cleaner to not have it all in one line of the .conf
This is the script body:
#!/bin/sh
# Space-separated list of PCI devices to unbind
PCI_DEVICES="0000:02:08.0 0000:02:09.0 0000:02:0a.0"
# Unbind each specified device if it exists
for DEVICE in $PCI_DEVICES; do
if [ -e "/sys/bus/pci/drivers/pcieport/$DEVICE" ]; then
echo "$DEVICE" > /sys/bus/pci/drivers/pcieport/unbind
echo "Unbound $DEVICE from pcieport driver"
else
echo "$DEVICE not found or already unbound"
fi
done
I've tried using /bin/bash instead of sh, and omitting /bin/bash in the .conf and just using "unbind_pcieport.sh" (with the script in $PATH)
The .sh script is world executable and readable
EDIT:
Loking through the modprobe manual I haven't found why my script isn't executing, but I did find that you can break lines with \, so I at least cleaned up the working mpt3sas.conf for now:
softdep mpt3sas pre: i40e
install mpt3sas \
echo "0000:02:08.0" > /sys/bus/pci/drivers/pcieport/unbind;\
echo "0000:02:09.0" > /sys/bus/pci/drivers/pcieport/unbind;\
echo "0000:02:0a.0" > /sys/bus/pci/drivers/pcieport/unbind;\
/sbin/modprobe --ignore-install mpt3sas $CMDLINE_OPTS
mpt3sasis loaded before switching root, and while the modprobe.d conf may have been included in the initramfs (because you triggered a regeneration of that after you have the file created under/etc/modprobe.d/(of the real root), yet you forgot to / didn't realize you need to also add/usr/bin/unbind_pcieport.shto the initramfs (like by some means make the initramfs generator of your system include the file when it does its work).