Loading...

Lab 7: Inspect and Load Kernel Modules

Investigate a suspected missing USB storage kernel module by listing loaded modules, inspecting module metadata, loading the module on demand, and validating that it is active. Configure the module to auto-load on boot using /etc/modules-load.d.

troubleshooting boot storage

Scenario

A USB device is not working and may be missing a kernel module. You have been asked to investigate, load the correct module, verify it is active, and configure it to load on every boot.

Operator context

This is how you validate driver availability and turn a one-time fix into a persistent configuration change.

Objective

  • List currently loaded kernel modules.
  • Inspect metadata for a suspected module.
  • Load a module immediately using modprobe.
  • Verify the module is loaded after insertion.
  • Locate the kernel modules directory for this kernel.
  • Configure the module to auto-load on boot.

Concepts

  • lsmod answers “what is loaded right now,” not “what exists on disk.” A module can be present under /lib/modules and still not be loaded.
  • modprobe is preferred over insmod because it resolves dependencies automatically.
  • modinfo is your reality check: file path, description, and aliases help confirm you are loading the right driver.
  • /etc/modules-load.d is for explicit boot-time module loads. Use it when auto-detection is unreliable or intentionally disabled.

Walkthrough

Step 1: List loaded kernel modules.
Command
lsmod

lsmod shows what modules are currently loaded. This helps confirm whether the suspected driver is already present before you load anything.

Example output
Module                  Size  Used by
xhci_pci               20480  0
usbcore               294912  3 xhci_pci,ehci_hcd,usb_common
Step 2: Inspect module metadata for usb_storage.
Command
modinfo usb_storage

modinfo confirms what the module is, where its .ko file lives, and which device classes it matches. This prevents guesswork.

filename:       /lib/modules/5.15.0-88-generic/kernel/drivers/usb/storage/usb-storage.ko
description:    USB Mass Storage driver for Linux
license:        GPL
alias:          usb:v*p*d*dc*dsc*dp*ic08isc06ip50in*
Step 3: Load the module immediately.
Command
sudo modprobe usb_storage

modprobe loads the module and resolves dependencies automatically. Inserting modules is a privileged kernel operation, so sudo is typical.

Step 4: Verify the module is loaded.
Command
lsmod | grep usb_storage

This confirms the module is now present in the loaded module list.

usb_storage           69632  0
Step 5: Locate the modules directory for this kernel version.
Command
ls /lib/modules/5.15.0-88-generic/

This directory contains all modules for a specific kernel. It is useful for confirming whether a module exists on disk even if it is not currently loaded.

kernel/  modules.alias  modules.dep  modules.softdep  updates/
Step 6: Configure auto-load on boot.
Command
echo usb_storage | sudo tee /etc/modules-load.d/usb.conf

Adding the module name to a file under /etc/modules-load.d configures systemd to load it during boot. This turns your fix into persistent behavior.

usb_storage

Common breakpoints

modinfo: ERROR: Module usb_storage not found

The module is not installed for this kernel. Confirm the running kernel with uname -r, then check /lib/modules/$(uname -r). If the directory is missing modules, you may need the correct kernel modules package.

modprobe fails silently or returns non-zero

Check the kernel log for the actual failure reason: dmesg | tail -n 50. Missing dependencies, secure boot policy, or a mismatched kernel/modules set are common causes.

Module loads, but USB storage still does not work

The driver is only one layer. Validate device detection and errors with: dmesg | tail, and confirm the block device appears with lsblk.

Auto-load config does not take effect

Confirm your file exists and contains only the module name: cat /etc/modules-load.d/usb.conf. Also check for a blacklist entry that blocks it: grep -R usb_storage /etc/modprobe.d.

Cleanup checklist

Optional revert

If you do not want this module to auto-load, remove the file: sudo rm -f /etc/modules-load.d/usb.conf and confirm it is gone: ls /etc/modules-load.d.

Success signal

usb_storage appears in lsmod after loading, and your boot-time config file contains the expected module name.

Reference

  • lsmod: Lists modules currently loaded in the kernel.
  • modinfo <module>: Displays module metadata.
  • modprobe <module>: Loads a module and resolves dependencies automatically.
  • /lib/modules/<kernel-version>: Installed module tree for that kernel.
  • /etc/modules-load.d/*.conf: Modules that should be loaded during boot.
  • tee: Writes stdin to a file (useful with sudo).