Best way to configure Linux kernel for a machine

Valdis.Kletnieks at Valdis.Kletnieks at
Thu Jan 17 13:44:49 EST 2013

On Wed, 16 Jan 2013 17:47:08 +0530, Shraddha Kamat said:
> I normally do the kernel configuration on my machine like this -
> * copy the distro configuration file  to the kernel dir
> * make menuconfig (answer Y's/N's/M's) Normally keep return key pressed
> for default answers
> * then do the actual kernel compilation
> Now, I know that this is not a clean way to do the kernel compilation
> (although it has worked for me for thousands of times that I have
> compiled and successfully booted up with the kernel - without any issues
> - whatsoever !)
> But this time , I am bent upon coming up with a configuration
> specifically targeted to my machine. What is the best way to do this ?

Take your distro kernel, boot it up.  Make sure to insert any USB storage,
webcams, etc, at least long enough for udev to recognize them and load
their driver modules.

Then cd to your kernel source tree and 'make localmodconfig'.

That will build a stripped-down kernel that only builds those modules that
are currently listed in 'lsmod' (which on my laptop is on the order of
1/3 the size of the full Fedora 'allmodconfig').  Which is why it's important
you get all the modules probed - if you don't plug in that USB storage,
the module won't be loaded, so it won't be in lsmod, and won't be included
in your new kernel - at which point you'll use some bad language as you
try to debug why it doesn't work. :)

Also, see the other reply that points at Greg HK's talk.

> Also, while creating a initrd image
> # mkinitrd /boot/initramfs.img 3.8.0-rc3+ -f
> ERROR: modinfo: could not find module ipt_MASQUERADE
> ERROR: modinfo: could not find module iptable_nat
> ERROR: modinfo: could not find module nf_nat
> ERROR: modinfo: could not find module snd_hda_codec_intelhdmi
> ERROR: modinfo: could not find module joydev
> I got the above errors - I know how to resolve these errors , but want
> to understand why in the first place mkinitrd should complain in the
> first place ??

Because if the module was for your keyboard or hard drive or video,
and you got an unbootable kernel as a result, you *really* want to
know at mkinitrd time, not at boot time... :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : 

More information about the Kernelnewbies mailing list