insmod
Insert modules into the Linux kernel
TLDR
Insert a kernel module into the Linux kernel
SYNOPSIS
insmod [options] module [module_parameters...]
PARAMETERS
-f, --force
Loads the module even if it fails integrity verification, is tainted, or was built for a different kernel version. Use with extreme caution as this can lead to system instability.
-v, --verbose
Prints detailed messages to syslog during module insertion, providing more information about the loading process.
-q, --quiet
Suppresses all non-critical error messages and warnings. Useful for scripting where only the command's exit code is checked.
-L, --lock
Acquires an exclusive lock during the module insertion process. This is mainly used by higher-level utilities to prevent race conditions.
module
The full path to the kernel module file (e.g., /lib/modules/$(uname -r)/kernel/drivers/net/ethernet/intel/e1000/e1000.ko). Unlike modprobe, insmod does not search default module paths.
module_parameters
Optional parameters passed to the module during loading, typically in the format param=value. Multiple parameters can be provided space-separated.
DESCRIPTION
insmod is a low-level utility used to load a specified kernel module into the Linux kernel. Unlike modprobe, insmod does not resolve dependencies or handle module aliases; it requires the exact path to the .ko (kernel object) file.
It's typically used by system administrators or during development to test new modules or load specific modules directly without the overhead of dependency resolution. When insmod loads a module, the module's code and data are integrated into the kernel's address space, making its functionalities available to the system.
It's a fundamental tool for managing kernel functionalities, but for general system operation, modprobe is often the preferred choice due to its advanced features. Using insmod requires root privileges and careful attention, as loading an unstable or incompatible module can lead to system instability or crashes.
CAVEATS
insmod is a low-level tool. It does not resolve module dependencies; if a module requires another, you must load the dependencies manually beforehand. It also does not handle module aliases, so you must provide the exact path to the module file. For general use, modprobe is recommended as it automates dependency resolution and alias handling.
Loading an unstable or incorrectly compiled module can lead to kernel panics or system instability. Always ensure the module is compatible with your kernel version. Root privileges are required to use insmod.
MODULE PARAMETERS
Many kernel modules accept parameters to modify their behavior at load time. These are passed directly after the module path, for example: insmod mymodule.ko myparam=value anotherparam=1. You can inspect a module's supported parameters and their descriptions using the modinfo -p
ERROR HANDLING
If insmod fails, it typically prints an error message to stderr and returns a non-zero exit code. Common failures include an incorrect module path, missing dependencies (which insmod won't resolve), an incompatible kernel version, or permission issues. Checking dmesg or syslog often provides more detailed error information.
SECURITY CONSIDERATIONS
Loading arbitrary kernel modules can introduce significant security risks, as kernel modules run in a highly privileged context within the kernel itself. A malicious or poorly written module can compromise system integrity, stability, and security. Always only load modules from trusted sources and ensure they are necessary for your system's operation.
HISTORY
insmod has been a fundamental part of Linux's module management utilities since early kernel versions. It is part of the module-init-tools (or kmod on newer systems) package, which provides various utilities for loading, unloading, and managing kernel modules. Its role remains largely unchanged as a direct interface for module loading, even as higher-level tools like modprobe gained prominence for handling complex module interactions and dependencies, automating dependency resolution and alias handling.