Compiling Kernel   «Prev 

Loading Kernel Modules

Kernel modules in Red Hat Linux can be loaded dynamically into the system kernel to add functionality without requiring a system reboot. These modules can be hardware drivers, filesystems, system calls, or any other feature the kernel can use. Here are the principal ways to load kernel modules:
  1. Using the insmod Command: insmod is a simple method to insert a module into the Linux Kernel. To use insmod, navigate to the directory containing the module and type the command followed by the .ko module filename.
    insmod /path/to/module.ko
    

    Please note that insmod does not resolve dependencies. The module must be self-contained or dependencies must be loaded manually beforehand.
  2. Using the modprobe Command: modprobe is a more sophisticated method to load modules. It automatically resolves dependencies and loads the required modules. If a module depends on another, modprobe ensures the dependent module is loaded first. To use modprobe, simply type the command followed by the module name.
    modprobe module_name
    

    modprobe looks in the module directory /lib/modules/uname -r for the modules.
  3. Automatically at Boot Time: Kernel modules can be loaded automatically at boot time by listing them in the /etc/modules file (or /etc/modules-load.d/ directory in some distributions). Each module should be listed on a separate line. This method uses modprobe under the hood, so dependencies are automatically handled.
    Add a module to this file using the echo command, replacing 'module_name' with the name of the module:
    echo 'module_name' >> /etc/modules
    

    Or create a new .conf file in the /etc/modules-load.d/ directory:
    echo 'module_name' > /etc/modules-load.d/module_name.conf
    

    The changes will take effect on the next system boot.
  4. Upon Hardware Detection - udev Rules: Linux uses the udev system for device detection and management. When udev detects a new device, it can automatically load the appropriate kernel module for that device using its rules system. This is typically handled by the distribution and not manually configured by users. The rules files are located in
    /etc/udev/rules.d/ and /lib/udev/rules.d/.
    

  5. For all the methods that require manual command line input, ensure you have the necessary administrative privileges to execute these commands. Be cautious when manually loading modules, as incorrect usage can destabilize your system.
Kernel modules are pieces of code that can be loaded and unloaded into the kernel upon demand. They extend the functionality of the kernel without the need to reboot the system.
A module can be configured as
  1. built-in or
  2. loadable.
To dynamically load or remove a module, it has to be configured as a loadable module in the kernel configuration (the line related to the module will therefore display the letter M). Modules are stored in
/usr/lib/modules/kernel_release. 

You can use the command uname -r to get your current kernel release version.


Red Hat Linux Server