I am trying to find out how kernel modules are automatically inserted. I am using Arch Linux, so basically I am working with systemd.
After some research, I know there are at least 2 ways to insert kernel modules:
systemdhas a unit calledsystemd-modules-load.service, which reads kernel module names in/etc/modules-load.d/*.conf(and the ones in/runand/usr/lib) (systemd documentation).udevcan handle kernel module automatically when devices are detected (Arch Linux wiki page).
However, I failed to see how those work:
There are no config files in
/etc/modules-load.d/*.conf(or the ones in/runor/usr/lib) on my system. Therefore it has nothing to load insystemd-modules-load.service.There are some
modprobecommands in/usr/lib/udev/rules.d, but not all of the kernel modules I see inlsmod.
For example, I have a xfs kernel module in the output of lsmod, but I can't find out the trigger point of inserting it. None of my filesystem are mounted with xfs (cat /proc/mounts | grep xfs shows nothing).
Is there any introduction or tutorial of how all this works?
I found a very useful introduction on this topic: https://wiki.archlinux.org/index.php/Modalias
In brief, the secret is the mapping between
MODALIASin udev and/lib/modules/$(uname -r)/modules.alias.