Introduction to Kernel Module Information with modinfo
This tutorial will guide you through leveraging the Linux modinfo
command to analyze and debug kernel modules. The modinfo
utility presents comprehensive details regarding kernel modules, encompassing aspects like filename, authorship, descriptive overview, licensing terms, dependencies, and configurable parameters. This knowledge is invaluable for systemadmin tasks, particularly when resolving issues tied to kernel modules or seeking to comprehend the operational mechanics and configuration possibilities of a given module.
Understanding the modinfo Command
In this section, we will delve into the functionalities of the Linux modinfo
command, a powerful tool that provides in-depth information about kernel modules. Mastering the modinfo
command is essential for effective system administration and kernel module troubleshooting.
Let's begin by verifying the version of the modinfo
command installed on our Ubuntu 22.04 system:
modinfo --version
Example output:
modinfo version 2.6.32-504.16.2.el6
The primary function of the modinfo
command is to display information about a specific kernel module. For instance, to retrieve details about the ext4
module, execute the following command:
sudo modinfo ext4
Example output:
filename: /lib/modules/5.15.0-1023-aws/kernel/fs/ext4/ext4.ko
author: Remy Card, Stephen Tweedie, Andrew Morton, Jakub Jelinek, et al.
description: Fourth Extended Filesystem
license: GPL
alias: fs-ext4
alias: ext4
alias: ext3
alias: ext2
depends: mbcache,jbd2
retpoline: Y
name: ext4
vermagic: 5.15.0-1023-aws SMP mod_unload modversions
parm: abort:behaviour when a metadata write fails (int)
parm: barrier:default barrier usage (int)
parm: dioread_nolock:use delalloc with no lock (int)
parm: max_dir_size_kb:max size of directories (unsigned long)
parm: min_batch_time:min time between delayed allocation attempts (us) (int)
parm: max_batch_time:max time between delayed allocation attempts (us) (int)
The output showcases a wealth of information about the ext4
module, including its filename, author(s), a descriptive summary, the license under which it is distributed, any aliases it may have, its dependencies on other modules, and a series of configurable parameters.
The modinfo
command empowers you to explore the details of any kernel module present on your system. This is particularly valuable when diagnosing problems associated with kernel modules or when striving to gain a deeper understanding of the functionality and customizable aspects of a particular module.
Exploring Module Information with modinfo
In this section, we'll delve deeper into the practical application of the modinfo
command to investigate kernel modules.
Let's begin by generating a list of all kernel modules currently active on the system:
sudo modinfo -F filename -a
Example output:
/lib/modules/5.15.0-1023-aws/kernel/drivers/acpi/acpi_power_meter.ko
/lib/modules/5.15.0-1023-aws/kernel/drivers/acpi/acpi_thermal_rel.ko
/lib/modules/5.15.0-1023-aws/kernel/drivers/acpi/battery.ko
/lib/modules/5.15.0-1023-aws/kernel/drivers/acpi/button.ko
/lib/modules/5.15.0-1023-aws/kernel/drivers/acpi/ec_sys.ko
/lib/modules/5.15.0-1023-aws/kernel/drivers/acpi/fan.ko
/lib/modules/5.15.0-1023-aws/kernel/drivers/acpi/video.ko
Here, the -F filename
option instructs modinfo
to display only the filenames of the modules, while the -a
option ensures that all modules are listed.
Next, let's examine the specifics of a particular module, using ext4
as our example:
sudo modinfo ext4
Example output:
filename: /lib/modules/5.15.0-1023-aws/kernel/fs/ext4/ext4.ko
author: Remy Card, Stephen Tweedie, Andrew Morton, Jakub Jelinek, et al.
description: Fourth Extended Filesystem
license: GPL
alias: fs-ext4
alias: ext4
alias: ext3
alias: ext2
depends: mbcache,jbd2
retpoline: Y
name: ext4
vermagic: 5.15.0-1023-aws SMP mod_unload modversions
parm: abort:behaviour when a metadata write fails (int)
parm: barrier:default barrier usage (int)
parm: dioread_nolock:use delalloc with no lock (int)
parm: max_dir_size_kb:max size of directories (unsigned long)
parm: min_batch_time:min time between delayed allocation attempts (us) (int)
parm: max_batch_time:max time between delayed allocation attempts (us) (int)
This output shows the detailed attributes of the ext4
module, including the filename, author, description, license, aliases, dependencies, and configurable parameters.
By using modinfo
, you can view the information about any installed kernel module on your Linux system. This functionality is critical for troubleshooting kernel module related problems, gaining a better understanding of module behavior, and viewing configuration parameters.
Troubleshooting Module Issues with modinfo on Linux
In this section, we'll focus on employing the modinfo
command for diagnosing and resolving issues related to kernel modules within a Linux environment.
First, let's attempt to load a module that does not exist:
sudo modprobe non_existent_module
Example output:
modprobe: FATAL: Module non_existent_module not found in directory /lib/modules/5.15.0-1023-aws
As shown, the modprobe
command fails when trying to load the non_existent_module
because the module cannot be found.
Now, let's query the modinfo
command for information about the same non-existent module:
sudo modinfo non_existent_module
Example output:
modinfo: ERROR: Module non_existent_module not found.
The modinfo
command returns an error message indicating that the module was not found. This is helpful to confirm the module does not exist in the system.
When encountering problems with a kernel module, modinfo
can be used as a first step to investigate the cause of a failure. For example, if a module fails to load, you can use modinfo
to check the module's dependencies, parameters, and other information to identify potential causes.
Let's try this with a valid module, ext4
:
sudo modinfo ext4
Example output:
filename: /lib/modules/5.15.0-1023-aws/kernel/fs/ext4/ext4.ko
author: Remy Card, Stephen Tweedie, Andrew Morton, Jakub Jelinek, et al.
description: Fourth Extended Filesystem
license: GPL
alias: fs-ext4
alias: ext4
alias: ext3
alias: ext2
depends: mbcache,jbd2
retpoline: Y
name: ext4
vermagic: 5.15.0-1023-aws SMP mod_unload modversions
parm: abort:behaviour when a metadata write fails (int)
parm: barrier:default barrier usage (int)
parm: dioread_nolock:use delalloc with no lock (int)
parm: max_dir_size_kb:max size of directories (unsigned long)
parm: min_batch_time:min time between delayed allocation attempts (us) (int)
parm: max_batch_time:max time between delayed allocation attempts (us) (int)
The output provides critical information about the ext4
module, like dependencies and configurable parameters. This is invaluable for troubleshooting.
Summary
In this tutorial, we explored the Linux modinfo
command, which is instrumental in displaying detailed information about kernel modules. We covered how to use modinfo
to gather specific information about a kernel module, including its filename, author, description, license, aliases, dependencies, and tunable parameters. This is valuable for both troubleshooting and understanding module function. We also investigated how to apply modinfo
for diagnosing module-related issues through analysis of module information.