6. Modify the kernel configuration file using make config
, make menuconfig
, or make xconfig
— we recommend the latter, but read the text following these numbered instructions for more details.
7. Run make dep
to create the code dependencies used later in the compilation process.
If you have a multiprocessor machine, you can use both processors to speed the make process by inserting -j
after the make
command, where, as a rule of thumb,
is one more than the number of processors you have. You might try a larger number and even try this on a single-processor machine (we have used -j8 successfully on an SMP machine); it loads up only your CPU. For example,
# make -j3 bzImage
All the make
processes except make dep
work well with this method of parallel compiling.
8. Run make clean
to prepare the sources for the actual compilation of the kernel.
9. Run make bzImage
to create a binary image of the kernel.
Several choices of directives exist, although the most common ones are as follows:
zImage
— This directive compiles the kernel, creating an uncompressed file called zImage
.
bzImage
— This directive creates a compressed kernel image necessary for some systems that require the kernel image to be under a certain size for the BIOS to be able to parse them; otherwise, the new kernel will not boot. It is the most commonly used choice. However, the Fedora kernel compiled with bzImage
is still too large to fit on a floppy, so a smaller version with some modules and features removed is used for the boot floppies. Fedora recommends that you boot from the rescue CD-ROM. bzDisk
— This directive does the same thing as bzImage
, but it copies the new kernel image to a floppy disk for testing purposes. This is helpful for testing new kernels without writing kernel files to your hard drive. Make sure that you have a floppy disk in the drive because you will not be prompted for one.
10. Run make modules
to compile any modules your new kernel needs.
11. Run make modules_install
to install the modules in /lib/modules
and create dependency files.
12. Run make install
to automatically copy the kernel to /boot
, create any other files it needs, and modify the bootloader to boot the new kernel by default.
13. Using your favorite text editor, verify the changes made to /etc/lilo.conf
or /boot/grub/grub.conf
; fix if necessary and rerun /sbin/lilo
if needed.
14. Reboot and test the new kernel.
15. Repeat the process if necessary, choosing a configuration interface.
Over time, the process for configuring the Linux kernel has changed. Originally, you configured the kernel by responding to a series of prompts for each configuration parameter (this is the make config
utility described shortly). Although you can still configure Linux this way, most users find this type of configuration confusing and inconvenient; moving back through the prompts to correct errors, for instance, is impossible.
The make config
utility is a command-line tool. The utility presents a question regarding kernel configuration options. The user responds with a Y
, N
, M
, or ?
(it is not case sensitive). Choosing M
configures the option to be compiled as a module. A response of ?
displays context help for that specific option, if available. (If you choose ?
and no help is available, you can turn to the vast Internet resources to find information.) We recommend that you avoid the make config
utility, shown in Figure 36.1.
FIGURE 36.1 The make config
utility in all its Spartan glory.
If you prefer to use a command-line interface, you can use make menuconfig
to configure the Linux kernel. menuconfig
provides a graphical wrapper around a text interface. Although it is not as raw as make config
, menuconfig
is not a fancy graphical interface either; you cannot use a mouse, but must navigate through it using keyboard commands. The same information presented in make config
is presented by make menuconfig
, but as you can see in Figure 36.2, it looks a little nicer. Now, at least, you can move back and forth in the selection process in case you change your mind or have made a mistake.
FIGURE 36.2 The make menuconfig
utility, a small improvement over make config.
In make menuconfig
, you use the arrow keys to move the selector up and down and the spacebar to toggle a selection. The Tab key moves the focus at the bottom of the screen to Select, Exit, or Help.
If a graphical desktop is not available, menuconfig
is the best you can do. However, both menuconfig
and xconfig
(see later discussion) offer an improvement over editing the .config
file directly. If you want to configure the kernel through a true graphical interface — with mouse support and clickable buttons — make xconfig
is the best configuration utility option. To use this utility, you must have the X Window System running. The application xconfig
is really nothing but a Tcl/Tk graphics widget set providing borders, menus, dialog boxes, and the like. Its interface is used to wrap around data files that are parsed at execution time. Figure 36.3 shows the main menu of xconfig
for the 2.6.7
kernel.
FIGURE 36.3 The much nicer make xconfig
GUI interface. We recommend that you use this interface if you are able.
After loading this utility, you use it by clicking on each of the buttons that list the configuration options. Each button you click opens another window that has the detail configuration options for that subsection. Three buttons are at the bottom of each window: Main Menu, Next, and Prev(ious). Clicking the Main Menu button closes the current window and displays the main window. Clicking Next takes you to the next configuration section. When configuring a kernel from scratch, click the button labeled Code Maturity Level Options, and then continue to click the Next button in each subsection window to proceed through all the kernel configuration choices. When you have selected all options, the main menu is again displayed. The buttons on the lower right of the main menu are for saving and loading configurations. Their functions are self-explanatory. If you just want to have a look, go exploring! Nothing will be changed if you elect not to save it.
If you are upgrading kernels from a previous release, it is not necessary to go though the entire configuration from scratch. Instead, you can use the make oldconfig
directive; it uses the same text interface that make config
uses, and it is noninteractive. It just prompts for changes for any new code.