Keywords: Linux | kernel module | modprobe | depmod | persistent loading
Abstract: This article addresses a common issue in Linux where the modprobe command fails to locate a kernel module even after installation. We explore the role of the depmod command in creating module dependency lists, provide step-by-step solutions to resolve the problem, and discuss methods for persistent module loading across reboots. Key topics include kernel module management, modprobe, and system configuration.
Problem Description
In Linux systems, installing custom kernel modules is a common task for developers and administrators. A frequent issue encountered is when the modprobe command reports that a module is not found, even though the corresponding .ko file is present in the correct directory under /lib/modules/$(uname -r)/. This problem often arises after manual compilation and installation of modules, such as the acpi_call module from GitHub.
Understanding modprobe and Kernel Module Loading
The modprobe command is used to load and unload Linux kernel modules. It relies on a dependency database located at /lib/modules/$(uname -r)/modules.dep, which is generated by the depmod utility. When a module is installed via make install, the .ko file is typically placed in a subdirectory like extra/, but modprobe may not recognize it until the dependency list is updated.
The Role of the depmod Command
depmod scans the /lib/modules/$(uname -r)/ directory and its subdirectories to create or update the modules.dep file. This file contains the dependencies between modules, allowing modprobe to locate and load them correctly. Running sudo depmod after module installation ensures that the system's module database is synchronized with the newly added files.
Step-by-Step Resolution
To resolve the "module not found" error, follow these steps:
- Verify that the module file (e.g.,
acpi_call.ko) is in the appropriate directory, such as/lib/modules/$(uname -r)/extra/. You can check the kernel version withuname -r. - Run the
depmodcommand to update the dependency database: - Attempt to load the module using
modprobe: - If successful, the module should be loaded, and you can verify with
lsmod | grep acpi_call.
sudo depmodsudo modprobe acpi_callPersistent Module Loading
To ensure the module loads automatically on boot, you can add it to the system's configuration. Common methods include:
- Adding the module name to
/etc/modulesor a file in/etc/modules-load.d/for systemd-based distributions. - Using
modprobein startup scripts, but configuring via module-load files is preferred for persistence.
For example, create a file /etc/modules-load.d/acpi_call.conf with the content:
acpi_callConclusion
The "module not found" error with modprobe is often resolved by running depmod to update the module dependency database. This highlights the importance of maintaining synchronized module lists in Linux kernel management. By understanding and applying these commands, users can effectively install and persist custom kernel modules.