Good and quick kernel configuration creation
by Thorsten Leemhuis
Using the make target "localmodconfig" saves time and effort when creating a configuration for a custom Linux kernel.
Linux distributions' universal kernels are a good choice for most systems. However, it is sometimes necessary to compile a custom kernel when testing new drivers or tracking down bugs. Building the appropriate configuration file from scratch can be time consuming and prone to errors. This can usually be avoided by using the distribution kernel's configuration file as a starting point – these typically have most drivers enabled for compilation as modules, which can take a long time and is unnecessary, as often only a few of them are relevant for the specific system.
Introduced with Linux 2.6.32 and mainly developed by Steven Rostedt, the localmodconfig
make target can be used to provide a way around this problem. It takes the distribution kernel's basic configuration file and disables the configuration entries for modules that are not required by the system in question; the rest of the config file remains unchanged.
Within seconds, the make target generates a configuration file that is well tailored to the user's specific hardware and Linux distribution, and that will cause the compiler to touch only what will most likely be needed. A system with an Intel Core i5-750 processor compiled such a configuration in under five-and-a-half minutes, completing the task about ten minutes sooner than when using the distribution kernel's own config file.
Tailor-made
Localmodconfig usually finds the distribution kernel's basic configuration file automatically because all major distributions store it as
/boot/config-$(uname -r)
If another file is to be used as a starting point, copy it as ".config" to the top level directory of the decompressed kernel sources.
Before launching the makefile target for configuration, you should plug in and turn on all USB, FireWire and similar devices. This will make the active kernel load the appropriate modules and will allow localmodconfig
to leave the configuration entries for these drivers untouched; all other options that were set to "=m" (module) will be disabled. Even the driver that is required for USB storage devices could be turned off if it was not present at the time of the make call because no USB storage devices were connected.
The following command creates the custom configuration:
make localmodconfig
Similar to the oldconfig
make target, after disabling all unneeded drivers, the program will ask for any options that aren't yet set. If you don't want to waste time with that, you can press the enter key to accept each question's suggested answer – in most cases, these settings are appropriate. To further modify the parameters set by localmodconfig in the configuration file, launch one of the regular configuration programs after your make call – for instance via the menuconfig
or xconfig
make targets.
Next: Compilation & localyesconfig