UNIX System Administration Handbook - Evi Nemeth [144]
We recommend make xconfig if you are running X and make menuconfig if you aren’t. Avoid make config.
These tools are straightforward as far as the options you can turn on, but unfortunately they are painful to use if you want to maintain several versions of the kernel for multiple architectures or hardware configurations.
The various configuration interfaces described above all generate a .config file that looks something like this:
# Automatically generated make config: don't edit
#
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y
#
# Processor type and features
#
# CONFIG_M386 is not set
# CONFIG_M486 is not set
# CONFIG_M586 is not set
# CONFIG_M586TSC is not set
CONFIG_M686=y
CONFIG_X86_WP_WORKS_OK=y
CONFIG_X86_INVLPG=y
CONFIG_X86_BSWAP=y
CONFIG_X86_POPAD_OK=y
CONFIG_X86_TSC=y
CONFIG_X86_GOOD_APIC=y
...
As you can see, the contents are rather cryptic and provide no descriptions of what the CONFIG tags mean. Sometimes you can figure out the meaning. Basically, each CONFIG line refers to a specific kernel configuration option. The value y compiles the option into the kernel; m enables it, but as a module.
Some things can be configured as modules and some can’t. You just have to know which is which; it’s not clear from the .config file. There is also no easy mapping of the CONFIG tags to meaningful information. However, you can usually extract this information from the Config.in file located in each driver directory. The Config.in files are difficult and inconvenient to track down, so it’s best to just use make xconfig or make menuconfig.
Once you have a working, running kernel, you may need to pass special configuration options to it at boot time, such as the root device it should use or an instruction to probe for multiple Ethernet cards. LILO, the Linux boot loader, passes in these options. You add static configuration options to the /etc/lilo.conf file by using the append keyword; see page 18 for more information.
If it’s not possible to edit the lilo.conf file (perhaps you broke something and the machine can’t boot), you can pass the options in when LILO first loads. For example, at the LILO boot prompt, you could type
LILO: linux root=/dev/hda1 ether=0,0,eth0 ether=0,0,eth1
to tell LILO to load the kernel specified by the “linux” tag, to use the root device /dev/hda1, and to probe for two Ethernet cards.
Building the Linux kernel binary
Setting up an appropriate .config file is the most important part of the Linux kernel configuration process, but you must jump through several more hoops to turn that file into a finished kernel. Here’s an outline of the entire process:
• cd to /usr/src/linux.
• Run make xconfig or make menuconfig, depending on your preference.
• Run make dep.
• Run make clean.
• Run make bzImage.
• Run make modules.
• Run make modules_install.
• Copy /usr/src/linux/arch/i386/boot/bzImage to /boot/vmlinuz.
• Copy /usr/src/linux/arch/i386/boot/System.map to /boot/System.map.
• Edit /etc/lilo.conf and add a configuration for the new kernel.
• Run /sbin/lilo to install the reconfigured boot loader.
The make clean step is not always strictly necessary, but it is generally a good idea to start with a clean build environment. In practice, many problems can be traced back to skipping this step.
Tuning your Linux configuration
Unfortunately, the .config file does not provide a mechanism for tuning kernel parameters. However, Linux does provide an extensive kernel-to-userland interface through files in the /proc filesystem.
Several files and directories in /proc let you view and set kernel options at run time. These files mimic standard UNIX files, but they are really back doors into the kernel. If one of these files has a value you would like to change, you can try writing to it. Not all of the files can be written to (regardless of their apparent permissions), and no documentation tells you which ones can or