depmod – Analyze Dependencies of Loadable Modules

The depmod command is used to analyze the dependencies of loadable kernel modules in Linux. It creates a list of module dependencies by examining the symbols used by each module and comparing them to the symbols exported by other modules. This list is then used by the kernel to ensure that modules are loaded in the correct order, with all dependencies satisfied.

Overview

The depmod command is typically used after installing or updating kernel modules. It can be run with or without arguments, depending on the desired behavior.

Basic usage

To generate a list of module dependencies, simply run depmod with no arguments:

depmod

This will create a new dependency file in the default location (/lib/modules/$(uname -r)/modules.dep), based on the currently loaded kernel version.

Specifying a kernel version

If you need to generate a dependency file for a specific kernel version (e.g. if you have multiple kernel versions installed), you can use the -b option followed by the path to the kernel directory:

depmod -b /path/to/kernel

This will create a dependency file for the specified kernel version, rather than the currently loaded version.

Updating an existing file

If you have already generated a dependency file and need to update it (e.g. after installing a new module), you can use the -a option to append new dependencies to the existing file:

depmod -a

This will add any new dependencies to the existing dependency file, rather than overwriting it.

Verbose output

If you need more detailed information about the dependencies of each module, you can use the -v option to enable verbose output:

depmod -v

This will print out a list of all modules and their dependencies, along with any errors or warnings that are encountered.

Options

The following options are available for the depmod command:

Option Description
-a Append new dependencies to an existing dependency file
-b <dir> Use the specified kernel directory instead of the default
-E <file> Use the specified file instead of the default modules.dep
-e Include weak symbols in the dependency analysis
-F <file> Use the specified file instead of the default modules.dep.bin
-n Dry-run mode (do not write any files)
-q Quiet mode (do not print any output)
-v Verbose mode (print detailed output)

Troubleshooting tips

If you encounter errors or warnings when running depmod, there are a few common issues to look out for:

  • Missing dependencies: If a module depends on another module that is not installed, depmod will report an error. Make sure all required modules are installed before running `depmod.
  • Symbol conflicts: If two modules export the same symbol with different meanings, depmod may report a warning or error. This can sometimes be resolved by rearranging the load order of the modules, or by modifying the modules to use different symbol names.
  • Incorrect kernel version: If you specify the wrong kernel version with the -b option, depmod may generate an incorrect dependency file. Make sure you are using the correct kernel directory when generating dependency files.

Notes

  • The depmod command is typically run automatically during the installation of new kernel modules, so manual invocation is rarely necessary.
  • The dependency file generated by depmod is used by other commands such as modprobe and insmod to ensure that modules are loaded in the correct order.
  • The depmod command is included in most Linux distributions by default, so it should be available on any Linux system.