072-075.html

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

HTML
105
字号
<HTML>

<HEAD>

<TITLE>Linux Unleashed, Third Edition:Using LILO</TITLE>

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

 -->




<!--ISBN=0672313723//-->

<!--TITLE=Linux Unleashed, Third Edition//-->

<!--AUTHOR=Tim Parker//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Sams//-->

<!--CHAPTER=4//-->

<!--PAGES=072-075//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="070-072.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="075-077.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H3><A NAME="Heading7"></A><FONT COLOR="#000077">The Boot Sector</FONT></H3>

<P>To understand the Linux boot process, a look at the DOS boot sector is necessary. Figure 4.1 shows the DOS boot sector layout. The program code is the bootstrap to the operating system. The disk parameters include the File Allocation Table (FAT).

</P>

<P><A NAME="Fig1"></A><A HREF="javascript:displayWindow('images/04-01.jpg',470,496 )"><IMG SRC="images/04-01t.jpg"></A>

<BR><A HREF="javascript:displayWindow('images/04-01.jpg',470,496)"><FONT COLOR="#000077"><B>Figure 4.1.</B></FONT></A>&nbsp;&nbsp;The DOS boot sector layout.</P>

<P>The LILO boot sector is similar to the DOS boot sector, except the disk parameter section is not used and the boundaries between code sections are different. The Linux boot sector layout is shown in Figure 4.2. The differences between the two boot sectors can cause a problem for DOS if the Linux LILO boot sector is written to a DOS disk&#146;s Master Boot Record because DOS won&#146;t be able to load properly.

</P>

<P><A NAME="Fig2"></A><A HREF="javascript:displayWindow('images/04-02.jpg',475,502 )"><IMG SRC="images/04-02t.jpg"></A>

<BR><A HREF="javascript:displayWindow('images/04-02.jpg',475,502)"><FONT COLOR="#000077"><B>Figure 4.2.</B></FONT></A>&nbsp;&nbsp;The Linux LILO boot sector layout.</P>

<P>The magic number referred to in both boot sector layouts is a two-byte number used by some operating systems to verify that the sector read is the boot sector.

</P>

<P>The Linux LILO boot sector can, in theory, be used to boot DOS because the partition table area of the boot record can contain the DOS&#146; FAT file, but in practice the boot process usually fails. It is much better to use a boot sector written to the Linux partition.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>Warning:&nbsp;&nbsp;</B><BR>Because the DOS and Linux LILO boot sectors differ, you should install DOS before Linux. This will make sure that the DOS boot sector is written to the hard disk. If you install Linux first and the Linux LILO boot sector is written to the hard disk, DOS cannot boot.<HR></FONT>

</BLOCKQUOTE>

<P>The LILO boot sector can be saved on a boot floppy, on the Master Boot Record of the hard disk, on the boot sector of the Linux partition, or in the boot sector of an extended partition. It cannot be stored in any non-Linux partition or on any hard disk other than the first.

</P>

<P>Note that although DOS cannot handle a boot sector in an extended partition, Linux can through extensions to <TT>fdisk</TT> or a utility program called <TT>activate</TT>.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>Warning:&nbsp;&nbsp;</B><BR>A common problem with LILO is that it will write a LILO boot sector anywhere, even into locations that cannot be accessed by the operating system. Make sure you are writing your LILO boot sector to a valid location. If you have already installed Linux and are making changes, keep a boot floppy at hand.<HR></FONT>

</BLOCKQUOTE>

<H3><A NAME="Heading8"></A><FONT COLOR="#000077">The Boot Process</FONT></H3>

<P>During the boot process, the boot sector is read to obtain the bootstrap for the operating system. In the case of DOS, the Master Boot Record or boot sector is read, then <TT>COMMAND.COM</TT> is loaded. <TT>COMMAND.COM</TT> is the DOS operating system kernel.</P>

<P>Although usually set up when the Linux installation process is followed, you may want to alter the boot system used by Linux. There are several approaches that can be used depending on your requirements and machine hard drive configuration. We can look at a few of the typical configuration examples to show how the boot process can be modified.</P>

<H4 ALIGN="LEFT"><A NAME="Heading9"></A><FONT COLOR="#000077">Dedicated Linux Hard Disk</FONT></H4>

<P>With a dedicated Linux installation or a Linux boot by default (and despite other operating systems on the hard disk), the Master Boot Record can be replaced with the Linux LILO boot sector. LILO will then boot straight into Linux from the Master Boot Record without touching partition boot sectors. In some cases, though, you may have to explicitly specify the boot sector. In other words, at the <TT>boot:</TT> prompt you may have to specify <TT>boot=/dev/hda</TT> (or whichever device holds the modified Master Boot Record) if the default values do not work.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>Warning:&nbsp;&nbsp;</B><BR>If you replace the Master Book Record with LILO for a dedicate Linux system and then later remove Linux, you will have to low-level format the hard drive or restore the old MBR before the drive can be used by another operating system such as DOS.<HR></FONT>

</BLOCKQUOTE>

<P>To install LILO as a dedicated Linux boot, follow these steps:

</P>

<DL>

<DD><B>1.</B>&nbsp;&nbsp;Boot Linux as usual. Make sure you have a boot floppy disk in case of problems.

<DD><B>2.</B>&nbsp;&nbsp;Copy your existing Master Boot Record to a floppy in case of problems. The command to copy the MBR from the main drive (<TT>/dev/hda</TT>) to a floppy using 512 character blocks (the default) is

<!-- CODE SNIP //-->

<PRE>

dd if=/dev/hda of=/fd/MBR bs=512 count=1

</PRE>

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

<DD><B>3.</B>&nbsp;&nbsp;Use the setup or LILO installation program to copy LILO into the boot sector, setting LILO in the Master Boot Record.

<DD><B>4.</B>&nbsp;&nbsp;Reboot the machine to boot from the Master Boot Record.

</DL>

<P>Your machine should load Linux automatically. If Linux does not boot, use your boot floppy to start Linux and either repeat the process or restore the original Master Boot Record from the floppy using the following command:

</P>

<!-- CODE SNIP //-->

<PRE>

dd if=/fd/MBR of=/dev/hda bs=446 count=1

</PRE>

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

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="070-072.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="075-077.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





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

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

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