Say, I have a default Gentoo install with all the modules (e.g. device drivers) compiled. From this point, is there an easy way to exclude the unused modules the next time I recompile the kernel?
Say, I have a default Gentoo install with all the modules (e.g. device drivers) compiled. From this point, is there an easy way to exclude the unused modules the next time I recompile the kernel?
make localmodconfig
andmake localyesconfig
(introduced in 2.6.32, which was released in December 3, 2009) will select the modules needed to load the modules in use.More info.
Note that this does not take into account modules that were loaded once, but are currently unloaded. ArchLinux has a modprobed_db thing that workarounds this, I don't know whether Gentoo has one as well.
I use the discover package in debian to figure out what kernel modules I could possibly load. Specifically:
For my amd dual core desktop with an nvidia chipset I get:
Here's a short essay on hardware detection in linux, including some text on using discover.
You can use "lsmod" to know the kernel modules
Show drivers/modules in use:
if we were going to get into technicalities, i would say you could just unload those modules, and then you would not need to recompile. However, I think you meant "to include only drivers to my specific hardware". In that case, I would suggest:
look through that and see what hardware details you can extrapolate. Then, when you go to compile the kernel, look through all the components and see if it makes a mention to your hardware. After rebooting, check to make sure all the hardware works.
In archlinux, there is a bash script called
[hwd][1]
, i assume it would work on gentoo (perhaps a bit of hacking required), but it will tell you about what you got under the hood. This is my work computer:There is a shellscript in "Linux Kernel in a nutshell" by GKH, which does this by approximation. The script is freely downloadable from the books website and hasn't got a copyright message, so I assume I can post it here.
The scripts output is a list of module your hardware needs to function. It does not list modules that are needed to make certain software work, like ipv6.so!
@Greg: if you don't want this posted like this, I'll remove it ;-)
One some distributions there's also a nice nifty tool called hwinfo, which gives you lots of useful information about your hardware.
To get more to know about the kernel modules, lspci and lsmod always have done a good job for me.
If you are recompiling the kernel. The best thing to do is to know your hardware well using the method presented by theman_on_osx. List all your components. You just have to uncheck / exclude the modules (that aren't needed) from the menu (i.e. if you are recompiling it via make menuconfig / make xconfig).
You can also unload modules that are loadable on the fly using "rmmod."
lspci should also help you.