Managing Hardware and Kernel Modules with Linux

Hardware and Modules

An important part of managing any Linux server is to know how to display your current hardware and modules that are currently loaded into your kernel. Thankfully there are some commands that can be used to display this information.

Listing hardware information

A commonly used command to list information regarding your hardware is the "lsdev" command. The "lsdev" command is used to display your systems interrupt addresses and I/O ports. Information is also displayed for IRQ and DMA channel information.

lsdev

To display information about your installed hardware you simply issue the "lsdev" command. There are no parameters or arguments that can be passed to this command. The below example was taken from a Linux Mint system.


# lsdev
Device            DMA   IRQ  I/O Ports
------------------------------------------------
0000:05:00.0                         f000-f0ff
0000:07:00.0                     e000-e07f
ACPI                             0800-0803     0804-0805     0808-080b     0810-0815     0820-0827
acpi                      9 
aerdrv                26 27 28 30 
ahci[0000:01:00.1]         39 
ahci[0000:09:00.2]         41 
AMD-Vi                   25 
cascade             4       
ccp-1                    48 
dma                            0080-008f
dma1                           0000-001f
dma2                           00c0-00df
enp5s0                   42 
fpu                            00f0-00ff
keyboard                       0060-0060   0064-0064
nvidia                   53 
PCI                          0000-03af 03b0-03df 03e0-0cf7 0cf8-0cff 0d00-ffff   e000-efff   f000-ffff     f000-ffff       f000-ffff
pic1                           0020-0021
pic2                           00a0-00a1

The information displayed from the "lsdev" command retrieves information from the "/proc" directories:

IRQ channels : /proc/interrupts

I/O memory addresses : /proc/ioports

DMA channels : /proc/dma

lspci

The "lspci" command is used to display information about PCI buses in the system and devices connected to them. Below are some of the options that can be passwd to the "lspci" command:


Basic display modes

       -m     Dump PCI device data in a backward-compatible machine readable form.  See below for details.

       -mm    Dump PCI device data in a machine readable form for easy parsing by scripts.  See below for details.

       -t     Show a tree-like diagram containing all buses, bridges, devices and connections between them.


Display options

       -v     Be verbose and display detailed information about all devices.

       -vv    Be very verbose and display more details. This level includes everything deemed useful.

       -vvv   Be  even more verbose and display everything we are able to parse, even if it doesn't look interesting at 
              all (e.g., undefined memory regions).

       -k     Show kernel drivers handling each device and also kernel modules capable of handling it.  Turned on  
              by  default  when  -v  is given in the normal mode of output.  (Currently works only on Linux with 
              kernel 2.6 or newer.)

       -x     Show hexadecimal dump of the standard part of the configuration space (the first 64 bytes or 128 bytes 
              for CardBus bridges).

       -xxx   Show hexadecimal dump of the whole PCI configuration space. It is available only to root as several 
              PCI devices crash when you try to read some parts of the config space (this behaviour probably doesn't 
              violate the PCI standard, but it's  at  least  very stupid). However, such devices are rare, so 
              you needn't worry much.

       -xxxx  Show hexadecimal dump of the extended (4096-byte) PCI configuration space available on PCI-X 2.0 and 
              PCI Express buses.

       -b     Bus-centric view. Show all IRQ numbers and addresses as seen by the cards on the PCI bus instead of 
              as seen by the kernel.

       -D     Always show PCI domain numbers. By default, lspci suppresses them on machines which have only domain 0.
       -P     Identify PCI devices by path through each bridge, instead of by bus number.

       -PP    Identify PCI devices by path through each bridge, showing the bus number as well as the  de‐
              vice number.

   Options to control resolving ID's to names
       -n     Show PCI vendor and device codes as numbers instead of looking them up in the PCI ID list.

       -nn    Show PCI vendor and device codes as both numbers and names.

       -q     Use  DNS  to query the central PCI ID database if a device is not found in the local pci.ids
              file. If the DNS query succeeds, the result is cached in ~/.pciids-cache and  it  is  recog‐
              nized in subsequent runs even if -q is not given any more. Please use this switch inside au‐
              tomated scripts only with caution to avoid overloading the database servers.

       -qq    Same as -q, but the local cache is reset.

       -Q     Query the central database even for entries which are recognized locally.  Use this  if  you
              suspect that the displayed entry is wrong.

lspci command example

Issuing "lspci" by itself with no parameters will display output in a format similar to the example below:


# lspci
00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Root Complex
00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) I/O Memory Management Unit
00:01.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:01.3 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge
00:02.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:03.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:03.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge
00:04.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:07.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:07.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B
00:08.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 59)
00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge (rev 51)
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 0
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 1
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 2
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 3
00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 4
00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 5
00:18.6 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 6
00:18.7 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 7
01:00.0 USB controller: Advanced Micro Devices, Inc. [AMD] Device 43bc (rev 02)
01:00.1 SATA controller: Advanced Micro Devices, Inc. [AMD] Device 43b8 (rev 02)
01:00.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 43b3 (rev 02)
02:04.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port (rev 02)
02:05.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port (rev 02)
02:06.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port (rev 02)
02:07.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port (rev 02)
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)
07:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)
07:00.1 Audio device: NVIDIA Corporation GP104 High Definition Audio Controller (rev a1)
08:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Zeppelin/Raven/Raven2 PCIe Dummy Function
08:00.2 Encryption controller: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Platform Security Processor
08:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) USB 3.0 Host Controller
09:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Zeppelin/Renoir PCIe Dummy Function
09:00.2 SATA controller: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] (rev 51)
09:00.3 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) HD Audio Controller

Adding the "-k" option to the "lspci" command will display kernel drivers handling each device:


# lspci -k
00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Root Complex
	Subsystem: ASUSTeK Computer Inc. Family 17h (Models 00h-0fh) Root Complex
00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) I/O Memory Management Unit
	Subsystem: ASUSTeK Computer Inc. Family 17h (Models 00h-0fh) I/O Memory Management Unit
00:01.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:01.3 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge
	Kernel driver in use: pcieport
00:02.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
	DeviceName:  Onboard IGD
00:03.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:03.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) PCIe GPP Bridge
	Kernel driver in use: pcieport
00:04.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:07.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:07.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B
	Kernel driver in use: pcieport
00:08.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-1fh) PCIe Dummy Host Bridge
00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Internal PCIe GPP Bridge 0 to Bus B
	Kernel driver in use: pcieport
00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 59)
	Subsystem: ASUSTeK Computer Inc. FCH SMBus Controller
	Kernel driver in use: piix4_smbus
	Kernel modules: i2c_piix4, sp5100_tco
00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge (rev 51)
	Subsystem: ASUSTeK Computer Inc. FCH LPC Bridge
00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 0
00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 1
00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 2
00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 3
	Kernel driver in use: k10temp
	Kernel modules: k10temp
00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 4
00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 5
00:18.6 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 6
00:18.7 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 7
01:00.0 USB controller: Advanced Micro Devices, Inc. [AMD] Device 43bc (rev 02)
	Subsystem: ASMedia Technology Inc. Device 1142
	Kernel driver in use: xhci_hcd
	Kernel modules: xhci_pci
01:00.1 SATA controller: Advanced Micro Devices, Inc. [AMD] Device 43b8 (rev 02)
	Subsystem: ASMedia Technology Inc. Device 1062
	Kernel driver in use: ahci
	Kernel modules: ahci
01:00.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Device 43b3 (rev 02)
	Kernel driver in use: pcieport
02:04.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port (rev 02)
	Kernel driver in use: pcieport
02:05.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port (rev 02)
	Kernel driver in use: pcieport
02:06.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port (rev 02)
	Kernel driver in use: pcieport
02:07.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] 300 Series Chipset PCIe Port (rev 02)
	Kernel driver in use: pcieport
05:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 15)
	Subsystem: ASUSTeK Computer Inc. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
	Kernel driver in use: r8169
	Kernel modules: r8169
07:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1070] (rev a1)
	Subsystem: ZOTAC International (MCO) Ltd. GP104 [GeForce GTX 1070]
	Kernel driver in use: nvidia
	Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia
07:00.1 Audio device: NVIDIA Corporation GP104 High Definition Audio Controller (rev a1)
	Subsystem: ZOTAC International (MCO) Ltd. GP104 High Definition Audio Controller
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel
08:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Zeppelin/Raven/Raven2 PCIe Dummy Function
	Subsystem: Advanced Micro Devices, Inc. [AMD] Zeppelin/Raven/Raven2 PCIe Dummy Function
08:00.2 Encryption controller: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Platform Security Processor
	Subsystem: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Platform Security Processor
	Kernel driver in use: ccp
	Kernel modules: ccp
08:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) USB 3.0 Host Controller
	Subsystem: ASUSTeK Computer Inc. Family 17h (Models 00h-0fh) USB 3.0 Host Controller
	Kernel driver in use: xhci_hcd
	Kernel modules: xhci_pci
09:00.0 Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Zeppelin/Renoir PCIe Dummy Function
	Subsystem: Advanced Micro Devices, Inc. [AMD] Zeppelin/Renoir PCIe Dummy Function
09:00.2 SATA controller: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] (rev 51)
	Subsystem: ASUSTeK Computer Inc. FCH SATA Controller [AHCI mode]
	Kernel driver in use: ahci
	Kernel modules: ahci
09:00.3 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) HD Audio Controller
	Subsystem: ASUSTeK Computer Inc. Family 17h (Models 00h-0fh) HD Audio Controller
	Kernel driver in use: snd_hda_intel
	Kernel modules: snd_hda_intel

lsusb

The "lsusb" command is used to display usb buses and devices that are connected to them on your system. Below is an example of the "lsusb" command used with the "-t" option. The "-t" option causes the output to be displayed in a tree like hierarchy.


# lsusb
Bus 004 Device 002: ID 1058:25a2 Western Digital Technologies, Inc. Elements 25A2
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 005: ID 06a3:0bac Saitek PLC Pro Flight Yoke
Bus 003 Device 003: ID 06a3:712c Saitek PLC Pro Flight Yoke integrated hub
Bus 003 Device 006: ID ff00:c08b  
Bus 003 Device 004: ID c001:c336  
Bus 003 Device 002: ID 1a86:8072 QinHeng Electronics 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0781:5581 SanDisk Corp. Ultra
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

# lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 3: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 12M
        |__ Port 2: Dev 6, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 2: Dev 6, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 1: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 1: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 4: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 4: Dev 5, If 0, Class=Human Interface Device, Driver=usbhid, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/3p, 10000M
    |__ Port 3: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/9p, 480M


lsusb options


       -v, --verbose
              Tells lsusb to be verbose and display detailed information about
              the  devices shown.  This includes configuration descriptors for
              the device's current speed.  Class descriptors  will  be  shown,
              when  available,  for  USB  device classes including hub, audio,
              HID, communications, and chipcard.

       -s [[bus]:][devnum]
              Show only devices in specified bus and/or devnum.  Both ID's are
              given in decimal and may be omitted.

       -d [vendor]:[product]
              Show  only  devices  with  the  specified vendor and product ID.
              Both ID's are given in hexadecimal.

       -D device
              Do not scan the /dev/bus/usb  directory,  instead  display  only
              information  about  the  device whose device file is given.  The
              device file should be something like /dev/bus/usb/001/001.  This
              option displays detailed information like the v option; you must
              be root to do this.

A list of all known vendors, products, classes, subclasses and protocols can be found in "/usr/share/hwdata/usb.ids" It is always useful to use the "dmesg" command to check that the kernel has recognized your usb device. This can be achieved by issuing the "dmesg | grep -i usb" command. Below is an example of the dmesg command being run shortly after attaching a mobile device via usb connection.


[ 8093.796041] usb 1-4: new high-speed USB device number 4 using ehci_hcd
[ 8093.942460] scsi5 : usb-storage 1-4:1.0
[ 8094.943212] scsi 5:0:0:0: Direct-Access     HTC      Android Phone    0100 PQ: 0 ANSI: 2
[ 8094.948449] sd 5:0:0:0: Attached scsi generic sg6 type 0
[ 8094.953351] sd 5:0:0:0: [sdf] Attached SCSI removable disk
[ 8128.490339] sd 5:0:0:0: [sdf] 3911680 512-byte logical blocks: (2.00 GB/1.86 GiB)

Displaying information about currently loaded Modules

The command used for displaying information about the status of loaded modules in the Linux kernel is the "lsmod" command.

lsmod

Basically "lsmod" is a command that is used to display the output from the "/proc/modules" file. Below is an example of the "lsmod" command in action:

Note: Below is only a small section of the output.


# lsmod
Module                  Size  Used by
vhost_net              28672  1
vhost                  53248  1 vhost_net
tap                    24576  1 vhost_net
vhost_iotlb            16384  1 vhost
xt_CHECKSUM            16384  1
xt_MASQUERADE          20480  3
ip6table_mangle        16384  1
ip6table_nat           16384  1
iptable_mangle         16384  1
iptable_nat            16384  1
nf_nat                 45056  3 ip6table_nat,iptable_nat,xt_MASQUERADE
nf_tables             192512  0
nfnetlink              16384  1 nf_tables
bridge                192512  0
stp                    16384  1 bridge
llc                    16384  2 bridge,stp
nls_iso8859_1          16384  2
nvidia_uvm           1011712  0
nvidia_drm             49152  10
nvidia_modeset       1183744  13 nvidia_drm
snd_hda_codec_realtek   131072  1
nvidia              19771392  596 nvidia_uvm,nvidia_modeset
snd_hda_codec_generic    81920  1 snd_hda_codec_realtek
ledtrig_audio          16384  1 snd_hda_codec_generic

The output from the lsmod command is formatted into three columns:

Module: Module Name

Size: Size of the Module

Used by: The dependent module that is using it.

To display information regarding a specific module we can pipe the output of the "lsmod" command into "grep":

"lsmod | grep vhost"


# lsmod | grep -i vhost
vhost_net              28672  1
vhost                  53248  1 vhost_net
tap                    24576  1 vhost_net
vhost_iotlb            16384  1 vhost

Working with Modules

Modules are simply code that can be loaded and unloaded into the kernel. Modules allow the functionality of the kernel to be extended without the need for a system re-boot. A good example of a module is one that is used for a device driver. Device drivers allow the kernel to access hardware connected to the system. Typically when working with modules, you will use commands such as "lsmod", "modinfo", "modprobe", "insmod" and "rmmod". These commands are generally used for displaying, loading and unloading modules.

insmod

"insmod" is used for inserting modules into the kernel. The preferred method of inserting modules into the kernel is to use the command "modprobe" as this handles dependencies.

modinfo

Modinfo is used to display information about a Linux Kernel module. "modinfo" extracts information from the Linux Kernel modules given on the command line. If the module name is not a filename, then the "/lib/modules/version" directory is searched.


# modinfo usbcore
filename:       /lib/modules/3.1.10-1.19-default/kernel/drivers/usb/core/usbcore.ko
license:        GPL
srcversion:     9023860545ED738FD260BB4
alias:          usb:v*p*d*dc*dsc*dp*ic09isc*ip*
alias:          usb:v*p*d*dc09dsc*dp*ic*isc*ip*
depends:        
vermagic:       3.1.10-1.19-default SMP mod_unload modversions 586TSC 
parm:           usbfs_snoop:true to log all usbfs traffic (bool)
parm:           authorized_default:Default USB device authorization: 0 is not authorized, 1 is authorized, -1 is authorized except for wireless USB (default, old behaviour (int)
parm:           blinkenlights:true to cycle leds on hubs (bool)
parm:           initial_descriptor_timeout:initial 64-byte descriptor request timeout in milliseconds (default 5000 - 5.0 seconds) (int)
parm:           old_scheme_first:start with the old device initialization scheme (bool)
parm:           use_both_schemes:try the other device initialization scheme if the first one fails (bool)
parm:           autosuspend:default autosuspend delay (int)
parm:           nousb:bool

modprobe

Modprobe is a command that is used to load a module into the Linux Kernel or remove a module from the Linux kernel. Modprobe is a wrapper around the insmod command. Modprobe is the preferred method of loading a module into the kernel because it is capable of handling dependencies. Modprobe also has the capability of removing modules with the "-r" option. Below is an example of modprobe removing and loading a module into the kernel:

The following example will remove the module "parport". First lets use the "lsmod" command to check to see if any other modules are dependant on "parport".


# lsmod
Module                  Size  Used by
ppdev                  17430  0 
parport_pc             36673  0 
parport                40930  2 ppdev,parport_pc

From the above output we can see that the modules "ppdev" and "parport_pc" are dependant on "parport". This means that if we unload the module "parport", then these modules will need to be unloaded too:


# modprobe -r parport_pc 
# modprobe -r ppdev
# modprobe -r parport
# lsmod | grep ppdev
# lsmod | grep parport_pc
# lsmod | grep parport
# modprobe ppdev

# lsmod
Module                  Size  Used by
parport_pc             36673  0 
ppdev                  17430  0 
parport                40930  2 parport_pc,ppdev

In the above, we unloaded the modules parpoprt_pc, ppdev and parport. The lsmod command was then used to verify these modules were no longer loaded. Finally we issued "modprobe ppdev" to reload our modules and any dependencies. Another way to check for dependencies is to look directly at the "modules.dep" file. On this openSUSE system our modules are stored in the following location: "/lib/modules/3.1.10-1.19-default". Dependencies are handled by modprobe by looking at the "modules.dep" file:


# grep ppdev modules.dep
kernel/drivers/char/ppdev.ko: kernel/drivers/parport/parport.ko

Modprobe Options


OPTIONS
       -a --all
              Insert all module names on the command line.

       -b --use-blacklist
              This option causes modprobe to apply the blacklist commands in the configuration files 
              (if  any)  to  module names as well.  It is usually used by udev(7).

       -C --config
              This option overrides the default configuration directory/file (/etc/modprobe.d or 
              /etc/modprobe.conf).

              This  option is passed through install or remove commands to other modprobe commands 
              in the MODPROBE_OPTIONS environment variable.

       -c --showconfig
              Dump out the effective configuration from the config directory and exit.

       --dump-modversions
              Print out a list of module versioning information required by a module. This option is 
              commonly used by distributions in order to package up a Linux kernel module using module 
              versioning deps.

       -d --dirname
              Directory where modules can be found, /lib/modules/RELEASE by default.

       --first-time
              Normally,  modprobe  will succeed (and do nothing) if told to insert a module which is 
              already present or to remove a module which isn't present.  This is ideal for simple 
              scripts; however,  more  complicated  scripts often  want  to know whether modprobe 
              really did something: this option makes modprobe fail in the case that it actually 
              didn't do anything.

       --force-vermagic
              Every module contains a small string containing important information, such as the 
              kernel and compiler  versions.  If  a module fails to load and the kernel complains that 
              the "version magic" doesn't match, you can use this option to remove it.  Naturally, 
              this check is there for your protection, so this using  option  is dangerous unless you 
              know what you're doing.

              This  applies  to  any  modules  inserted: both the module (or alias) on the command line 
              and any modules on which it depends.

       --force-modversion
              When modules are compiled with CONFIG_MODVERSIONS set, a section detailing the versions of 
              every  interfaced used by (or supplied by) the module is created.  If a module fails to 
              load and the kernel complains that the module disagrees about a version of some interface, 
              you can use "--force-modversion" to remove  the  version information altogether.  
              Naturally, this check is there for your protection, so using this option is dangerous 
              unless you know what you're doing.

              This applies any modules inserted: both the module (or alias) on the command line and any 
              modules  on  which it depends.

       -f --force
              Try  to strip any versioning information from the module which might otherwise stop it from 
              loading: this is the same as using both --force-vermagic and --force-modversion.  Naturally, 
              these checks are there for  your protection, so using this option is dangerous unless you 
              know what you are doing.

              This  applies  to any modules inserted: both the module (or alias) on the command line and 
              any modules it on which it depends.

       -i --ignore-install --ignore-remove
              This option causes modprobe to ignore install and remove commands in the configuration file 
              (if any) for the module  specified  on  the command line (any dependent modules are still 
              subject to commands set for them in the configuration file). Both install and remove commands 
              will currently be ignored when this option is used regardless  of  whether  the  request  was  
              more  specifically made with only one or other (and not both) of --ignore-install or 
              --ignore-remove.  See modprobe.conf(5).

       -l --list
              List all modules matching the given wildcard (or "*" if no wildcard is given).  This option 
              is provided  for backwards  compatibility and may go away in future: see find(1) and 
              basename(1) for a more flexible alternative.

       -n --dry-run --show
              This option does everything but actually insert or delete the modules (or run the  install  
              or  remove  commands).   Combined  with  -v, it is useful for debugging problems. For 
              historical reasons both --dry-run and --show actually mean the same thing and are interchangeable.

       -q --quiet
              With this flag, modprobe won't print an error message if you try to remove or insert a module 
              it can't  find (and  isn't an alias or install/remove command).  However, it will still return 
              with a non-zero exit status.  The kernel uses this to opportunistically probe for modules 
              which might exist using request_module.

       -R --resolve-alias
              Print all module names matching an alias. This can be useful for debugging module alias problems.

       -r --remove
              This option causes modprobe to remove rather than insert a module.  If the modules it depends  
              on  are  also unused,  modprobe  will  try to remove them too.  Unlike insertion, more than 
              one module can be specified on the command line (it does not make sense to specify module 
              parameters when removing modules).

              There is usually no reason to remove modules, but some buggy modules require it.  Your  
              distribution  kernel may not have been built to support removal of modules at all.

       -S --set-version
              Set  the kernel version, rather than using uname(2) to decide on the kernel version 
              (which dictates where to find the modules).

       --show-depends
              List the dependencies of a module (or alias), including the module itself.  This produces a 
              (possibly empty) set of module filenames, one per line, each starting with "insmod" and is 
              typically used by distributions to determine which modules to include when generating 
              initrd/initramfs images.  Install  commands  which  apply are  shown prefixed by "install".  
              It does not run any of the install commands.  Note that modinfo(8) can be
              used to extract dependencies of a module from the module itself, but knows nothing  of  
              aliases  or  install commands.

       -s --syslog
              This  option  causes  any  error  messages  to  go  through  the  syslog mechanism 
              (as LOG_DAEMON with level LOG_NOTICE) rather than to standard error.  This is also automatically 
              enabled when stderr is unavailable.

              This option is passed through install or remove commands to other modprobe commands in the  
              MODPROBE_OPTIONS environment variable.

       -t --type
              Restrict  -l  to  modules  in directories matching the dirname given.  This option is provided 
              for backwards compatibility and may go away in future: see find(1) and basename(1) for a more 
              flexible alternative.

       -V --version
              Show version of program and exit.

       -v --verbose
              Print messages about what the program is doing.  Usually modprobe only prints  messages  if  
              something  goes wrong.

              This  option is passed through install or remove commands to other modprobe commands in the 
              MODPROBE_OPTIONS environment variable.

       --allow-unsupported-modules
              Load unsupported modules even if disabled in configuration.