Monday, August 16, 2010

Viewing Modules in Ubuntu

The basic command to see what modules are currently loaded is lsmod. Running lsmod displays the LKM’s common name, size of the LKM, and any other LKMs that depend on it. For example:

$ lsmod | head
Module Size Used by
floppy 64676 0
rfcomm 43604 0
l2cap 28192 5 rfcomm
bluetooth 54084 4 rfcomm,l2cap
ppdev 9668 0
speedstep_lib 4580 0
cpufreq_userspace 6496 0
cpufreq_stats 6688 0
freq_table 4928 1 cpufreq_stats

This shows that the bluetooth module is loaded and is in use by the rfcomm and l2cap modules. A second command, modprobe, can be used to show the actual LKM files.

$ modprobe -l bluetooth
/lib/modules/2.6.24-26-generic/kernel/net/bluetooth/bluetooth.ko

The modprobe command can also list available modules-not just ones that are loaded. For example, to see all the asynchronous transfer mode (ATM) network drivers, you can use:

$ modprobe -l -t atm
/lib/modules/2.6.24-26-generic/kernel/drivers/usb/atm/cxacru.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/usb/atm/usbatm.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/usb/atm/speedtch.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/usb/atm/ueagle-atm.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/usb/atm/xusbatm.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/atm/idt77252.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/atm/iphase.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/atm/he.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/atm/atmtcp.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/atm/fore_200e.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/atm/nicstar.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/atm/lanai.ko
/lib/modules/2.6.24-26-generic/kernel/drivers/atm/suni.ko
...

The -t atm parameter shows all modules with the ATM tag. LKMs are stored in an organized directory, so the tag indicates the directory name. This is different from using modprobe -l '*atm*’, since that will only show modules containing ‘‘atm’’ in the LKM file name.

Along with modprobe, you can use modinfo to learn more about a particular LKM. The modinfo command lists information about a module, or it can be used to retrieve specific information. For example:

$ modinfo lp # list information about the lp module
filename: /lib/modules/2.6.31-15-generic/kernel/drivers/char/lp.ko
license: GPL
alias: char-major-6-*
srcversion: 84EA21D13BD2C67171AC994
depends: parport
vermagic: 2.6.31-15-generic SMP mod_unload modversions 586
parm: parport:array of charp
parm: reset:bool

If you only need to see a particular field from the modinfo output, then you can use the -F parameter with any of the listed fields. For example, -F filename only displays the file name for the module.

$ modinfo -F filename lp # only list the filename field
/lib/modules/2.6.31-15-generic/kernel/drivers/char/lp.ko

Source of Information : Wiley Ubuntu Powerful Hacks And Customizations

No comments: