Load modules in initrd

Carolina Jubran <[email protected]> Wed, 19 Jun 2024 11:51:00 +0000
Newsgroups org.kernel.vger.initramfs
Message-ID <BYAPR12MB3318839A4B6BE11ECB13E06BCBCF2@BYAPR12MB3318.namprd12.prod.outlook.com>
Hello!

I need to load RDMA modules in initrd, and I have a systemd service for that. However, when we start running in the initrd, the initrd-cleanup.service kills the service.
The Dracut arrangement only installs the service if the necessary hardware is present.
I tried to add dependencies to the systemd service "Before=initrd.target" to ensure that the service loads the drivers in initrd.
Unfortunately, this was inconsistent; sometimes we load in initrd and sometimes we don't. 

Then I discovered that adding a "$SYSTEMCTL -q --root "$initdir" add-wants initrd.target <our-service>" in the module-setup.sh helps with the issue, and the driver consistently runs in initrd.
My question is, how does "add-wants initrd.target" fit into the picture with the initramfs image and systemd? 
Do I need to make any further changes to my systemd service, or is building the image using dracut sufficient?

Thank you,
Carolina Jubran