⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grub.html

📁 LFS,名为linux from scratch
💻 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" lang="zh-CN" xml:lang="zh-CN">
  <head><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    <title>8.4. 使 LFS 系统能够启动</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="6.2">
    <div class="navheader">
      <div class="headertitles">
        <h4>Linux From Scratch - 版本 6.2</h4>
        <h3>第八章 使 LFS 系统能够启动</h3>
      </div>
      
  <ul class="headerlinks">
    <li class="prev"> <a accesskey="p" href="kernel.html" title="Linux-2.6.16.27">后退</a> 
      <p>Linux-2.6.16.27</p>
    </li>
    <li class="next"> <a accesskey="n" href="../chapter09/chapter09.html" title="结束">前进</a> 
      <p>结束</p>
    </li>
    <li class="up"><a accesskey="u" href="chapter08.html" title="第八章 使 LFS 系统能够启动">上一级</a></li>
    <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a></li>
  </ul>
    </div>
    <div class="sect1">
      <div class="titlepage">
        <h1 class="sect1">8.4. 使 LFS 系统能够启动</h1>
      </div>
      
  <p>你的全新 LFS 系统差不多要完成了。 最后要做的事是确保系统可以正常启动。下面的指令仅适用于 IA-32 架构的计算机,就是主流的 PC 机。 关于其它架构计算机 
    "<span class="quote">boot loading(引导装载)</span>"的信息可以在相应的资源里找到。</p>
      
  <p>引导装载是一个很复杂的问题,因此接下来会有一些警告的话。所以需要熟悉当前的引导装置和硬盘上其他操作系统需要能被启动。确定紧急启动盘已经准备了,假如电脑变成不能用了(不能启动)能够 
    "<span class="quote">援救</span>"。</p>
      <p>先前,我们为这个步骤编译和安装了 GRUB 引导装载程序做了准备。这个程序包括了在硬盘的指定位置上写的一些特殊 GRUB 文件,我们强烈推荐你创建一张 GRUB 引导软盘作为备份,插入一张空白软盘并输入下面的命令:</p>
      <pre class="userinput"><kbd class="command">dd if=/boot/grub/stage1 of=/dev/fd0 bs=512 count=1
dd if=/boot/grub/stage2 of=/dev/fd0 bs=512 seek=1</kbd></pre>
      <p>取出软盘并在安全的地方存放,现在,运行
        <span><strong class="command">grub</strong></span> shell:</p>
      <pre class="userinput"><kbd class="command">grub</kbd></pre>
      <p>GRUB 使用它自己的驱动器和分区命名结构,形式是 <span class="emphasis"><em>(hdn,m)</em></span>,这里的
        <span class="emphasis"><em>n</em></span> 是硬盘驱动号,
        <span class="emphasis"><em>m</em></span> 是分区号,
        两个都是从零开始。例如,分区 <tt class="filename">hda1</tt> 是GRUB的 <span class="emphasis"><em>(hd0,0)</em></span> , <tt class="filename">hdb3</tt>是 <span class="emphasis"><em>(hd1,2)</em></span>. 与 Linux 不同的是, GRUB 不把光驱作为硬盘驱动器。
       例如,假如 <tt class="filename">hdb</tt> 是光盘驱动器,第二个硬盘驱动器是
        <tt class="filename">hdc</tt>,第二个硬盘驱动器仍然是
        <span class="emphasis"><em>(hd1)</em></span>。</p>
      <p>用上面的信息为 root 分区(或boot 分区,假如是单独使用了分区的情况下)。
        下面的例子里假定 root 分区(或单独的
        boot分区)是 <tt class="filename">hda4</tt>.</p>
      <p>告诉 GRUB 在哪里搜索它的 <tt class="filename">stage{1,2}</tt> 文件。用 Tab 键能在各处让 GRUB 显示可选择项:</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">警告</h3>
        </div>
        <div class="admonbody">
          <p>下一个命令会覆盖当前的引导装载程序,如果不需要的话就不要运行这个命令,例如,使用第三方启动管理器来管理主引导记录
            (MBR)。当然,现在的情况是安装 GRUB 到 LFS 分区的“boot sector”更有意义。在这个例子里,下一个命令将变成 
            <strong class="userinput"><tt>setup (hd0,3)</tt></strong> 。</p>
        </div>
      </div>
      <p>告诉 GRUB 安装它自己到 <tt class="filename">hda</tt>的MBR:</p>
      <pre class="userinput"><kbd class="command">setup (hd0)</kbd></pre>
      <p>如果一切顺利,GRUB 会报告在
        <tt class="filename">/boot/grub</tt>找到它的文件。现在可以退出
         <span><strong class="command">grub</strong></span> shell:</p>
      <pre class="userinput"><kbd class="command">quit</kbd></pre>
      <p>创建一个 "<span class="quote">显示菜单</span>"文件定义 
        GRUB 的启动菜单:</p>
      <pre class="userinput"><kbd class="command">cat &gt; /boot/grub/menu.lst &lt;&lt; "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 6.2
root (hd0,3)
kernel /boot/lfskernel-2.6.16.27 root=/dev/hda4</tt>
EOF</kbd></pre>
      
  <p>如果需要可以为宿主系统增加一项,看起来如下:</p>
      <pre class="userinput"><kbd class="command">cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
<tt class="literal">title Red Hat
root (hd0,2)
kernel /boot/kernel-2.6.5 root=/dev/hda3
initrd /boot/initrd-2.6.5</tt>
EOF</kbd></pre>
  <p>如果是 Windows 的双启动系统,下面的项能够启动它:</p>
      <pre class="userinput"><kbd class="command">cat &gt;&gt; /boot/grub/menu.lst &lt;&lt; "EOF"
<tt class="literal">title Windows
rootnoverify (hd0,0)
chainloader +1</tt>
EOF</kbd></pre>
      
  <p>如果用 <span><strong class="command">info grub</strong></span> 不能获取足够的信息,更多 GRUB 资料可以在它的网站找到 
    <a href="http://www.gnu.org/software/grub/"><i>http://www.gnu.org/software/grub/</i></a>.</p>
      <p> FHS 规定 GRUB 的 <tt class="filename">menu.lst</tt>
       文件必须链接到 <tt class="filename">/etc/grub/menu.lst</tt>。为了符合这个规定,可以用下面的命令:
</p>
      <pre class="userinput"><kbd class="command">mkdir -v /etc/grub &amp;&amp;
ln -sv /boot/grub/menu.lst /etc/grub</kbd></pre>
    </div>
    <div class="navfooter">
      
  <ul>
    <li class="prev"> <a accesskey="p" href="kernel.html" title="Linux-2.6.16.27">后退</a> 
      <p>Linux-2.6.16.27</p>
    </li>
    <li class="next"> <a accesskey="n" href="../chapter09/chapter09.html" title="结束">前进</a> 
      <p>结束</p>
    </li>
    <li class="up"><a accesskey="u" href="chapter08.html" title="第八章 使 LFS 系统能够启动">上一级</a></li>
    <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a>. 
    </li>
  </ul>
    </div>
  </body>
</html>

⌨️ 快捷键说明

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