Compiling Kernel   «Prev  Next»

Lesson 5Configure Linux Module Options and Boot-Time Loading
ObjectiveDistinguish modprobe configuration, startup loading, and early-boot initramfs requirements.

Configure Linux Module Options and Boot-Time Loading

Module options control a driver's behavior; startup-loading configuration requests that a module be loaded. These are separate settings. On current RHEL systems, use configuration directories such as /etc/modprobe.d/ and /etc/modules-load.d/. The older /etc/conf.modules procedure is not the configuration model used in this lesson.

Inspect supported options first

modinfo -p loop
modprobe -c

modinfo -p lists parameters exposed by the installed module. modprobe -c displays the combined configuration understood by the tool. Parameter names and permitted values are specific to the module and kernel version.

Set a module parameter

For a lab kernel that provides loop as a module and lists max_loop as a supported parameter, an administrator can create /etc/modprobe.d/loop-lab.conf containing:

# Lab example; check modinfo -p loop on the target kernel.
options loop max_loop=16

The setting is used when the module is inserted through the normal loading path. Editing the file does not reconfigure a module that is already loaded. Arrange a reboot or a safe unload/reload after stopping all users, then inspect the resulting parameter if the driver exposes it:

cat /sys/module/loop/parameters/max_loop

Built-in drivers need an appropriate built-in parameter mechanism, commonly a documented kernel command-line parameter. A modprobe.d file does not cause built-in code to be reinserted.

Request deliberate loading at startup

If this same lab requires the module before any application requests it, an administrator can create /etc/modules-load.d/loop-lab.conf with one module name per line:

loop

Do not put options directives in this file. On systemd systems, the module-loading service processes these requests. Prefer automatic device-based loading when it already provides the required behavior.

Aliases and blacklists have specific meanings

An alias directive gives a module an alternate name. A blacklist directive suppresses matching internal aliases; it is not an absolute guarantee that the module can never be loaded explicitly or as a dependency. If a policy requires disabling a driver, follow the distribution's complete procedure and account for modules included in the initramfs.

Place administrative overrides in /etc rather than editing vendor configuration files. Check effective configuration and filename precedence when more than one file influences a module.

Account for early boot

A storage driver or its configuration may be needed before the real root filesystem is available. In that case, modifying a file on the root filesystem may not be sufficient: the relevant configuration must be included in the target kernel's initramfs. Lesson 10 covers identifying that target and inspecting the generated image.

Record the changed file, parameter, reason, and verification result. This makes the configuration reproducible when the kernel is updated.

Kernel Modules - Quiz

Review module inspection, loading, and configuration with the quiz linked below.

Kernel Modules - Quiz

The next lesson considers when compiling a custom kernel is justified.

References

SEMrush Software 4 SEMrush Banner 4