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 for persistence.

troubleshooting boot storage

Scenario

A USB device is not working and may be missing a kernel module. You’ve 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.

What You’ll Practice

  • Discovering loaded modules with lsmod .
  • Inspecting module metadata using modinfo .
  • Loading modules with modprobe and verifying with lsmod | grep .
  • Understanding the modules tree under /lib/modules/<kernel-version> .
  • Persisting module auto-load behavior via /etc/modules-load.d .

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 attempt to 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 hardware patterns it matches. This is how you avoid loading the wrong module by name alone.

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. Using sudo is typical because inserting modules is a privileged kernel operation.

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’s 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

Reference

  • lsmod : Lists modules currently loaded in the kernel.
  • modinfo <module> : Displays module metadata such as file path, description, license, and aliases.
  • modprobe <module> : Loads a module and resolves dependencies automatically.
  • /lib/modules/<kernel-version> : Contains the installed module tree for that kernel.
  • /etc/modules-load.d/*.conf : Files listing modules that should be loaded during boot.
  • tee : Writes stdin to a file, useful with sudo when writing to protected paths.