< Day Day Up > |
Instead of installing already compiled binary versions of the kernel, you can install the kernel source code on your system and use it to create the kernel binary files yourself. Kernel source code files are compiled with the gcc compiler just as any other source code files are. One advantage to compiling the kernel is that you can enhance its configuration, adding support for certain kinds of devices such as Bluetooth devices. The 2.4 kernel is described here.
You can obtain a recent version of the kernel source code from your distribution. It will have the name kernel-source. New versions can be downloaded with your distribution update agent, or by directly accessing the distribution's FTP site. As noted previously, you simply install them as you would any RPM package.
# rpm -ivh kernel-source-2.4.22-1.2115.nptl.i386.rpm
The source files are placed in the /usr/src directory, within the subdirectory that has the prefix linux and a suffix consisting of the kernel version, as in linux-2.4.22-1 for kernel 2.4, revision 20, patch 8. The full directory will be /usr/src/linux-2.4.22-1. When you download and install a new kernel, a separate subdirectory is created for it. For example, the 2.4.22-1 kernel is placed in /usr/src/linux-2.4.22-1. A link is created called /usr/src/linux-2.4 that links to the most recent kernel source directory that you installed. You can use this link to access your most recent kernel source. Originally, this would link to /usr/src/linux-2.4.22-1. If you later installed the 2.5.67 kernel, this would link to /usr/src/linux2.5.67.
You can also obtain the most recent version of the source code from www.kernel.org. These versions are normally much more recent than those available on your distribution site, but they may not have been thoroughly tested on the distribution platform. The kernel source is in the form of compressed archives (.tar.gz). They have the prefix linux with the version name as the suffix. You decompress and extract the archive with the following commands. You first change to the /usr/src directory and then unpack the archive. It creates a directory called linux where the source files are placed. The following example extracts the 2.4.22-1 kernel:
cd /usr/src tar -xzvf linux-2.4.22-1.tar.gz
Be sure to unpack the archive in the /usr/src directory. The archive extracts a directory named linux that holds the source code files. This way, the files are located in the /usr/src/linux directory. You should rename this directory, adding the kernel version, as Red Hat does, /usr/src/linux-2.4.22-1.
Tip |
If you are using the original kernel source, you should also check for any patches. |
Once the source is installed, you must configure the kernel. Configuration consists of determining the features for which you want to provide kernel-level support. These include drivers for different devices, such as sound cards and SCSI devices. You can configure features as directly included in the kernel itself or as modules the kernel can load as needed. You can also specifically exclude features. Features incorporated directly into the kernel make for a larger kernel program. Features set up as separate modules can also be easily updated. Documentation for many devices that provide sound, video, or network support can be found in the /usr/share/doc directory. Check the kernel-doc package to find a listing of the documentation provided.
rpm -ql kernel-doc
Note |
If you configured your kernel previously and now want to start over from the default settings, you can use the make mrproper command to restore the default kernel configuration. |
You can configure the kernel using one of several available configuration tools: config, menuconfig, xconfig, and with the 2.6 kernel, gconfig. You can also edit the configuration file directly. These tools perform the same configuration tasks but use different interfaces. The config tool is a simple configure script providing line-based prompts for different configuration options. The menuconfig tool provides a cursor-based menu, which you can still run from the command line. Menu entries exist for different configuration categories, and you can pick and choose the ones you want. To mark a feature for inclusion in the kernel, move to it and press the SPACEBAR. An asterisk appears in the empty parentheses to the left of the entry. If you want to make it a module, press M and an M appears in the parentheses. The xconfig tool runs on a window manager and provides a window interface with buttons and menus. You can use your mouse to select entries. A menu consists of configuration categories that are listed as buttons you can click. The 2.6 kernel's gconfig tool uses a GNOME interface to provide expandable menu trees, selectable panels, and help windows. Selectable features include check buttons you can click. All these tools save their settings to the .config file in the kernel source's directory. If you want to remove a configuration entirely, you can use the mrproper option to remove the .config file and any binary files, starting over from scratch.
make mrproper
You start a configuration tool by preceding it with the make command. Be sure you are in the /usr/src/linux-version directory. The process of starting a configuration tool is a make operation that uses the Linux kernel makefile. The xconfig tool should be started from a terminal window on your window manager. The menuconfig and config tools are started on a shell command line. The following example lists commands to start xconfig, menuconfig, and config:
make xconfig make menuconfig make config
The xconfig tool opens a Linux Kernel Configuration window listing the different configuration categories. Figure 33-1 shows the configuration categories for the 2.4 kernel. Buttons at the right of the screen are used to save the configuration or to copy it to a file, as well as to quit. Clicking an entry opens a window that lists different features you can include. Three check boxes to the left of each entry enable you to choose to have a feature compiled directly into the kernel, created as a separate module that can be loaded at runtime, or not included at all. As a rule, features in continual use, such as network and file system support, should be compiled directly into the kernel. Features that could easily change, such as sound cards, or features used less frequently, should be compiled as modules. Otherwise, your kernel image file may become too large and slower to run.
The gconfig tool opens a Linux Kernel Configuration window listing the different configuration categories. Figure 33-2 shows the configuration categories for the 2.6 kernel. You will notice that there are fewer categories than for the 2.4 kernel. Many categories have been reorganized into a few major headings, with many now included under the Device Drivers menu. The Load and Save buttons and File menu entries can be used to save the configuration or to copy it to a file. Single, Split, and Full view buttons let you display menus in one window, in a display panel with another panel containing an expandable tree to select entries, or as a single expandable tree of entries. The Expand button will expand all headings and subheadings, whereas the Collapse button will let you expand only those you want displayed. Use the down and side triangles for each entry to expand or collapse subentries.
Clicking an entry opens a window that lists different features you can include. Entries are arranged in columns listing the option, its actual name, its range (yes, module, or no), and its data (yes, no, or module status). Entries in the Options menu let you determine what columns to display: Name for the actual module name; Range for the selectable yes, no, and module entries; and Data for the option status, titled as Value.
The Range entries are titled N, M, and Y and are used to select whether or not to include an option (N), to load it as a module (M), or to compile it directly into the kernel (Y). Entries that you can select will display an underscore. Clicking the underscore will change its entry to Y for module or direct kernel inclusion, and N for no inclusion. The Value column will show what is currently selected.
The Options column will include a status showing whether the option is included directly (check mark), included as a module (line mark), or not included at all (empty). To quickly select or deselect an entry, double-click the option name in the Options field. You will see its check box checked, lined (module), or empty. Corresponding N, M, and Y entries for no inclusion, module, or kernel inclusion are selected. The default preference for either module or direct kernel inclusion for that option is selected automatically. You can change it manually if you wish.
< Day Day Up > |
This HTML Help has been published using the chm2web software. |