#StackBounty: #linux-kernel How to get a list of unused kernel modules of currently running system? (Static and loaded)

Bounty: 50

There are a lot of interesting kernel modules. Thanks to the linux kernel, I now know there is such a thing as a “Lego Infrared Tower”.

I’m trying to slim down my linux kernel beyond the point of things I obviously dont need.

To do this, I need a programmatic way to find the unused kernel modules currently in my system.

I know about ‘lsmod’. But that’s very far away from what I’m looking for.

*** The reverse approach – by elimination ***

What I might need to achieve this result is a way to determine which statically compiled and loaded modules currently are in use. These are the ones selected by “*” in the menuconfig and not just “M”

I think i already might a way to “cross out” each of those modules in the .config file of the current kernel, because it is possible to map module names to config names using a grep command as described here:

Binding lsmod module name with kernel configuration menu entry

though I am not sure how consistently that will work.

So what I have already is the .config file and the kernel sources and that grep command from that link above. The bottleneck is the first list of statically-used and loadedly- used kernel modules.

This is perhaps a “best effort” question. It is as difficult to completely clean a kernel as it is to completely clean a bedroom. When my bedroom is clean, there is still some dust here and there. These are the same expectations I would expect for an answer to this question.

With any resulting list, more manual filtering will be needed, because I dont think I am constantly using things like DNS name resolutions, though I do need those intermittently.

But there has to be faster way to clean a kernel than recompiling the kernel every few hours with less and less modules each time. Or is there a more common strategy?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.