📄 253-255.html
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Linux, Fourth Edition:Configuring the Linux Kernel</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=0789717468//-->
<!--TITLE=Special Edition Using Linux, Fourth Edition//-->
<!--AUTHOR=Jack Tackett//-->
<!--AUTHOR=Jr.//-->
<!--AUTHOR=Steve Burnett//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=13//-->
<!--PAGES=253-255//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch12/251-251.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="255-258.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H2><A NAME="Heading1"></A><FONT COLOR="#000077">Chapter 13<BR>Configuring the Linux Kernel
</FONT></H2>
<P><I>by Jack Tackett</I></P>
<DL>
<DT><B><BIG>I</BIG>n this chapter
</B><DT>Preparing to Build a New Kernel
<DT>Configuring a New Kernel
<DT>Compiling the New Kernel
<DT>Building a Modularized Kernel
</DL>
<P>This chapter gives you the information you need to configure and install a new Linux kernel. The kernel is the core of the Linux operating system and provides the basic system services to the rest of Linux. Remember, Linux isn’t a commercial product, so you might find some problems after a new distribution is released. Or someone may discover a serious security hole in the kernel. This happens all the time with both commercial and “free” operating systems. The difference is that with Linux, because the source code is available, you can patch any problems immediately after they are discovered. You do not have to wait for your commercial vendor to release a new service pack to fix a hole in your system.
</P>
<P>In addition, a new feature in the current releases of the Linux kernel enables you to load specific device and program support into the kernel without precompiling the support into a large kernel. This allows Linux to load into memory only those parts of the kernel it needs. Modules also provide a way to modify the kernel to solve a problem or to add a new feature without recompiling the entire system.</P>
<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Preparing to Build a New Kernel</FONT></H3>
<P>Sometimes a problem has only one solution—a new kernel. The kernel is the core operating system for Linux. Although not for the faint of heart, downloading a new kernel from the Net and building the kernel is sometimes necessary. If you have some programming experience and know your way around the C programming language, you should be able to build and install a new kernel. If not, you might want to skip this section.
</P>
<P>You may have to install a new kernel for a few reasons:</P>
<DL>
<DD><B>•</B> A patch is released to run new hardware.
<DD><B>•</B> You want to remove features you don’t use from the kernel in order to lower the memory requirements for your system.
</DL>
<P>The starting point is to determine what kernel version you’re now running. You can find out the kernel version with the following command:
</P>
<!-- CODE SNIP //-->
<PRE>
uname -a
</PRE>
<!-- END CODE SNIP //-->
<P>The response indicates which version of the kernel is running and when it was created. The version numbers are in the form of
</P>
<DL>
<DD>MajorVersionNumber.MinorVersionNumber.PatchLevel
</DL>
<P>Linus Torvalds is the official release point for new kernels, although anyone can modify Linux (due to the GPL). Because Linus is the official release point, the Linux development and user community has a common baseline from which to work and communicate.
</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>Be sure to read the Kernel HOWTO for up-to-date information before actually trying to build and configure a new kernel. If you mess up, you could render your system useless. You should also make sure to keep an older, working copy of a kernel around just in case of problems. You can then boot that kernel instead of the worthless kernel.<HR></FONT>
</BLOCKQUOTE>
<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Configuring a New Kernel</FONT></H3>
<P>To build a new kernel, you first need to configure the source code files. The source files should be located in the /usr/src/Linux directory. You also must have the C compiler package loaded. If you didn’t install that package during installation, use RPM to do so now with the following commands:
</P>
<!-- CODE SNIP //-->
<PRE>
rpm –i kernel-source-2.0.34-0.6.i386.rpm
rpm –i gcc-2.7.2.3-11.i386.rpm
</PRE>
<!-- END CODE SNIP //-->
<P>You may also have to install the kernel headers and various compiler libraries.
</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR>• <B>See</B> “Installing Packages with RPM,” <B>p. 150</B><HR></FONT>
</BLOCKQUOTE>
<P>First, you must get the new kernel sources or patches. The new sources are usually found on the Internet; check <B>sunsite.unc.edu</B> for the latest and greatest kernels. (If you’re modifying your current kernel, this step is, of course, unnecessary.) The source files are usually in a tar file and will need to be unarchived.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>TIP: </B>Making a backup copy of your current kernel with the following commands is a very good idea:<!-- CODE SNIP //-->
<PRE>
cd /usr/src
cp Linux linux.sav
</PRE>
<!-- END CODE SNIP //-->
<P>These commands copy the entire Linux source directory to another directory called linux.sav.<HR></FONT>
</BLOCKQUOTE>
</P>
<P>Next, you should use the <TT>patch</TT> command to apply any patch files. After preparing the source files, you can configure and build your new system. Depending on your personal preferences and hardware available, three methods are available for configuring the kernel: a text-based program, a text-based menu program, and if you have installed X Windows, an X-based program.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>TIP: </B>In order to use kernel modules, you must answer Yes to kerneld support and module version (CONFIG_MODVERSIONS) support during your kernel configuration.<HR></FONT>
</BLOCKQUOTE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="../ch12/251-251.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="255-258.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -