Linux modinfo Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to use the Linux modinfo command to explore and troubleshoot kernel modules. The modinfo command provides detailed information about kernel modules, including their filename, author, description, license, dependencies, and configurable parameters. This knowledge can be helpful when troubleshooting issues related to kernel modules or when trying to understand the functionality and configuration options of a specific module.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicFileOperationsGroup(["`Basic File Operations`"]) linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux/BasicFileOperationsGroup -.-> linux/cat("`File Concatenating`") linux/SystemInformationandMonitoringGroup -.-> linux/uname("`System Information Displaying`") subgraph Lab Skills linux/cat -.-> lab-422819{{"`Linux modinfo Command with Practical Examples`"}} linux/uname -.-> lab-422819{{"`Linux modinfo Command with Practical Examples`"}} end

Understand the modinfo Command

In this step, we will explore the Linux modinfo command, which provides detailed information about kernel modules. The modinfo command is a useful tool for understanding and troubleshooting kernel modules.

First, let's check the version of the modinfo command on our Ubuntu 22.04 system:

modinfo --version

Example output:

modinfo version 2.6.32-504.16.2.el6

The modinfo command can be used to display information about a specific kernel module. For example, to get information about the ext4 module, we can run:

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 detailed information about the ext4 module, including the filename, author, description, license, aliases, dependencies, and various parameters that can be configured.

You can use the modinfo command to explore information about any kernel module installed on your system. This can be helpful when troubleshooting issues related to kernel modules or when trying to understand the functionality and configuration options of a specific module.

Explore Module Information Using modinfo

In this step, we will dive deeper into using the modinfo command to explore detailed information about kernel modules.

First, let's list all the kernel modules currently loaded on our 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

The -F filename option tells modinfo to only display the filename of the modules, and the -a option lists all the modules.

Now, let's explore the details of a specific module, such as the ext4 module:

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 provides detailed information about the ext4 module, including the filename, author, description, license, aliases, dependencies, and various parameters that can be configured.

You can use the modinfo command to explore information about any kernel module installed on your system. This can be helpful when troubleshooting issues related to kernel modules or when trying to understand the functionality and configuration options of a specific module.

Troubleshoot Module Issues with modinfo

In this final step, we will learn how to use the modinfo command to troubleshoot issues related to kernel modules.

Let's start by trying to load a module that doesn't 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 you can see, the modprobe command fails to load the non_existent_module because it doesn't exist on the system.

Now, let's try to get more information about this issue using the modinfo command:

sudo modinfo non_existent_module

Example output:

modinfo: ERROR: Module non_existent_module not found.

The modinfo command also fails to find any information about the non_existent_module, confirming that the module doesn't exist on the system.

If you encounter issues with a specific kernel module, you can use the modinfo command to troubleshoot the problem. For example, if a module is not loading correctly, you can use modinfo to check the module's dependencies, parameters, and other relevant information to identify the issue.

Let's try an example with a real module, such as the ext4 module:

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 detailed information about the ext4 module, including its dependencies, parameters, and other relevant details. This information can be useful when troubleshooting issues related to the ext4 module or other kernel modules on your system.

Summary

In this lab, we explored the Linux modinfo command, which provides detailed information about kernel modules. We learned how to use modinfo to understand the characteristics of a specific kernel module, such as its filename, author, description, license, aliases, dependencies, and various configurable parameters. This command can be helpful when troubleshooting issues related to kernel modules or when trying to understand the functionality and configuration options of a specific module. We also explored how to use modinfo to troubleshoot module issues by examining the information it provides.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like