📄 grub.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content= "application/xhtml+xml; charset=iso-8859-1" /> <title> 7.19. Making the Temporary System Bootable </title> <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /> <link rel="stylesheet" href="../stylesheets/lfs-print.css" type= "text/css" media="print" /> </head> <body id="lfs" class="CLFS-SVN-20060417-x86"> <div class="navheader"> <div class="headertitles"> <h4> Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-x86 </h4> <h3> Chapter 7. If You Are Going to Boot </h3> </div> <ul class="headerlinks"> <li class="prev"> <a accesskey="p" href="changingowner.html" title= "Changing Ownership">Prev</a> <p> Changing Ownership </p> </li> <li class="next"> <a accesskey="n" href="whatnext.html" title= "What to do next">Next</a> <p> What to do next </p> </li> <li class="up"> <a accesskey="u" href="chapter.html" title= "Chapter 7. If You Are Going to Boot">Up</a>. </li> <li class="home"> <a accesskey="h" href="../index.html" title= "Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-x86"> Home</a> </li> </ul> </div> <div class="sect1" lang="en" xml:lang="en"> <div class="titlepage"> <h1 class="sect1"> 7.19. Making the Temporary System Bootable </h1> </div> <p> Boot loading can be a complex area, so a few cautionary words are in order. Be familiar with the current boot loader and any other operating systems present on the hard drive(s) that need to be bootable. Make sure that an emergency boot disk is ready to “<span class="quote">rescue</span>” the computer if the computer becomes unusable (un-bootable). </p> <p> Earlier, we compiled and installed the GRUB boot loader software in preparation for this step. The procedure involves writing some special GRUB files to specific locations on the hard drive. We highly recommend creating a GRUB boot floppy diskette as a backup. Insert a blank floppy diskette and run the following commands: </p> <pre class="userinput"><kbd class="command">dd if=${LFS}/boot/grub/stage1 of=/dev/fd0 bs=512 count=1dd if=${LFS}/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</kbd></pre> <p> Remove the diskette and store it somewhere safe. Now, run the <span><strong class="command">grub</strong></span> shell: </p> <pre class="userinput"><kbd class="command">grub</kbd></pre> <p> GRUB uses its own naming structure for drives and partitions in the form of <span class="emphasis"><em>(hdn,m)</em></span>, where <span class="emphasis"><em>n</em></span> is the hard drive number and <span class="emphasis"><em>m</em></span> is the partition number, both starting from zero. For example, partition <tt class= "filename">hda1</tt> is <span class= "emphasis"><em>(hd0,0)</em></span> to GRUB and <tt class= "filename">hdb3</tt> is <span class= "emphasis"><em>(hd1,2)</em></span>. In contrast to Linux, GRUB does not consider CD-ROM drives to be hard drives. For example, if using a CD on <tt class="filename">hdb</tt> and a second hard drive on <tt class="filename">hdc</tt>, that second hard drive would still be <span class="emphasis"><em>(hd1)</em></span>. </p> <p> Using the above information, determine the appropriate designator for the root partition (or boot partition, if a separate one is used). For the following example, it is assumed that the root (or separate boot) partition is <tt class="filename">hda4</tt>. </p> <p> Tell GRUB where to search for its <tt class= "filename">stage{1,2}</tt> files. The Tab key can be used everywhere to make GRUB show the alternatives: </p> <pre class="userinput"><kbd class="command">root (hd0,3)</kbd></pre> <div class="warning"> <div class="admonhead"> <img alt="[Warning]" src="../images/warning.png" /> <h3 class="admontitle"> Warning </h3> </div> <div class="admonbody"> <p> The following command will overwrite the current boot loader. Do not run the command if this is not desired, for example, if using a third party boot manager to manage the Master Boot Record (MBR). In this scenario, it would make more sense to install GRUB into the “<span class="quote">boot sector</span>” of the LFS partition. In this case, this next command would become <strong class="userinput"><tt>setup (hd0,3)</tt></strong>. </p> </div> </div> <p> Tell GRUB to install itself into the MBR of <tt class= "filename">hda</tt>: </p> <pre class="userinput"><kbd class="command">setup (hd0)</kbd></pre> <p> If all went well, GRUB will have reported finding its files in <tt class="filename">${LFS}/boot/grub</tt>. That's all there is to it. Quit the <span><strong class="command">grub</strong></span> shell: </p> <pre class="userinput"><kbd class="command">quit</kbd></pre> <p> Create a “<span class="quote">menu list</span>” file defining GRUB's boot menu: </p> <pre class="userinput"><kbd class="command">cat > ${LFS}/boot/grub/menu.lst << "EOF"<tt class="literal"># Begin /boot/grub/menu.lst# By default boot the first menu entry.default 0# Allow 30 seconds before booting the default.timeout 30# Use prettier colors.color green/black light-green/black# The first entry is for LFS.title LFS CLFS-SVN-20060417root (hd0,3)kernel /boot/lfskernel-2.6.16.5 root=/dev/hda4</tt>EOF</kbd></pre> <p> Add an entry for the host distribution if desired. It might look like this: </p> <pre class="userinput"><kbd class="command">cat >> ${LFS}/boot/grub/menu.lst << "EOF"<tt class="literal">title Red Hatroot (hd0,2)kernel /boot/kernel-2.6.5 root=/dev/hda3initrd /boot/initrd-2.6.5</tt>EOF</kbd></pre> </div> <div class="navfooter"> <ul> <li class="prev"> <a accesskey="p" href="changingowner.html" title= "Changing Ownership">Prev</a> <p> Changing Ownership </p> </li> <li class="next"> <a accesskey="n" href="whatnext.html" title= "What to do next">Next</a> <p> What to do next </p> </li> <li class="up"> <a accesskey="u" href="chapter.html" title= "Chapter 7. If You Are Going to Boot">Up</a>. </li> <li class="home"> <a accesskey="h" href="../index.html" title= "Cross-Compiled Linux From Scratch - Version CLFS-SVN-20060417-x86"> Home</a>. </li> </ul> </div> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -