Last updated
Last updated
The depmod
command in Linux is used to generate a module dependency file (modules.dep
) and related files (modules.alias
, modules.symbols
, modules.devname
) that list the dependencies of kernel modules. Here’s an overview of what depmod
does and how it is used:
depmod
Dependency Resolution:
Kernel modules often depend on other modules or kernel features to function correctly.
depmod
scans all available modules and generates a dependency file (modules.dep
) that specifies which modules depend on others.
Module Loading:
When the Linux kernel loads a module using modprobe
or insmod
, it checks dependencies listed in modules.dep
.
If a required dependency is missing, the kernel may fail to load the module or encounter runtime errors.
Related Files:
Besides modules.dep
, depmod
also generates other files:
modules.alias
: Provides symbolic links to modules based on their properties.
modules.symbols
: Maps symbols to modules, aiding in module resolution.
modules.devname
: Maps network device names to modules.
depmod
Basic Usage: Run depmod
without arguments to generate or update module dependency files based on the currently running kernel and installed modules.
Specific Kernel Version: Use -b
to specify the base directory where the kernel modules are located. This is useful when working with a kernel build directory or a different root filesystem.
Force Update: The -a
option forces depmod
to regenerate module dependency files even if they already exist. This ensures the latest module configurations are accounted for.
Verbose Output: Adding -v
provides verbose output, showing detailed information about the modules being processed and any errors encountered.
Suppose you've compiled and installed a new kernel module (my_module.ko
) into your Linux system. To ensure the kernel can properly load my_module
and resolve any dependencies, you would run:
This command updates modules.dep
and related files in the default module directory (/lib/modules/$(uname -r)/
) based on the modules currently installed.
Kernel Updates: After installing a new kernel or updating modules, it's essential to run depmod
to ensure the kernel can correctly load modules with their dependencies.
System Maintenance: Regularly updating module dependencies is crucial for system stability and compatibility, especially when upgrading kernel versions or adding new hardware support.
depmod
is a vital command for managing kernel module dependencies in Linux systems. It ensures that modules are loaded correctly by generating dependency files and related mappings used by the kernel during module loading and system startup. Understanding how to use depmod
ensures smooth operation and compatibility when working with kernel modules and custom kernel configurations.