Reputation: 24768
Is there a way to list down from command line the complete dependency list of kernel modules loaded in the kernel at runtime?
Let me clarify my question a little bit.
What I am trying to do:
lsmod
modprobe -r
. This step fails (obviously) as some modules are in use.
(I can switch to using rmmod -r
, but don't want to as it is unsafe and can crash the system.)It is step 2 that is failing, as I cannot get all the module dependencies before using modprobe -r
.
Any ideas, suggestions or comments ?
Upvotes: 5
Views: 33945
Reputation: 77339
man lsmod: lsmod is a trivial program which nicely formats the contents of the /proc/modules
, showing what kernel modules are currently loaded.
Edited:
see also: depmod -n
Upvotes: 2
Reputation: 7590
To get a list of module dependencies as would be used by modprobe
(i.e. this should normally be the full list, but see the answer by user502515), use
$ modprobe --show-depends <module>
Note that this command shows more information than modinfo
's depends:
line, as it lists dependencies recursively (i.e. dependencies of dependencies).
It also takes into account alias
commands in modprobe configuration files.
Tested using:
$ modprobe -V
kmod version 14
Upvotes: 6
Reputation: 4454
However lsmod o/p is sometimes incomplete. It also does not always indicate all the modules dependent on a given module.
What you see in lsmod in the "Used by" column are merely the static symbol dependencies that you can also look at using modinfo
.
If however a piece of kernel code takes a reference on a module using (try_)module_get, the caller will not be recorded. References do not have an owner (moduleA could pass the pointer to moduleB, which then module_puts it..), there is nothing to record for the Used by column.
Upvotes: 7