LKMs are object files containing code that extends the running kernel. They’re commonly used to add support for new hardware, filesystems, NICs, and more. Most often, LKMs serve as device drivers, but they can also be used for other purposes like file systems and firewalls.
To load a kernel module automatically during boot, you can edit the /etc/modules file or create a new config file in /etc/modules-load.d/.
Example: If you want to load the ide-cd and ide-core modules, add these lines to /etc/modules
After editing, reboot your system to test the changes.
Use ls /usr/lib/modules/$(uname -r)/kernel/ to find the location of your Linux kernel device drivers/modules.
To load a module without rebooting, use insmod followed by the module name (e.g., insmod hello.ko).
Example: insmod /lib/modules/4.4.0-21-generic/kernel/drivers/cpufreq/speedstep-lib.ko
To remove a loaded module, use rmmod followed by the module name (e.g., rmmod hello.ko).
$ lsmod
This command will display a nicely formatted output showing the module names, their sizes, and usage information. If you need more details about a specific module, you can also use the modinfo command.
modinfo command in Linux serves the purpose of providing detailed information about a kernel module (loadable kernel object). When you run:
$ modinfo <module_name>
It displays essential details about the specified module, including:
Module name
Author(s)
Description
License
Parameters (if any)
Dependencies
Module version
Firmware (if applicable)
======================================================================
To load a kernel module automatically during boot, you can edit the /etc/modules file or create a new config file in /etc/modules-load.d/.
Example: If you want to load the ide-cd and ide-core modules, add these lines to /etc/modules
Code:
ide-cd
ide-core
After editing, reboot your system to test the changes.
Use ls /usr/lib/modules/$(uname -r)/kernel/ to find the location of your Linux kernel device drivers/modules.
To load a module without rebooting, use insmod followed by the module name (e.g., insmod hello.ko).
Example: insmod /lib/modules/4.4.0-21-generic/kernel/drivers/cpufreq/speedstep-lib.ko
To remove a loaded module, use rmmod followed by the module name (e.g., rmmod hello.ko).
$ lsmod
This command will display a nicely formatted output showing the module names, their sizes, and usage information. If you need more details about a specific module, you can also use the modinfo command.
modinfo command in Linux serves the purpose of providing detailed information about a kernel module (loadable kernel object). When you run:
$ modinfo <module_name>
It displays essential details about the specified module, including:
Module name
Author(s)
Description
License
Parameters (if any)
Dependencies
Module version
Firmware (if applicable)
======================================================================