-   Linux - Kernel (
-   -   module dependence (

linuxgentoo 11-08-2007 12:06 AM

module dependence
PHP Code:

root@lynn:/home/lynn# lsmod
Module                  Size  Used by
ipv6                  273892  10 

i want to know which modules dependent on ipv6 module


Simon Bridge 11-08-2007 09:47 AM

You could remove it and see which modules vanish :)

archtoad6 11-08-2007 06:50 PM

I think:

lsmod  | grep [^^]$MOD  | less -S

will give the answer you are looking for. You can omit the "less" at the risk of being confused by folded output lines. You could also/instead pipe it into a column selector that would remove the "(Used) by" modules. E.g., an awk or cut statement.

Notes on lsmod
The man page is, to say the least, sparse. IMNRHO, its brevity sucks. (With all due respect to the author, Rusty Russell, who is legendary for his work on netfilter & iptables.)

It is so bad, I originally thought there is a bug in the headers: column 3 seemed to be the # pages the module uses & col. 4 the list of other modules that use it. seems to support this idea:

Module        Pages    Used by
memory_cs          2            0
ds                2    [memory_cs]    3
i82365            4            2


First column is Module name and second column is size of modules i..e the output format is module name, size, use count, list of referring modules.

At a given time, if a module has "0" in the lsmod "Used" column and either
nothing or (unused) or (autoclean) in the "by" column, there are reasonable
chances that it is unused.
say otherwise.

An explanation of the meaning of the columns in the man page would save countless hours of grief. Changing "by" to "" in the headers wouldn't hurt either.

Why not change

lsmod is a trivial program which nicely formats the contents of the /proc/modules, showing what kernel modules are currently loaded.

lsmod is a trivial program which nicely formats the contents of /proc/modules, showing what kernel modules are currently loaded in a 4 column format:
"Module" - the name of the module
"Size" - the amount of memory it uses
"Used" - its use count
"by" - a "tight" (no spaces) comma separated list of referring modules
Although it only appears once - for brevity in the output - "Used" is to be mentally read twice: i.e. "by" is to be understood as "Used by", that is why it is not capitalized.

I also don't like lsmod's column formatting, esp. col. #3.

lsmod  | awk '{printf "%-21s %6s  %2s %s\n",$1,$2,$3,$4}'

lsmod  \
| sed '1s,by,,'  \
| awk '{printf "%-21s %6s  %2s %s\n",$1,$2,$3,$4}'

would be a good aliases for the current lsmod.

linuxgentoo 11-08-2007 08:44 PM


Originally Posted by Simon Bridge (Post 2952198)
You could remove it and see which modules vanish :)

PHP Code:

localhost lynn # rmmod ipv6
ERRORModule ipv6 is in use 

tthtlc 11-08-2007 09:27 PM

depmod is the command - which generate the modules.dep file, in /lib/modules/xxxx/ directory:

For example:

/lib/modules/2.6.23/kernel/crypto/cbc.ko: /lib/modules/2.6.23/kernel/crypto/blkcipher.ko

From above we know that cbc is depending on blkcipher.ko.

All times are GMT -5. The time now is 10:38 PM.