Kernel Modules

Kernel modules are Article description::object files that contain code to extend the [[kernel of an operating system.]] Kernel modules are used to add support for new hardware and/or filesystems, or for adding system calls. Modules can be built into the kernel or compiled as loadable kernel modules.

Most modern Gentoo installations will use a device manager, such as udev, to automatically load and manage kernel modules, thus module loading will often need no particular configuration.

Gentoo installs, except from Gentoo Prefix, have the virtual package in the system set, which often resolves to  by default. virtual/udev has an "any of many" dependency on, and (or the depreciated ).

About Loadable kernel modules
Many Loadable kernel modules (LKMs) may also be compiled "in-kernel". See configuring a kernel on how to select either built-in and LKM options.

Using LKMs can result in a smaller kernel memory footprint, by not having unneeded modules loaded: modules can be loaded on demand by udev (for example DVB drivers for a DVB stick). Compile-in-kernel code will not be able to be reloaded while the kernel is running, but LKMs can sometimes be used to solve certain issues, by unloading and reloading them.

Using a module rather than building code into the kernel also permits the setting of module-specific parameters, through the file - see man /etc/modprobe.d.

Modules needed early in the boot process may require an update of the initramfs after a kernel update or recompilation (e.g. filesystem drivers for filesystems used for boot). Some LKMs may incur a slight performance penalty over built-in code, due to the addition of an API layer and slightly more memory usage.

Beware of file system module X located on a partition formatted with X (unbootable system at worst).

View running modules
To list currently loaded modules, run.

To see all modules built into the currently running kernel:

List available modules
To see all the modules available to be loaded:

Load specific modules during boot
Occasionally, modules other than those automatically loaded are desired. Loadable modules can be defined in files in the  directory in order to load them during the init portion of the system boot process. Both OpenRC and systemd will look in this path. Each module is listed one per-line. For example:

Blacklist modules
To prevent a module from loading, add it by name to a file in and precede each module name with the   keyword:

More information on module blacklisting via can be found by reading the modprobe.d(5) man page:

Alternatively, kernel modules can be blacklisted from the secondary bootloader (see GRUB2, systemd-boot, etc.) via parameters passed to the kernel from the kernel command-line. For example, to blacklist the, , and kernel modules using command-line parameters:

module_blacklist=evbug,nvidiafb,nvidia

More details on backlisting via kernel command-line parameters can be found in the upstream kernel documentation (search for module_blacklist).

Manual loading
A module can be loaded or unloaded manually by the command. For example, to unload the  module and load the   module, run:

See man modprobe.

Going completely "module-less"
If, for some reason, there is a desire to have a completely module-less system, disable loadable module support in the kernel configuration (making sure to build-in any required drivers/features, of course). Setting  will disable loadable module support:

With a module-less kernel, it is possible to dispense the userspace programs that manage loadable modules (e.g., , etc). To do this, remove  support from packages that use it, and also remove the  package. Because is part of the system set, it must first be removed from the set before it can be unmerged.

First, add  to the system's USE flags in.

Next, rebuild installed packages without kmod support:

Follow any special instructions given by rebuilt packages (for example, if udev was rebuilt, then restart it according to the instructions in the output).

Now add  to  (create the  directory and  file if they don't exist). This removes the package from the system set.

Then unmerge the package:

If the above command doesn't remove kmod, then some package still depends on it even with the  USE flag set. Run to find out which package still depends on kmod.

If a kernel was installed with modules, then also remove the directory. Since the kernel was built without any loadable modules, there won't be anything useful in there anymore.

When using a generated initramfs, it may be necessary to add   to the kernel command line in the system's bootloader (e.g. GRUB) configuration so that the initramfs does not waste any time looking for modules to load.

Kernel modules fail to automatically load
Ensure that CONFIG_MODPROBE_PATH points to the correct location for the modprobe binary: