Optimizing kernel build: How to leave out the not needed kernel modules?

Hi all!

I am a kernel-noob but since I run some Ryzen/Zen2 machines, I use the package aur/linux-amd-znver2 for a year now. I thought, this might be a better solution compared to the generic kernel. Of course, I use some Manjaro kernels as backups.

So I build the kernels pretty often. That is in principle ok for me. But due to the amount of kernel modules, that my machines do not need, I am wondering, how I can optimize the build process, to build only those modules, that are needed.

Is there any tool, that creates statistics of all used kernel modules, so that one can run all generally used applications an devices to get the list of needed kernel modules. Probably, there are some constraints that have to be taken into account.

After one created the list of necessary modules, it is probably possible, to change the build process in the desired way, leaving out the unnecessary modules.

Certainly, I am not the first one, who asks for this. Could someone give me advice, where to start reading or if there are tools, I should look at?

Thank you & kind regards
Peer

1 Like
  1. https://kernel.org
  2. https://kernelnewbies.org/

Run lspci -v on console to check, what devices your computer has.
Then: which filesystems your installation has → must be build into the kernel.
The sound support can be compiled as module.

Also check out the localmodconfig target. It will create a config just with the currently loaded modules.

You can also use modprobed-db

2 Likes

Great, thank you very much! Right now, I am collecting and on the weekendthen I will give localmodconfig a chance :wink:

Kind regards,
Peer

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.