Start systemd-modules-load.service after cryptsetup.target

Good day.

I have custom kernel modules that I load from modules.conf. At every boot the systemd-modules-load.service fails since it starts prior to cryptsetup.target. The modules get loaded after unlocking the disks. There are unnecessary errors at the boot time saying Systemd couldn’t load modules. The service file has no [INSTALL] section and Requires, RequiresMountFor, After directives don’t seem to work.

Is it safe to add [INSTALL] section with WantedBy=multi-user.target and add After=cryptsetup.target in [UNIT] section?

I will like to get rid of these errors on console, the errors don’t show up in journalctl, I can provide a picture of console if need be. Please let me know how to suppress these errors and start systemd-modules-load after cryptsetup.target

Thanks!

systemd-modules-load.service loads kernel modules. kernel modules are located on root filesystem. root filesystem must be available and unlocked before this. I do not see how crytpsetup.target can be related to this.

Instead of describing your conclusions, start with actual problem - what you have done, what results you expected, what results you got.

I’ve encrypted root. I want systemd-modules-load.service to start after cryptsetup.target or sysvinit.target, RequiresMountFor= or After= or Requires= don’t seem to work.

These are the errors I see in /var/log/boot.log

[FAILED] Failed to start Load Kernel Modules.
[FAILED] Failed to start Load Kernel Modules.
[FAILED] Failed to start Load Kernel Modules.

What you probably need, is to delay that module load until the switch to the real root file system (instead of the temporary “initrd” ram disk. I’m not sure of the best way to do that, but there are probably better ways than tying it to cryptsetup. Alternatively, you could try forcing the needed modules to be included in the “initrd”.

RequiresMountFor= should work but it didn’t. The info page reads -

RequiresMountsFor=
  Takes a space-separated list of absolute paths. Automatically adds dependencies of type Requires= and After= for all mount units required to access the specified path.
  Mount points marked with noauto are not mounted automatically and  will be ignored for the purposes of this option. If such a mount should  be a requirement for this unit, direct dependencies on the mount units may be added.
 


I am exploring some other alternatives for delaying the modules-load.

There is no logical relation between these two sentences.

These are the errors I see in /var/log/boot.log

[FAILED] Failed to start Load Kernel Modules.

And what makes you believe it has anything to do with root encryption? What makes you believe that delaying module loading will fix it? Did you try to actually debug what happens?

I created the thread after due diligence, posted the log. It takes over 20 mins for system to boot and about same time for a complete shutdown. I can’t keep rebooting all the time. Don’t ask rhetorical counter questions if you have no answers.

I fixed it with a shell script loop, now the modules are loaded after local-fs.target and before network.target

If you’re certain this is what you require,
There was a recent thread somewhere for a similar situation where “WantedBy” “After” and “Before” where all defined in a particular Unit file to achieve a result similar to what you describe. Maybe these would also work for you, replacing a script.

TSU

RequiresMountsFor=/ and After=local-fs.target seem to work. My issue with systemd-modules-load.service is unique since xtables-addons-kmp doesn’t seem to work with latest kernel, with a script I am able to control modules, rebuild them if necessary and load them. Some modules are dkms capable (pf_ring) and some are not. I have another thread here for xtables-addons-kmp, please let me know how to fix the dkms for it. I will like to use the systemd-modules-load instead of a script.