[systemd-devel] Custom initrd services

Lennart Poettering lennart at poettering.net
Tue Jun 11 13:14:17 UTC 2024


On Di, 11.06.24 09:37, Carolina Jubran (cjubran at nvidia.com) wrote:

> Hello!
>
> I have modules that need to be loaded using services because some of
> them don't autoload their modules.

"Modules"? do you mean kmod kernel modules with that?

> I want the modules to load in initrd, before initrd.target. However,
> the service is not consistently loading in initrd in the current
> implementation.

If you have kernel modules that to not autoload, it should typically
suffice to add any kernel modules to a file in /etc/modules-load.d/ in
the initrd.

That said, in 2024 kernel modules that do not autoload seems quite out
of place.

> To resolve this issue, I added "systemctl add-wants initrd.target
> A.service" in the dracut configuration.

Hmm, I don't follow? what would such a line do to kernel modules?

> Is this sufficient for my setup, or do I need to make any further
> changes in the systemd side to ensure the correct loading before
> initrd.target? I'm using systemd-load-modules to load the modules.

I am not sure I follow really. That service that needs the kernel
modules, what kind f service is that?

Note that services can add the followng to their deps:

    Wants=modprobe at foobar.service
    After=modprobe at foobar.service

To ensure the kmod "foobar" is definitely loaded before the service
begins execution.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list