I have a sh script that should be executed during system boot, as I understand before graphic driver modules are loaded.

Probably this is not relevant for the answer, but this script serves for PCI passthrough of a GPU in the special case a system has two identical GPUs sharing the same id, to override the driver assignment only on one of the two GPUs.

For arch linux systems, a wiki says that one should:

Edit /etc/mkinitcpio.conf:
Add modconf to the HOOKS array and /usr/local/bin/vfio-pci-override.sh 
to the FILES array.
Edit /etc/modprobe.d/vfio.conf:
Add the following line: install vfio-pci /usr/local/bin/vfio-pci-override.sh
Regenerate the initramfs and reboot.

What is the Ubuntu equivalent of mkinitcpio.conf and how should it be modified in this case? Just in case, the script is the following:


DEVS="0000:01:00.0 0000:01: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

1 Answer 1


The package is called (man page) initramfs-tools (see wiki: wiki.ubuntu.com/Initramfs).

initramfs-tools - an introduction to writing scripts for mkinitramfs

initramfs-tools has one main script and two different sets of subscripts which will be used during different phases of execution. Each of these will be discussed separately below with the help of an imaginary tool which performs a frobnication of a lvm partition prior to mounting the root partition.



Mind that ...


can be used for configuration files and


for adding hooks. To rebuild you can use ...

 update-initramfs -u
  • Thank you. My folder is /etc/initramfs-tools/ (on kubuntu 19.10) but besides that your answer was correct. I copied my script in /etc/initramfs/conf.d/ , rebuilded initramfs and rebooted. It did something: now one card has the usual kernel driver in use, the other has not. Unfortunately it did not bind vfio-pci to that GPU, but this might be another kind of problem. Feb 14, 2020 at 15:38
  • Gratz on getting 1/2 working O
    – Rinzwind
    Feb 14, 2020 at 17:55
  • 3
    Can you be more specific. How to do the configurations and the hooks.
    – user63726
    Mar 8, 2020 at 2:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .