High memory usage on Linux servers is a frequent trigger for system instability, leading to application crashes or the dreaded Out Of Memory (OOM) killer terminating critical processes. While developers often suspect application leaks, infrastructure engineers must first rule out hardware-level issues, specifically faulty SCSI controllers or storage drivers that fail to release resources properly. When a kernel module associated with a storage device consumes excessive RAM or causes system hangs, standard monitoring tools like top or htop may only show the symptom, not the root cause. By combining lsscsi to identify active devices and modinfo to inspect module parameters, administrators can pinpoint problematic hardware interfaces and adjust kernel behavior without rebooting or replacing physical components immediately.
This guide walks through a realistic troubleshooting scenario where a junior engineer discovers intermittent latency spikes on a production web server running CentOS Stream 9. The goal is to isolate whether a specific SCSI initiator is causing memory pressure due to buggy driver parameters or resource leaks, providing actionable steps for students and practitioners alike.
Identifying Active SCSI Initiators with lsscsi
The first step in diagnosing storage-related issues is establishing a baseline of what hardware the kernel recognizes. The lsscsi command queries the SCSI subsystem to list all attached devices, their types, and associated drivers. This is crucial because sometimes a “ghost” device or a misconfigured initiator appears active but consumes resources without providing I/O throughput.
To begin, execute the following command in a terminal with root privileges:
lsscsi -i
The -i flag provides detailed information, including the vendor and model of the controller. In our illustrative scenario, the output might look like this:
[1:0:0:0] disk ATA WDC_WD4003FFZ-68L /dev/sda (931G)
[2:0:0:0] tape STK SONY-TS-HD5 /dev/st0 (14G)
[3:0:0:0] sd SCSI HP-SCSI /dev/sdb (100G)
[3:1:0:0] sd SCSI HP-SCSI /dev/sdc (500G)
Notice the third and fourth entries share the same vendor (HP-SCSI). If memory usage is high, it is possible that the driver for this specific controller instance is leaking memory. The output shows the device path (e.g., /dev/sdb), which you will need to cross-reference with process information or module loading logs later.
Inspecting Module Parameters with modinfo
Once a suspicious device or controller is identified, the next step is to inspect the kernel module responsible for it. The modinfo command retrieves metadata about a loaded module, including its parameter settings which can drastically affect memory consumption.
Run the following command to get details on the SCSI host adapter driver:
modinfo scsi_mod -p | grep -A 5 "memory"
# Or specifically for the vendor driver if known:
modinfo hp_swfc -p
In a high-memory scenario, you might discover that certain initialization parameters are set to default values that are inefficient for your specific workload. For example, some drivers allow tuning of cache sizes or request limits. If modinfo returns no specific memory-related parameters, it implies the module uses static allocation or relies on global kernel settings.
Expected Output Example:
filename: /lib/modules/5.14.0-284.el9.x86_64/kernel/drivers/scsi/hp_swfc.ko
version: 3.1.0
description: HP Smart Array Controller Driver
author: HP
date: Thu Mar 21 14:00:00 2024
license: GPL
depends:
retpoline: Y
integrity: SHA256 signed
parm: cache_size:int (default 64)
parm: max_memory_mb:int (default 512)
If the max_memory_mb parameter is set to a low value, it might cause the driver to thrash in memory, attempting to reallocate buffers constantly. Conversely, if it is set too high on a system with limited RAM, it could starve other processes.
Adjusting Kernel Module Parameters Safely
After identifying the problematic parameter via modinfo, you must adjust it carefully. Modifying kernel parameters at runtime requires root access and often involves writing to /proc/sys or using sysctl. However, for SCSI-specific modules, direct parameter passing is usually done via module options in the configuration files rather than runtime sysctl entries.
To apply a fix without rebooting, you can use the modprobe command with new parameters if the driver supports dynamic reloading. Note that many storage drivers do not support hot-unloading and reloading; in those cases, a reboot is required after changing kernel boot arguments.
Create or edit a file to pass parameters at boot:
echo "options hp_swfc max_memory_mb=1024" > /etc/modprobe.d/hp_storage.conf
Important Warning: Do not blindly increase memory limits. If the driver has a bug causing leaks, increasing the limit will only accelerate the exhaustion of system RAM. The correct approach is often to reduce the limit or disable specific features if they are non-essential.
To test the change safely without affecting production data immediately, you can simulate the environment in a lab or use a staging server. If you must apply it live, do so during a maintenance window.
Verifying Memory Stabilization with Monitoring Tools
After applying parameter changes or identifying a faulty module, verification is essential. Simply restarting the service does not confirm that memory usage has stabilized; you must monitor over time. Use standard Linux monitoring tools to observe trends rather than instantaneous snapshots.
Run vmstat (virtual memory statistics) to check swap activity and memory pressure:
vmstat 1 10
Look for the si (swap in) and so (swap out) columns. If these values are consistently non-zero after your changes, the system is still thrashing. Additionally, use free -h to track available memory:
free -h
Illustrative Result:
total used free shared buff/cache available
Mem: 15Gi 8Gi 4Gi 200Mi 3Gi 6Gi
Swap: 2Gi 0B 2Gi
If available memory remains stable and does not drop to near zero, the resolution was successful. For more granular views, enable kernel tracing or use perf to track memory allocations within the SCSI subsystem, though this requires deeper expertise.
Common Errors and Fixes in Storage Module Troubleshooting
Even experienced practitioners encounter pitfalls when diagnosing high memory usage in storage drivers. One common error is attempting to unload a module that is currently in use by an active block device.
Error Message:
modprobe: FATAL: Module hp_swfc is in use.
Fix: You cannot remove the module while devices like /dev/sdb are mounted. The solution is either to unmount the filesystem, stop any services using it (like a database or web server), or accept that a reboot is necessary. Never force-remove modules; this can corrupt file systems.
Another frequent mistake is assuming lsscsi output reflects real-time memory usage. lsscsi only lists devices; it does not show RAM consumption. You must correlate the device list with /proc/meminfo or slabtop to see if specific slab caches (data structures used by the kernel) related to SCSI are bloating.
Student Practice Task: Simulating a Memory Leak Scenario
To reinforce these skills, students can perform a safe simulation in a virtual lab environment using VirtualBox or Docker.
- Setup: Create a VM with CentOS Stream or Ubuntu Server.
- Simulation: Use
modprobeto load a dummy module that consumes memory (if available) or simulate high I/O by running a loop ofddcommands to fill a disk partition. - Diagnosis: Run
lsscsito identify the simulated device. Check/proc/meminfofor increasedSReclaimable. - Resolution: Document the steps taken to unload the module or adjust parameters, ensuring no data loss occurs during the process.
This exercise helps bridge the gap between theoretical knowledge of kernel modules and practical server administration.
Conclusion
Diagnosing high memory usage caused by kernel modules requires a systematic approach that combines device identification with parameter inspection. By using lsscsi to locate active storage controllers and modinfo to analyze their configurations, IT professionals can often resolve resource leaks or inefficiencies without costly hardware replacements. Always verify changes in a controlled environment before applying them to production systems, and remember that storage stability is foundational to the reliability of web servers and databases.
Educational-use notice: This tutorial is for learning and controlled lab use only. Test carefully, use backups, and obtain authorization before making changes. Do not run unfamiliar commands on production systems. We accept no responsibility for misuse, damage, data loss, or production issues.

