When we install Linux Like operating system at that time Linux kernel install most of device driver’s modules and after the installation it also allows us to install new device drivers as modules using the commands modprobe and insmod.

Normally kernel modules are loaded automatically but sometimes you need to install the additional modules as being manual . For instance you want to install device drivers of storage device and etc. For this there are some commands some of them are listed below.

  1. lsmod command

lsmod stand for “list module“. This command is showing currently loading modules on system and also is easy usable command.

[root@babak~]# lsmod

mod-1

If you want to find a specific module. This can be network driver module (e1000) then you can do via grep command.

[root@babak ~]# lsmod | grep e1000

mod-2

2. Modinfo Command

modinfo stand for “module information”. This command is showing information about a kernel module. For instance you want to learn about network driver module:

[root@babak ~]# modinfo e1000

mod-3

Output of modinfo command clearly show version of this module, description which is showing the manufacture factory, license is GPL and other important information.

3. modprobe command is used to add and remove module from the kernel. Linux maintains kernel module directory under ‘/lib/modules/’uname -r’/kernel/drivers/‘ and configuration files(except for additional configuration file in /etc/modprobe.d/). If we want to look at kernel drivers then run the beneath command.

 [root@babak ~]# ls /lib/modules/3.10.0-327.18.2.el7.x86_64/kernel/drivers/

mod-4

If we need to add  i8k kernel module which this module is using for “accessing SMM BIOS on Dell laptops”

[root@babak ~]# modprobe i8k

if output of this command is being any error,  then you can use –quite options that with this flag modprobe won’t print error messages.

Note:You also can use insmod command for adding new module

-r option in modprobe command is used to remove a kernel module. Let’s assume we want to remove the floppy module.

[root@babak ~]# modprobe -r floppy

4. Remove kernel module

-r option in modprobe command is used to remove a kernel module. Let’s assume we want to remove the floppy module.

[root@babak ~]# modprobe -r floppy   

There we remove floppy module from kernel after that you type

 [root@babak ~]# lsmod | grep floppy

You see nothing. If you want to add this module again you can type

[root@babak ~]# modprobe floppy

At some point of time we may get issues while loading the modules or modules not loaded properly. To overcome these errors we can add or load modules forcefully using –force’ option (-f) in the modprobe command.

[root@babak ~]# modprobe –f floppy

If we still face problems or errors while loading the modules, then this time we must do debugging.By enabling debugging we can find exact error or issue before or after installing the modules. In other words debugging is equivalent of dry-run of loading modules.‘-n’ option in the modprobe command can enable this type of debugging. This option will force modprobe command to perform all module loading steps except the final one.

 [root@babak ~]#  modprobe –vn ‘module_name’

We can also see dependency of the module with using ‘–show-depends‘ in the modprobe command, example is shown below

[root@babak ~]# modprobe –show-depends e1000

That’s all for this article. I hope you got an idea how to list, install and remove kernel module in Linux.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here