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?
-
Seeing I can't tag stuff on this site yet, please add a "gentoo" tag, otherwise you'll keep getting debian answers. – Kent Fredric May 29 '09 at 10:28
-
that comment you just made is why im considering a switch to *bsd – theman_on_osx Jun 15 '09 at 11:34
9 Answers
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.
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.
- 411
- 3
- 4
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.
- 437
- 7
- 12
-
I believe Gentoo is using portage, which is different from that of debian and debian variants. The command is "emerge" – setzamora May 29 '09 at 10:22
-
You can use "lsmod" to know the kernel modules
- 1,122
- 2
- 22
- 47
-
2this only shows modules currently running, not really useful when trying to trim the fat – theman_on_osx Jun 15 '09 at 11:33
Show drivers/modules in use:
lspci -v
- 1,213
- 8
- 21
-
`lspci -k`, will show you all of your _pci_ hardware, and which modules are being used for that hardware. `emerge sys-apps/pciutils` for lcpci. – James Broadhead Feb 07 '12 at 21:09
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
- 327
- 3
- 8
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.
for i in `find /sys/ -name modalias -exec cat {} \;`; do
/sbin/modprobe --config /dev/null --show-depends $i ;
done | rev | cut -f 1 -d '/' | rev | sort -u
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 ;-)
- 10,269
- 2
- 32
- 47
-
This assumes that modules for the hardware are already available, which makes it of limited use for kernel configuration. Still, that caveat about software kernel requirements is _golden_ – James Broadhead Feb 07 '12 at 21:12
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.
- 161
- 5
-
In portage as sys-apps/hwinfo ; sys-apps/lshw performs similar – James Broadhead Feb 07 '12 at 21:13
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."