Jay Taylor's notes
back to listing indexHowto: Linux Add or Remove a Linux Kernel Modules / Drivers
[web search]Howto: Linux Add or Remove a Linux Kernel Modules / Drivers
by nixCraft on January 24, 2007 · 18 comments· LAST UPDATED May 16, 2013
Linux systems comes with the modprobe command, to add and remove modules from the Linux Kernel. Please note that:
=> Under MS-Windows you use term device driver for modules.
=> Under Linux you use term modules for device drivers.
Tutorial details | |
---|---|
Difficulty | Advanced (rss) |
Root privileges | Yes |
Requirements | modprobe/lsmod/modinfo utilities |
Estimated completion time | N/A |
=> At boot time, only a minimal resident kernel is loaded into memory.
=> If you add new hardware you need to add driver i.e. modules.
=> The modprobe command intelligently adds or removes a module from the Linux kernel
=> Usually, all Linux kernel modules (drivers) are stored in the module directory located that /lib/modules/$(uname -r) directory. To see current modules, type:
$ ls /lib/modules/$(uname -r)
Output:
build modules.ccwmap modules.order initrd modules.dep modules.pcimap kernel modules.dep.bin modules.seriomap misc modules.devname modules.softdep modules.alias modules.ieee1394map modules.symbols modules.alias.bin modules.inputmap modules.symbols.bin modules.builtin modules.isapnpmap modules.usbmap modules.builtin.bin modules.ofmap updates
Use the following command to list all drivers for various devices:
$ ls /lib/modules/$(uname -r)/kernel/drivers/
Sample outputs:
# modprobe foo
In this example, I am loading a module called i8k, enter:
# modprobe -v i8k
Sample outputs:
insmod /lib/modules/3.5.0-30-generic/kernel/drivers/char/i8k.ko
Find out info about loaded module
You need to use the modinfo command to see information about a Linux Kernel module. The syntax is:
# modinfo -v {module-name-here}
# modinfo i8k
Sample outputs:
# lsmod
Sample outputs:
Module Size Used by smbfs 75465 0 md5 5953 1 ipv6 284193 10 ipt_TOS 4033 2 iptable_mangle 4545 1 ip_conntrack_ftp 74801 0 ip_conntrack_irc 74033 0 ipt_REJECT 8897 43 ipt_LOG 8513 2 ipt_limit 4033 6 iptable_filter 4673 1 ipt_multiport 3521 4 ipt_state 3393 16 ip_conntrack 54297 3 ip_conntrack_ftp,ip_conntrack_irc,ipt_state ip_tables 21825 8 ipt_TOS,iptable_mangle,ipt_REJECT,ipt_LOG,ipt_limit,iptable_filter,ipt_multiport,ipt_state i2c_dev 13889 0 i2c_core 28865 1 i2c_dev dm_mirror 32721 0 dm_mod 68609 1 dm_mirror button 9313 0 battery 11465 0 ac 6985 0 ohci_hcd 24529 0 ehci_hcd 33989 0 tg3 109381 0 floppy 66065 0 ext3 137937 2 jbd 69105 1 ext3 sata_svw 10053 3 libata 78345 1 sata_svw sd_mod 19393 4 scsi_mod 141457 2 libata,sd_mod
Task: Remove a module called foo
Pass the -r option to modprobe command to remove a module, type:
# modprobe -r foo
You can also use the rmmod command, which is simple program to remove a module from the Linux Kernel:
# rmmod foo
Recommended readings
- man pages - modinfo, lsmod, insmod, and modprobe
If you would like to be kept up to date with our posts, you can follow us on Twitter, Facebook, Google+, or even by subscribing to our RSS Feed.
Featured Articles:- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012