How do i add kernel modules with dracut? mkinitcpio.conf equivalent?

I’m trying to do GPU passthrough, but can’t find a way to add the necessary kernel modules.

On Arch, this is done with mkinitcpio.conf. I don’t know how dracut works.

Here’s the step: https://github.com/vanities/GPU-Passthrough-Arch-Linux-to-Windows10

edit /etc/mkinitcpio.conf. At the very top of your file you should see a section titled MODULES. Towards the bottom of this section you should see the uncommented line: MODULES= . Add the in the following order before any other drivers (nouveau, radeon, nvidia, etc) which may be listed: vfio vfio_iommu_type1 vfio_pci vfio_virqfd. The line should look like the following:

There’s a dracut.conf file but all it says is to put the config in separate files in dracut.conf.d with name.conf.

Reading the man pages, it says this:

add_dracutmodules+=" <dracut modules> "

Meaning, adding the libvirt kernel modules would look like this in a file named libvirt.conf:

add_dracutmodules+=" vfio vfio_iommu_type1 vfio_pci vfio_virqfdvfio vfio_iommu_type1 vfio_pci vfio_virqfd "

Is this correct? Then just rebuild with dracut? And this persists after the kernel is updated, right?

Also, i’m using the zen kernel because of the ACS override patch, do i need to add those specific modules to that kernel, or are all kernels affected by this?

Dracut refers to kernel modules as “drivers”. So you can use add_drivers or force_drivers

“modules” refers to dracut modules, not kernel modules.

2 Likes

Ah! Good to know, thank you! I would have messed something up had i not asked. :smiley:
A bit counterintuitive haha, but it’s fine. :slight_smile:

Thank worked, thanks!

Just another quick question, do i need to create a hook or something to do this every time there’s a kernel update? Or does this now just get included?

Assuming you added your changes in /etc/dracut.conf.d, it should be automatic.

There is already hook that calls dracut when kernels change.

1 Like

Yes, i stored the add_drivers line in the vfio.conf file in dracut.conf.d.
Then it’s automatic.

Thank you! :slight_smile:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.