johnlinp
johnlinp

Reputation: 933

How are kernel modules automatically inserted by systemd?

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:

  1. systemd has a unit called systemd-modules-load.service, which reads kernel module names in /etc/modules-load.d/*.conf (and the ones in /run and /usr/lib) (systemd documentation).

  2. udev can handle kernel module automatically when devices are detected (Arch Linux wiki page).

However, I failed to see how those work:

  1. There are no config files in /etc/modules-load.d/*.conf (or the ones in /run or /usr/lib) on my system. Therefore it has nothing to load in systemd-modules-load.service.

  2. There are some modprobe commands in /usr/lib/udev/rules.d, but not all of the kernel modules I see in lsmod.

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?

Upvotes: 4

Views: 8052

Answers (1)

johnlinp
johnlinp

Reputation: 933

I found a very useful introduction on this topic: https://wiki.archlinux.org/index.php/Modalias

In brief, the secret is the mapping between MODALIAS in udev and /lib/modules/$(uname -r)/modules.alias.

Upvotes: 7

Related Questions