0057-0059.html

来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 304 行

HTML
304
字号


<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Configuring and Building Kernels</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311739 //-->

<!-- TITLE=RED HAT LINUX 2ND EDITION //-->

<!-- AUTHOR=DAVID PITTS ET AL //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS PUBLISHING //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=05 //-->

<!-- PAGES=0053-0074 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->









<P><CENTER>

<a href="0053-0056.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0060-0062.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-57"><P>Page 57</P></A>









<H4><A NAME="ch05_ 4">





Patching the Source Tree

</A></H4>









<P>As each new version of the source tree is released, a corresponding patch also is released

containing the differences between the two versions. The patch, as you can imagine, is much

smaller than the entire new source tree, thereby making it a much quicker upgrade.

</P>









<P>When you're patching the Linux kernel, keep in mind that patches apply to only one

particular version of the Linux kernel. For example, if you have the 2.0.27 kernel, the only patch

that will apply to it is for the 2.0.28 kernel. If you want to bring your kernel up to version

2.0.30, you will need to apply three patches: 2.0.28, 2.0.29, and 2.0.30. The patch files are

available in the same directories as the kernel sources at the FTP and Web sites mentioned previously

in this chapter.

</P>









<P>After you download a patch, you need to use a combination of the tar and patch programs

to make the changes. Begin by moving the patch into the

/usr/src directory. After it is there, run the commands

</P>





<!-- CODE SNIP //-->

<PRE>

cd /usr/src

gzip -cd patch-XX.gz | patch -p0

</PRE>

<!-- END CODE SNIP //-->











<P>where XX is the version number of the patch you are applying. For example, you would

apply the following to the 2.0.29 kernel:

</P>





<!-- CODE SNIP //-->

<PRE>

cd /usr/src

gzip -cd patch-2.0.30.gz | patch -p0

</PRE>

<!-- END CODE SNIP //-->











<P>After you apply the patch, check for any files ending in

.rej in the /usr/src/linux directory. If you find such files there, verify that you applied the patch correctly. If you are sure you

patched correctly, watch for an update patch within a day or two. If an error occurs with the patch

file, a new version of the patch will appear.

</P>









<H4><A NAME="ch05_ 5">





Modules

</A></H4>









<P>Modules are chunks of the kernel that are not permanently loaded into memory at boot

time. Instead, they are loaded on demand and after a period of non-use are removed from

memory. Modules are commonly used for networking code on a machine that is not permanently

connected, supporting devices not often used, and so on. Although you can make even

commonly used kernel code a module, you might find that the overhead in reloading it often

outweighs the benefits of it being removed from memory when not in use.

</P>









<P>The Linux kernel as of version 2.0 has easy-to-use support for modules. Modules have, for

all practical purposes, become transparent in their operation. If you are curious about the

details of their operation, read the documentation that comes with the

insmod, rmmod, ksyms, and lsmod programs.

</P>



<A NAME="PAGENUM-58"><P>Page 58</P></A>













<H3><A NAME="ch05_ 6">

Configuring the Linux Kernel

</A></H3>









<P>Now that you have the kernel source tree unpacked and ready to go in

/usr/src/linux, you can begin the configuration.

</P>







<CENTER>

<TABLE BGCOLOR="#FFFF99">

<TR><TD><B>

WARNING

</B></TD></TR>

<TR><TD>

<BLOCKQUOTE>

Before making any key changes to a system, such as installing a new kernel, you

should have a boot disk ready. In the unfortunate event that you misconfigure something

(and everybody does eventually), you will need a way to get back into your system.<BR>

<BR>

If you are only compiling a new kernel and not making any other key changes, you

can simplify the emergency rescue process by making a backup of the kernel and modules

on the root partition. Modify the /etc/lilo.conf file to allow you to boot to your

currently working kernel as an option. This step is important because not all new kernels work

as advertised, especially if you are compiling a development kernel. Booting another

kernel right off your root partition is substantially easier than booting off floppies to regain

control.

</BLOCKQUOTE></TD></TR>

</TABLE></CENTER>

</P>

<P>You can configure the Linux kernel in one of three ways. The first (and original) method is

to use the make config command. It provides you with a text-based interface for answering all

the configuration options. You are prompted for all the options you need to set up your kernel.

</P>









<P>The text-based interface is a good backup for instances in which you don't have fancy

screen control (for example, your console is an old terminal for which you don't have a

termcap setting); hence, you should be familiar with it.

</P>









<P>More likely, however, you will have a standard PC console. If so, you can use

the make menuconfig command, which provides all the kernel options in an easy-to-use menu. For the sample

configuration in this chapter, you will use the make

xconfig command, which provides a full graphical interface to all the kernel

options.

</P>









<H4><A NAME="ch05_ 7">





Starting the Configuration

</A></H4>









<P>For the sample configuration, assume that the system is a generic Pentium class PC with

an EIDE hard drive, IDE CD-ROM, an Adaptec 2940 SCSI card, and a 3Com 3C905

Ethernet card. The system is being configured as a server, so use a stock 2.0.30 kernel. (Remember:

Never use development kernels on production systems!)

</P>









<P>To start the configuration tool, change into the directory

/usr/src/linux and invoke the following command:

</P>





<!-- CODE SNIP //-->

<PRE>

make xconfig

</PRE>

<!-- END CODE SNIP //-->











<P>After a brief pause (some text will scroll down your screen), a window like the one shown

in Figure 5.1 appears.

</P>



<A NAME="PAGENUM-59"><P>Page 59</P></A>





<BR>

Figure 5.1.<BR>

Kernel configuration<BR>

main menu.<BR>

<a href="07rhu01.html"><img src="images/tn_07rhu01_jpg.jpg"></a><BR>











<P>The menu options, which are centered in the middle of the window, start with Code

maturity level options and end with Kernel hacking. By using the four buttons below the menu, you

can load or save configurations to disk for

further work.

</P>









<H4><A NAME="ch05_ 8">





Stepping Through the Menus

</A></H4>









<P>Under each top-level menu in this opening window is a list of options that you can tag to

either compile into the kernel, compile as a module, or not include at all. Remember that

each option that you elect to compile into the kernel makes the kernel a little larger, thereby

requiring more memory. Therefore, include only what you need, but be sure to include key

system functions into the kernel such as network drivers and filesystem support for your boot

drive. Essentially, you should add any feature you will need on a constant basis. Features that are

not often used, such as PPP support, are best compiled as modules.

</P>









<P>To start, take a close look at the menu under Code maturity level options. Begin by

clicking that menu. This action brings up the Code maturity level options window, as shown in

Fig-ure 5.2.

</P>



<P><CENTER>

<a href="0053-0056.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0060-0062.html">Next</A>

</CENTER></P>









</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?