Skip to content

Linux: Device Management

Kernel Module Management

Kernel modules allows the extension of a linux system. Linux allows adding and removing kernel modules.

insmod is used to manually install module into the kernel.

modprobe is used to install module with their dependencies.

rmmod is used to remove a module.

insmod

insmod requires the full path of the .ko file. It does not resolve dependencies so user is required to make sure that all the dependencies are already present in the system before using insnod to install a module. Ex: insmod /lib/modules/$(uname -r)/extra/custom_module.ko used to install custom_module.ko into the kernel located in /lib/modules/$(uname -r)/extra/ directory. $(uname -r) is used to retrieve the kernel current version. insmod is recommended for specific situation since it does not resolve dependencies.

modprobe

modprobe manages kernel modules and automatically handle dependency resolution. It requires only the module name unlike insmod which requires the full path of the module.

Use modprobe <module_name> to load a module in the kernel.

modprobe support multiple options.

  • -a allows loading multiple modules at once
  • -r removes a module and its dependencies
  • -f to force-load a module
  • -n to perform a dry-run to see eventual events if the module is to be loaded
  • -v to enable verbose mode

rmmod

Allows the removal of kernel modules. It does not check for dependencies. So, if a module is a dependency, rmmod will still remove it without warning. It must be used only if necessary. modprobe -r is convenient for safely removing modules.