📄 0053-0056.html
字号:
<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="../ch04/0050-0052.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0057-0059.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-53"><P>Page 53</P></A>
<H3><A NAME="ch05_ 1"> CHAPTE 5</A></H3>
<H2>
Configuring and Building Kernels
</H2>
<B>by Steve Shah
</B>
<H3><A NAME="ch05_ 2">
IN THIS CHAPTER
</A></H3>
<UL>
<LI> An Introduction to the Linux Kernel 54
<LI> Configuring the Linux Kernel 58
<LI> Building the Kernel 70
<LI> Installing the Kernel 72
<LI> Recovering from Faulty Kernels 73
</UL>
<A NAME="PAGENUM-54"><P>Page 54</P></A>
<P>The kernel is the program that is loaded at boot time which provides an interface between
the user-level programs and the hardware. Its functionality includes performing the actual
task switching that occurs in multitasking systems, handling requests to read and write to
disks, dealing with the network interface, and managing memory. It is these functions that give
Linux its underlying behavior seen throughout the system.
</P>
<P>Technically, Linux is only the kernel. The programs that surround it, such as the
compilers, editors, windowing managers, and so on, make up the distribution. (For example, Red
Hat Linux is considered a distribution of Linux.) Therefore, several different distributions of
Linux exist, but the kernel remains common among them.
</P>
<P>The kernel is important because it is the glue that holds everything together. Working as
a central command post for the system, it manages all the programs running, their memory
allocation, their means of accessing the disk, and so on. Without the kernel, there is no Linux.
</P>
<P>The default kernel that comes on the CD-ROM is the 2.0.30 kernel. This kernel, which
is automatically installed, contains support for a large number of devices, thereby making it
flexible. Unless you have a particularly unusual configuration, the standard issue kernel with
Red Hat should work on your machine without any changes.
</P>
<P>Although the standard issue kernel will work, you might need to add support for a new
device or simply pare down the list of devices the kernel supports so that it takes less memory.
Either way, you will need to step through the kernel configuration process.
</P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
WARNING
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
Recompiling a new kernel can be potentially dangerous. By doing so, you can easily
deny yourself access to the system, so be sure to follow all the safety tips in this chapter.
Being locked out of your own machine because of a silly mistake is one of the most
frustrating results than can occur.
<BR>
At the very least, you should have a boot disk ready. Test it and verify that it comes up
as you expect it to. Be familiar with the commands necessary to mount the root partition,
make changes to key files (for example,
/etc/lilo.conf), and rerun LILO.
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
<H3>
An Introduction to the Linux Kernel
</H3>
<P>Now that you have an understanding of what the kernel does, you might find a need
to reconfigure and build it. In this section, I discuss the preamble to the process: acquiring
the source code and installing it in the correct place.
</P>
<A NAME="PAGENUM-55"><P>Page 55</P></A>
<H4><A NAME="ch05_ 3">
Acquiring the Source Tree
</A></H4>
<P>The CD-ROM that comes with this book contains an RPM for the kernel source tree. To
use it, simply install it using the rpm package. You can find updated versions of the kernel source
at www.redhat.com or from one of the following:
</P>
<UL>
<LI> <a href="http://www.kernel.org">http://www.kernel.org</A>
<LI> ftp://ftp.cdrom.com/pub/linux/sunsite/kernel
<LI> ftp://sunsite.unc.edu/pub/Linux/kernel
<LI> ftp://tsx-11.mit.edu/pub/linux/sources/system
</UL>
<P>The source tree comes in one large file titled
linux-X.X.XX.tar.gz, where X.X.XX is the
version number of the kernel. For this example, you will use version 2.0.30.
</P>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
NOTE
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
Version numbers in Linux have more significance than what may appear to you at
first glance. To understand what I mean, look at the kernel used in this chapter—2.0.30.<BR>
<BR>
The version number is broken up into three parts: the major number, the minor number,
and the revision number. The major version number—2 in this kernel—rarely changes.
Every time the number increases, major improvements have been made in the kernel,
and upgrades are definitely warranted.<BR>
<BR>
The minor number—0 in this kernel—indicates the kernel's stability. Even-numbered
kernels (for example, 0, 2, 4, and so on) are considered stable production-quality kernels,
whereas odd-numbered kernels (for example, 1, 3, 5, and so on) are development kernels. When
a kernel reaches a production version, no more features are added, and the only
changes made to it are to fix any last-minute bugs.<BR>
<BR>
In contrast, odd-numbered kernels are actively being worked on. They contain
experimental code and feature the latest developments. The side effect of these added features is
the instability that may exist in them. Sometimes they are stable; other times they have
critical flaws. Odd-numbered kernels should be used only on systems on which users are
comfortable trying out new features and can accept downtime incurred by frequent kernel
upgrades.<BR>
<BR>
The last number, which is the revision number, indicates the current patch level for
this version of the release. During the development phase, new versions can be released
as often as twice a week.
</BLOCKQUOTE></TD></TR>
</TABLE>
<P>If you decide to download a more recent source tree instead of using the version on the <BR>
CD-ROM, you need to decompress and untar it. You should do so in the
/usr/src directory because symbolic links from
/usr/include have already been set up. By manipulating the
</P>
<A NAME="PAGENUM-56"><P>Page 56</P></A>
<P>
/usr/src directory so that /usr/src/linux always points to the most recent kernel, you
don't have to fix the /usr/include directories every time you compile a new kernel. (See the
following tip.)
</P>
<P>To unpack the kernel, simply run
</P>
<!-- CODE SNIP //-->
<PRE>
tar xzf linux-2.0.30.tar.gz
</PRE>
<!-- END CODE SNIP //-->
<P>where linux-2.0.30.tar.gz is the name of the kernel you downloaded. This line
decompresses and untars the kernel into the
/usr/src/linux directory.
</P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
TIP
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
If you have an older kernel in place, you might not want to
remove the previous source tree. After all, if you need to revert back to it, not having to download it again would
be nice! Instead, create a new directory titled
linux-2.0.30, where 2.0.30 is the version number of the new kernel. Then create a symbolic link from
/usr/src/linux to /usr/src/linux-2.0.30. By doing so, you can easily repoint the symbolic link to new kernels as
they are released. As a side benefit, your
/usr/include directories can always remain pointed to
/usr/src/linux.
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
</P>
<P>If this is the first kernel you've compiled, be sure to take a few minutes to read the
/usr/src/linux/README file. It contains up-to-the-minute details about the exact kernel you are
working with as well as problem reporting information.
</P>
<CENTER>
<TABLE BGCOLOR="#FFFF99">
<TR><TD><B>
TIP
</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
Due to the amount of concurrent development done in the Linux community, you might
find that not all the drivers provided with the Linux kernel are the latest. If you have
problems with a particular device, searching on the Internet to see whether a more recent version
of the driver is available is often worthwhile.
<BR>
For example, if you are having problems with the 3Com 3C59x driver, a quick peek at
the source code shows that you can reach the author of the driver, Donald Becker, at
linux-vortex@cesdis.gsfc.nasa.gov. Searching on the keywords
linux vortex on the AltaVista search engine
(www.altavista.digital.com) turns up the primary Web site for
the development of this driver
<a href="http://cesdis.gsfc.nasa.gov/pub/linux/drivers/vortex.html">(http://cesdis.gsfc.nasa.gov/pub/linux/drivers/vortex.html</A>
) from which you can download the latest version and include it into
your source tree.
</BLOCKQUOTE></TD></TR>
</TABLE></CENTER>
<P><CENTER>
<a href="../ch04/0050-0052.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0057-0059.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -