Short Information about loaded kernel modules
2010-01-24
386 words
2 mins read
There are couple of ways you can find the information on the <a class="zem_slink" title="Loadable kernel module" rel="wikipedia" href="http://en.wikipedia.org/wiki/Loadable_kernel_module">loadable kernel modules. All these would always involve calling <a class="zem_slink" title="Lsmod" rel="wikipedia" href="http://en.wikipedia.org/wiki/Lsmod">lsmod to get the loaded kernel modules and then calling modinfo to get the info on the loaded modules. I will show you with examples:
$ lsmod
Module Size Used by
cdc_acm 19616 0
vfat 8744 9
fat 41836 1 vfat
The above output is for the list of the modules loaded on the kernel.
$ modinfo vfat
filename: /lib/modules/2.6.31.5-127.fc12.i686.PAE/kernel/fs/fat/vfat.ko
author: Gordon Chaffee
description: <a class="zem_slink" title="File Allocation Table" rel="wikipedia" href="http://en.wikipedia.org/wiki/File_Allocation_Table">VFAT <a class="zem_slink" title="File system" rel="wikipedia" href="http://en.wikipedia.org/wiki/File_system">filesystem support
license: <a class="zem_slink" title="GNU General Public License" rel="wikipedia" href="http://en.wikipedia.org/wiki/GNU_General_Public_License">GPL
srcversion: 48F6DF1D674F0E1325466C9
depends: fat
vermagic: 2.6.31.5-127.fc12.i686.PAE SMP mod_unload 686
modinfo will list the filename, authour and other related info for the modules. So if you wanted to get the info for all the modules, then the easiest way would be to do :
lsmod|xargs modinfo
But as you can see, this will list all the info on the module, which is not really required. So there were couple of posts on commandlinefu, that takes care of displaying only the required information, viz. filename, authour and dependency. Here are the commands:
lsmod | sed ’1d’ | cut -d’ ’ -f1 | xargs modinfo | egrep ’^file|^desc|^dep’ | sed -e’/^dep/s/$/\n/g’
Quite raw method where we <a class="zem_slink" title="Grep" rel="wikipedia" href="http://en.wikipedia.org/wiki/Grep">grep the required fields and susbstitute the end with <a class="zem_slink" title="Newline" rel="wikipedia" href="http://en.wikipedia.org/wiki/Newline">newline for the last patter <img style="vertical-align: bottom;" src="http://sc.webmessenger.msn.com/10.1.0323.0/session/images/emoticons/smile_regular.gif" alt=":)" />
lsmod | sed -e ’1d’ -e ’s/\(\([^ ]*\) \)\{1\}.*/\2/’ | xargs modinfo | sed -e ’/^dep/s/$/\n/g’ -e ’/^file/b’ -e ’/^desc/b’ -e ’/^dep/b’ -e d
Quite same as above with only exception of using one sed command rather than egrep and sed.
modinfo $(cut -d’ ’ -f1 /proc/modules) | sed ’/^dep/s/$/\n/; /^file\|^desc\|^dep/!d’
Directly using the modinfo commands without xargs and passing the arguments with cut command and then using sed to display only the required fields.
awk '{print $1}’ ”/proc/modules” | xargs modinfo | awk ’/^(filename|desc|depends)/’
using awk to check the /proc/modules and then displaying the fields with awk<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/e252418c-c6cf-4fd7-8e83-036dc2ce6de7/"><img class="zemanta-pixie-img" style="border: medium none ; float: right;" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_e31.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related pretty-attribution">
Related Articles:
- 2008/10/13 Scratch — Programming for kids
- 2010/01/24 Seders\’s grab bag – Tutorials
- 2010/01/21 Copy temporary evolution images downloaded for messages
- 2010/01/21 sed tutorial and help
- 2010/01/19 Perl script to create csv files with a pattern – Generic script.