Howdo I tell which kernel modules are required?

make localmodconfig and make 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:

apt-get install discover
discover --data-path=linux/module/name|sort|uniq

For my amd dual core desktop with an nvidia chipset I get:

amd74xx
emu10k1
emu10k1-gp
forcedeth
i2c-nforce2
ohci1394
sata_nv

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:

lspci -v

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:

dmesg | less

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:

[theman@work]# hwd -s
HARDWARE DETECT ver 5.5 (simple mode)
Kernel     : 2.6.29-ARCH
CPU & Cache: Processor 0: Intel(R) Pentium(R) Dual  CPU  E2200  @ 2.20GHz 2194MHz, 1024 KB Cache
Processor 1: Intel(R) Pentium(R) Dual  CPU  E2200  @ 2.20GHz 2194MHz, 1024 KB Cache

Sound(a)   : 82801G ICH7 Family High Definition Audio Controller module: snd-hda-intel 
Video      : GeForce 8400 GS server: Xorg (vesa)  
Driver     : xf86-video-vesa   module: - 
Monitor    : Generic Monitor  H: 28.0-96.0kHz V: 50.0-75.0Hz
Mouse      : Logitech, Inc. Marble Mouse (4-button)  xtype: IMPS2 device: /dev/input/mice
HDD        : 82801GB/GR/GH ICH7 Family SATA IDE Controller module: ata_piix 
USB        : 82801G ICH7 Family USB UHCI Controller #4 module: uhci_hcd 
USB2       : 82801G ICH7 Family USB2 EHCI Controller module: ehci_hcd 

Ethernet   : RTL8139/8139C/8139C+ module: 8139too 
Network    : No wireless card

Menu       : Main menu: hwd
All        : Detect all hardwares: hwd -e
X sample   : Generate X sample: hwd -x