Compiling Kernel   «Prev  Next»

Lesson 4 Loading modules
ObjectiveLoad kernel modules.

Loading Kernel Modules manually when compiling Linux Kernel

The modprobe command allows you to manually load kernel modules.
is a smart command, as it performs several operations to make sure you load the module correctly.
  1. It loads all modules that your module depends on.
  2. It consults /etc/conf.modules for your module's default parameters.
  3. It can try a list of modules, and when it loads a module successfully, it ceases to try others in the list.

You can also use the depmod, insmod, and rmmod commands to load modules. However, I recommend steering away from them, as you will need to follow more steps to obtain the same functionality as modprobe.
The SlideShow below demonstrates how to load modules into the kernel.

How do you load kernel modules manually when compiling a Linux Kernel?

When compiling a Linux kernel, you may want to manually load certain kernel modules after booting the system. Here are the steps to load kernel modules manually:
  1. Compile the kernel with the necessary module(s) enabled or built-in. This can be done by selecting the appropriate configuration option during the kernel compilation process. For example, if you need to load the "vfat" module for reading and writing FAT filesystems, you would select the "FAT filesystem support" option and the "VFAT (Windows-95) fs support" option in the kernel configuration.
  2. After booting the new kernel, log in as root.
  3. Check if the module you want to load is available by using the "lsmod" command. This command lists all currently loaded modules.
  4. If the module is not listed, you can manually load it by using the "modprobe" command. For example, to load the "vfat" module, type "modprobe vfat". This will load the module and any dependencies it requires.
  5. You can verify that the module has been loaded by using the "lsmod" command again.

Note that if you want to load a module automatically at boot time, you can add the module name to the "/etc/modules" file. This file contains a list of modules that should be loaded at boot time, one module per line.

1) Linux Kernel by itself
1) Linux Kernel by itself

2) A module loaded into the kernel
2) A module loaded into the kernel

3) A kernel with many modules
3) A kernel with many modules
  1. Linux Kernel by itself
  2. A module loaded into the kernel
  3. A kernel with many modules
Kernel Loaded Module

Loading kernel modules on demand

The Linux 2.2 kernel thread, kmod, constantly checks to see if any requests require missing functionality.
If kmod sees the need to load a module, it will call modprobe to load the module. For example, if you mount a filesystem that your kernel does not support, kmod will load the support automatically. Automatic loading of modules is called demand loading.
The Linux kernel is multi-threaded, meaning that multiple actions occur within the kernel simultaneously.
The next lesson explains how to configure kernel modules.

Red Hat Enterprise Linux