📄 613-616.html
字号:
<HTML>
<HEAD>
<TITLE>Using Linux:Managing the 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=0789716232//-->
<!--TITLE=Using Linux//-->
<!--AUTHOR=William Ball//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=32//-->
<!--PAGES=613-616//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="606-613.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="616-618.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading23"></A><FONT COLOR="#000077">Building and Installing the Kernel</FONT></H4>
<P>No matter which configuration tool you used to configure your kernel, now you must compile all the source files and produce the kernel itself. After building the kernel, and the modules for it, you need to create an initial ramdisk if your system is booting from a SCSI disk, and then re-run <TT>LILO</TT>, if you’re using <TT>LILO</TT> to boot the system. If you’re using <TT>LOADLIN</TT>, you must copy the kernel and the ramdisk file to a location from which <TT>LOADLIN</TT> can load the kernel.</P>
<P><FONT SIZE="+1"><B><I>Compiling the kernel and modules</I></B></FONT></P>
<DL>
<DD><B>1.</B> Make sure you’re in the Linux kernel directory. (You’re probably already there.)
<DD><B>2.</B> Issue the <TT>make dep</TT> command. This command causes the <TT>make</TT> system to generate dependency files to facilitate the correct building of the kernel.
<DD><B>3.</B> Issue the <TT>make clean</TT> command. <TT>make dep</TT> leaves a lot of files lying around that can prevent the <TT>make</TT> program from compiling some files, and this can cause problems.
<DD><B>4.</B> Issue the <TT>make zImage</TT> command. Note that this command is case sensitive. <TT>make zImage</TT> builds the kernel file. If the build process stops with an error message, run <TT>make clean</TT>, <TT>make dep</TT>, and then <TT>make zImage</TT> again. Any remaining error is likely to be an error in the configuration from the <TT>make config</TT> or equivalent script. Rerun that script, and perhaps take out some of the experimental stuff.
<DD><B>5.</B> If all went well, run the <TT>make modules</TT> command to compile the module files.
<DD><B>6.</B> If the version of the kernel you’re compiling is different from the kernel you’re currently running, run the make <TT>modules_install</TT> command. (Note the underscore in this command.) <TT>make modules_install</TT> copies the modules into the correct tree in the <TT>/lib/modules</TT> directory tree. If you want to make backups of the modules you currently have, you can make a quick backup by issuing the following command:
<!-- CODE SNIP //-->
<PRE>
<B>tar czvf /root/modules-`uname -r`.tar.gz</B>
<B>b/modules/`uname -r`</B>
</PRE>
<!-- END CODE SNIP //-->
<BR>This command assumes that you’re going to install modules of the same kernel version that you’re currently running.
</DL>
<P>You’re now ready to make your initial ramdisk. You must perform this step only if you are booting from a non-IDE block device (such as a SCSI hard disk or RAID array), are using modules for your SCSI block device driver, and have switched kernel versions.
</P>
<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD><FONT SIZE="+1"><B>Initial ramdisks and static (non-modular) device drivers</B></FONT>
<BR>The default installation of Red Hat Linux does use modular device drivers for SCSI hard disks, and if you have compiled drivers specific to your SCSI hardware into your kernel you must make sure that you have either disabled initial ramdisk support in the kernel as well, or edited your <TT><B>/etc/lilo.conf</B></TT> file to remove the initial ramdisk entry; otherwise, your system attempts to load the drivers for your SCSI card twice. Because your system will not find a SCSI device the second time the driver is initialized, the boot system will stop—this is not what you want!</TABLE>
<P><FONT SIZE="+1"><B><I>Creating an initial ramdisk with <I>mkinitrd</I>
</I></B></FONT></P>
<DL>
<DD><B>1.</B> Ensure that the <TT>/etc/conf.modules</TT> file on your system is set up correctly. (Chances are it is, especially if your SCSI system booted from your hard disk successfully.)
<DD><B>2.</B> Make a backup of your current ramdisk. The file is located in the <TT>/boot</TT> directory, usually called either <TT>initrd</TT> or <TT>initrd-<kernel-version></TT>, where <TT><kernel-version></TT> is the version number of the kernel it is compiled for. Since it’s probably a good idea to set up your system so that you can still boot the old kernel, rename the file to <TT>initrd.old</TT>.
<DD><B>3.</B> Determine whether your system needs to preload the generic SCSI system support modules. Execute the command <TT>/sbin/lsmod</TT> to obtain a listing of the modules that your system currently has loaded. The generic SCSI modules are called <TT>sd_mod</TT> and <TT>scsi_mod</TT>. If these appear in the output listing, chances are your system needs them.
<DD><B>4.</B> Issue the following command:
<!-- CODE SNIP //-->
<PRE>
<B>/sbin/mkinitrd <--needs-scsi-modules> /boot/initrd <ker-</B>
<B>nel-version></B>
</PRE>
<!-- END CODE SNIP //-->
<BR>The option <TT>--needs-scsi-modules</TT> should be used if you have configured your kernel so that the generic SCSI disk support is modular. <TT><kernel-version></TT> is the version of the kernel for which you need to make the ramdisk.
<BR>If you have problems with this command, make sure that your system has support for a loopback block device, either as a module (recommended—<TT>kerneld</TT> will automatically load the module), or as a static device. It would also be worthwhile to check for updates for <TT>mkinitrd</TT> at the Red Hat Web site.
</DL>
<H4 ALIGN="LEFT"><A NAME="Heading24"></A><FONT COLOR="#000077">Installing the Kernel</FONT></H4>
<P>This assumes that you have configured and compiled your kernel, installed your modules, and configured <TT>initrd</TT>. You should also have configured LILO (refer to Chapter 24, “Using LILO and LOADLIN”) to perhaps include the old boot image and ramdisk so that you can boot those if things go wrong with your new kernel.</P>
<P>The following steps will save you the most typing if you are in the <TT>/boot</TT> directory because you can leave the <TT>/boot</TT> directory path out of every command.</P>
<DL>
<DD><B>1.</B> Copy the kernel image, <TT>/usr/src/linux/arch/i386/boot/vmlinuz</TT>, to the <TT>/boot</TT> directory as file <TT>zImage-<kernel-version></TT>. Of course, replace <TT><kernel-version></TT> with the version number of your kernel. If you have customized LILO to look for a different filename as the kernel image, make sure you use that instead.
<DD><B>2.</B> Delete the symbolic link <TT>/boot/zImage</TT>. Create a new symbolic link using the command <TT>ln -s /boot/zImage-<kernel-version> /boot/zImage</TT>.
<DD><B>3.</B> Type the command <TT>lilo</TT>. You should see output something like this:
<!-- CODE SNIP //-->
<PRE>
[root@jansmachine /root]# lilo
Added linux *
Added old
</PRE>
<!-- END CODE SNIP //-->
<BR>The <TT>*</TT> character after the <TT>linux</TT> image is the image that LILO will boot by default. If you want to boot another image (for instance, the image <TT>old</TT> that was listed above), just type the image at the <TT>lilo:</TT> prompt that the system presents you with before it boots.
<BR>You may also want to test to see if LILO will install your configuration successfully. To do this, type <TT>lilo -t</TT> instead of <TT>lilo</TT>. This does everything but actually modify your disk to install LILO.
</DL>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="606-613.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="616-618.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 + -