~alpine/users

Alpine linux kernel modules loading

Details
Message ID
<CAE49SAg7-9R+tD7XjJXn3RArjTNaE9cc-DcRyU1kqULdim1Kcg@mail.gmail.com>
DKIM signature
missing
Download raw message
Hi all,

I have a question related to kernel modules loading
on Alpine Linux. The system I am working with is
Alpine Extended 3.15.4 with kernel 5.15.32-0-lts.

So far I found that kernel modules are loaded via:

1) Modules passed as kernel arguments (cat /proc/cmdline)
modules=sd-mod,usb-storage,ext4
Above is processed by the initramfs init (product of mkinitfs)
and modprobe is called for every module on the argument list.

2) mdev hotplug modules load:
/etc/mdev.conf:
$MODALIAS=.* root:root 0660 @modprobe -q -b "$MODALIAS"
This is for hotplug devices and modules for them.

3) OpenRC calling /etc/init.d/modules which process:
- /lib/modules-load.d/*.conf
- /etc/modules
- /etc/modules-load.d/*.conf
- /run/modules-load.d/*.conf
Then modprobe is called for valid entries in above files.

4) OpenRC calling /etc/init.d/hwdrivers
This one search /sys for modalias files and tries to load
matching modules using modprobe ("cold" hardware modules).

If I miss something and there is yet another level of
modules loading?

Explanation:
I am creating Alpine initramfs.cpio using mkinitfs.
The plan is to build a custom initramfs to play with.
My initramfs will not switch_root to HDD at the end
but will live in RAM only. To achieve this I want
to replace original init script created by mkinitfs with my own.
I have /sys, /dev and /proc setup ready and most of the script done.
Only remaining part is kernel modules loading.

The naive approach would be to just create list of modules
that needs to be loaded and call modprobe for
all of them. This would work as long as hardware will not change.
I want to make it more intelligent and merge OpenRC
logic (/etc/init.d/modules, /etc/init.d/hwdrivers).
I am wondering if this will be enough to make it working
or OpenRC is doing something more, not presented in those scripts.

Best regards,
Pawel
Reply to thread Export thread (mbox)