Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Kernel Modules

Linux systems store device drivers as so called Kernel modules which usually are stored in /lib/modules/. The modules stored here are either loaded or unloaded into the kernel to provide functionalities to system devices. Kernel modules are loaded by default when the system boots up but, you can later load them manually.

lsmod Command can be used to view the currently loaded kernel modules:

Kernel modules

Kernel modules

As seen from the output of the lsmod command, a kernel module can be used by another module and/or process or not used at all (0 values stands for not used).

If you don’t know a module’s purpose you can search the internet for it or use the modinfo command to view more details about it:

Modinfo

Modinfo

If the Linux kernel has the auto module loading feature enabled then you don’t need to worry about loading kernel modules but, if you want to load a module manually, read the following section.

Modules can be loaded into the kernel using one of the following commands:

insmod – loads a single module into the kernel. This command will not load any module dependencies so those should be loaded before performing this operation.

modprobe – loads a kernel module and all its dependencies.

With insmod you need to specify the full path of the module, with modprobe command this is not needed.

Just add the kernel module name and modprobe will load it and all its dependencies:

Load kernel modules

Load kernel modules

Modprobe command will actually execute multiple instances of the insmod command to load all dependencies. You can use the -v (verbose) parameter to check out its operation:

[[email protected] /]# modprobe -v bluetooth
insmod /lib/modules/2.6.32-573.3.1.el6.x86_64/kernel/net/rfkill/rfkill.ko
insmod /lib/modules/2.6.32-573.3.1.el6.x86_64/kernel/net/bluetooth/bluetooth.ko
[[email protected] /]#

Configuration files for modprobe are stored under /etc/modprobe.d/ or /etc/modprobe.conf. Other useful parameters for this command are:

-r – removes a kernel module and all its dependencies

-n – executes a dry-run to check out if all requirements are met but does not actually load the kernel module

-l – list all loadable modules

–show-depends – can be used to display all module dependencies

[[email protected] /]# modprobe –show-depends bluetooth
insmod /lib/modules/2.6.32-573.3.1.el6.x86_64/kernel/net/rfkill/rfkill.ko
insmod /lib/modules/2.6.32-573.3.1.el6.x86_64/kernel/net/bluetooth/bluetooth.ko

For other parameters available with these two commands check out their man pages.

To remove a loaded kernel module, use the rmmod command as seen in the following example:

[[email protected] /]# modprobe bluetooth
[[email protected] /]# lsmod | grep bluetooth
bluetooth 97895 0
rfkill 19255 1 bluetooth
[[email protected] /]# rmmod bluetooth
[[email protected] /]# lsmod | grep bluetooth
[[email protected] /]#

The command can also be used with one of the following commands:

-f – force module removal

-w – wait until the module becomes unused

-v – verbose

Note that rmmod will unload one specific kernel module. If you want to unload a kernel module and all its dependencies, use the modprobe command as described earlier.




This post first appeared on ITtrainingday | It's All About IT And Much More…, please read the originial post: here

Share the post

Kernel Modules

×

Subscribe to Ittrainingday | It's All About It And Much More…

Get updates delivered right to your inbox!

Thank you for your subscription

×