- Unix Commands Reference
- Unix Commands - Home
depmod Command in Linux
The depmod command in Linux generates dependency and map files by reading the modules in the /lib/modules/kernel_version directory. The depmod command determines the dependency relationships between modules.
Linux kernel modules provide services to other modules, and these services are known as symbols. The depmod command creates a list of dependencies by reading the default kernel module directory, determining which symbols each module exports and which each module requires. By default, the list is written to modules.dep file.
Table of Contents
Here is a comprehensive guide to the options available with the depmod command −
Note − The depmod command requires elevated privileges.
Syntax of depmod Command
The general syntax of the depmod command is as follows −
depmod [options] [version]
Here, [options] indicates depmod options that control the command’s behavior. While [version] signifies the kernel version for which dependencies are to be created. If the kernel version is not specified, the command will use the current kernel version by default.
depmod Command Options
Some commonly used depmod command options are listed below −
Options | Description |
---|---|
-a (--all) | It probes all the modules (system-wide) |
-A (--quick) | It quickly scans to check any newer modules |
-b (--basedir) | To change the default module directory |
-e (--errsyms) | It reports if the symbols are not provided by modules of kernel |
-h (--help) | To print help about command |
-n (--show) | It writes the dependency file to standard output |
-o (--outdir) | To set the output directory for depmod command to store any generated files |
-v (--verbose) | It provides verbose output |
-V (--version) | To check version of the command |
-w | It warns about duplicate dependencies, aliases, and symbols |
Examples of depmod Command in Linux
This section briefly explains the use of the depmod command in Linux −
- Generating Module Dependencies File
- Running depmod Command in Verbose Mode
- Updating Module Dependencies File
- Generating Module Dependencies from a Different Directory
- Dry Running the depmod Command
- Generating Dependencies File in a Different Directory
- Displaying Warnings related to Dependencies File
- Generating Dependencies File using System Map File
- Viewing Dependencies File
Generating Module Dependencies File
To create the dependencies file of the currently running kernel version, use the depmod command without any option.
sudo depmod
It reads data and symbol information from /lib/modules/$(uname -r) and generates modules.dep file in the same directory.
Running depmod Command in Verbose Mode
The depmod command often does not produce any output. To get output, use it in the verbose mode.
The -v flag or --verbose option is used to run the command in verbose mode.
sudo depmod -v
Updating Module Dependencies File
If any change is made to the kernel modules, to update it the dependencies file needs to be updated. To update the dependencies file -a flag or --all option is used −
sudo depmod -a
The above does not produce any output if it goes successfully. However, in case of errors or running the command in verbose, you can see the output.
Generating Module Dependencies from a Different Directory
If the kernel modules are located in another directory instead of the default directory then dependencies files can be generated by using the -b flag or --basedir option.
sudo depmod -b /mnt/kernel
Dry Running the depmod Command
The depmod command with -n or --show option dry-runs the command. It tests what changes the depmod command will commit instead of making actual changes.
sudo depmod -n
Generating Dependencies File in a Different Directory
To generate a dependencies file in another directory, specify the directory after the depmod -o command.
sudo depmod -o /mnt/kernel
The above command generates files for the current kernel. To generate the dependencies file for a specific kernel, first set the kernel’s base directory using the depmod -b command. Then, run the depmod -o command.
Displaying Warnings related to Dependencies File
To display the warnings related to module dependencies, the -w flag is used. It is specifically useful for troubleshooting purposes.
sudo depmod -w
The above command displays warnings related to missing symbols, dependencies, and aliases.
Generating Dependencies File using System Map File
The dependencies file can also be generated using the System.map file located in the /boot directory. This file contains mappings for kernel symbols, crucial for various kernel operations.
To generate a dependencies file using the system map file the -F flag is used with the file path.
sudo depmod -F /boot/System.map-6.8.0-35-generic
Viewing Dependencies File
The dependencies file of a current kernel is located in the /lib/modules/$(uname -r) directory. To view its contents, the cat command can be employed −
cat /lib/modules/$(uname -r)/modules.dep
The modules.deb file ensures that the modules load properly hence helping the system stability.
Conclusion
The depmod command in Linux generates dependencies files of kernel modules. It is used when modifications are made to the kernel modules or a new kernel is installed.
The depmod command ensures dynamic loading of kernel modules for stable operation of the system.