|
@@ -1,4 +1,4 @@
|
|
|
-<?xml version="1.0" encoding="ISO-8859-1"?>
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
|
<!ENTITY % general-entities SYSTEM "../general.ent">
|
|
@@ -14,32 +14,45 @@
|
|
|
<address>&grub-url;</address>
|
|
|
</sect1info>
|
|
|
|
|
|
- <title>Using GRUB to Set Up the Boot Process</title>
|
|
|
+ <title>使用 GRUB 设定引导过程</title>
|
|
|
|
|
|
<sect2>
|
|
|
- <title>Introduction</title>
|
|
|
+ <title>概述</title>
|
|
|
|
|
|
- <warning><para>Configuring GRUB incorrectly can render your system
|
|
|
+ <!--warning><para>Configuring GRUB incorrectly can render your system
|
|
|
inoperable without an alternate boot device such as a CD-ROM. This
|
|
|
section is not required to boot your LFS system. You may just
|
|
|
want to modify your current boot loader, e.g. Grub-Legacy, GRUB2, or
|
|
|
- LILO.</para></warning>
|
|
|
+ LILO.</para></warning-->
|
|
|
+ <warning>
|
|
|
+ <para>如果您不小心错误地配置了 GRUB,而且没有 CD-ROM
|
|
|
+ 之类的备用引导设备,可能会导致您的系统完全无法使用。
|
|
|
+ 本节不是引导您的 LFS 系统的唯一方案,
|
|
|
+ 您可能只要修改现有的启动加载器(如 Grub-Legacy、GRUB2 或 LILO)
|
|
|
+ 配置即可引导 LFS。</para>
|
|
|
+ </warning>
|
|
|
|
|
|
|
|
|
- <para> Ensure that an emergency boot disk is ready to <quote>rescue</quote>
|
|
|
+ <!--para> Ensure that an emergency boot disk is ready to <quote>rescue</quote>
|
|
|
the computer if the computer becomes unusable (un-bootable). If you do not
|
|
|
already have a boot device, you can create one. In order for the procedure
|
|
|
below to work, you need to jump ahead to BLFS and install
|
|
|
<userinput>xorriso</userinput> from the <ulink
|
|
|
url="&blfs-book;multimedia/libisoburn.html">
|
|
|
- libisoburn</ulink> package.</para>
|
|
|
+ libisoburn</ulink> package.</para-->
|
|
|
+ <para>您务必保证自己拥有一个紧急引导磁盘,它在计算机不可用(不可引导)
|
|
|
+ 时能够 <quote>救援</quote> 计算机。如果您现在还没有引导设备,
|
|
|
+ 您可以执行下列命令创建一个。在运行下列命令前,您需要跳到 BLFS,
|
|
|
+ 安装包含 <command>xorriso</command> 的
|
|
|
+ <ulink url="&blfs-book;multimedia/libisoburn.html">libisoburn
|
|
|
+ </ulink> 软件包:</para>
|
|
|
|
|
|
<screen role="nodump"><userinput>cd /tmp
|
|
|
grub-mkrescue --output=grub-img.iso
|
|
|
xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></screen>
|
|
|
|
|
|
<note>
|
|
|
- <para>
|
|
|
+ <!--para>
|
|
|
To boot LFS on host systems that have UEFI enabled, the kernel needs to
|
|
|
have been built with the CONFIG_EFI_STUB capabality described in the
|
|
|
previous section. However, LFS can be booted using GRUB2 without such
|
|
@@ -48,15 +61,28 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></
|
|
|
url="http://www.linuxfromscratch.org/hints/downloads/files/lfs-uefi.txt">
|
|
|
the lfs-uefi.txt hint</ulink> at
|
|
|
http://www.linuxfromscratch.org/hints/downloads/files/lfs-uefi.txt.
|
|
|
- </para>
|
|
|
- </note>
|
|
|
+ </para-->
|
|
|
+ <para>为了在使用 UEFI 的宿主系统上引导 LFS ,在构建内核时,
|
|
|
+ 需要启用 CONFIG_EFI_STUB 功能,正如上一节所述。
|
|
|
+ 不过,可以使用 GRUB2 在没有该功能的情况下引导 LFS,
|
|
|
+ 前提是在系统 BIOS 设定中关闭 UEFI 模式和安全引导
|
|
|
+ (Secure Boot)功能。关于在 UEFI 环境下引导 LFS 的的详细信息,
|
|
|
+ 可以参阅 <ulink url="&hints-root;lfs-uefi.txt"/>。
|
|
|
+ </para>
|
|
|
+ </note>
|
|
|
+ <note><title>译注</title>
|
|
|
+ <para>以上 hint 版本较老,译者维护了它的更新版本,参阅
|
|
|
+<ulink url="https://linux.xidian.edu.cn/git/xry111/LFS-book/wiki/lfs-uefi"
|
|
|
+ />。
|
|
|
+ </para>
|
|
|
+ </note>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2>
|
|
|
- <title>GRUB Naming Conventions</title>
|
|
|
+ <title>GRUB 命名惯例</title>
|
|
|
|
|
|
- <para>GRUB uses its own naming structure for drives and partitions in
|
|
|
+ <!--para>GRUB uses its own naming structure for drives and partitions in
|
|
|
the form of <emphasis>(hdn,m)</emphasis>, where <emphasis>n</emphasis>
|
|
|
is the hard drive number and <emphasis>m</emphasis> is the partition
|
|
|
number. The hard drive number starts from zero, but the partition number
|
|
@@ -69,19 +95,37 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></
|
|
|
consider CD-ROM drives to be hard drives. For example, if using a CD
|
|
|
on <filename class="partition">hdb</filename> and a second hard drive
|
|
|
on <filename class="partition">hdc</filename>, that second hard drive
|
|
|
- would still be <emphasis>(hd1)</emphasis>.</para>
|
|
|
+ would still be <emphasis>(hd1)</emphasis>.</para-->
|
|
|
+ <para>GRUB 使用一种独特的命名结构,为驱动器和分区命名。
|
|
|
+ 分区名的形式为 <emphasis>(hdn,m)</emphasis>,这里
|
|
|
+ <emphasis>n</emphasis> 是硬盘驱动器编号,<emphasis>m</emphasis>
|
|
|
+ 是分区编号。硬盘驱动器编号从 0 开始,但分区号对于主分区来说从
|
|
|
+ 1 开始,而对于扩展分区来说从 5 开始。例如,分区
|
|
|
+ <filename class="partition">sda1</filename> 在 GRUB 中的名字是
|
|
|
+ <emphasis>(hd0, 1)</emphasis>,而
|
|
|
+ <filename class="partition">sda3</filename> 的名字是
|
|
|
+ <emphasis>(hd1, 3)</emphasis>。和 Linux 不同,
|
|
|
+ GRUB 不认为 CD-ROM 驱动器属于硬盘驱动器。例如,如果在
|
|
|
+ <filename class="partition">hdb</filename> 上有一个 CD-ROM 驱动器,
|
|
|
+ 而 <filename class="partition">hdc</filename>
|
|
|
+ 上有一个次要硬盘驱动器,则第二个驱动器仍然名为
|
|
|
+ <emphasis>hd1</emphasis>。</para>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2>
|
|
|
- <title>Setting Up the Configuration</title>
|
|
|
+ <title>设定 GRUB 配置</title>
|
|
|
|
|
|
- <para>GRUB works by writing data to the first physical track of the
|
|
|
+ <!--para>GRUB works by writing data to the first physical track of the
|
|
|
hard disk. This area is not part of any file system. The programs
|
|
|
there access GRUB modules in the boot partition. The default location
|
|
|
- is /boot/grub/.</para>
|
|
|
+ is /boot/grub/.</para-->
|
|
|
+ <para>GRUB 的工作方式是,将数据写入硬盘的第一个物理磁道。
|
|
|
+ 这里不属于任何文件系统,在启动时,
|
|
|
+ 第一个物理磁道中的程序从引导分区加载 GRUB 模块,
|
|
|
+ 默认在 /boot/grub 中查找模块。</para>
|
|
|
|
|
|
- <para>The location of the boot partition is a choice of the user that
|
|
|
+ <!--para>The location of the boot partition is a choice of the user that
|
|
|
affects the configuration. One recommendation is to have a separate small
|
|
|
(suggested size is 100 MB) partition just for boot information. That way
|
|
|
each build, whether LFS or some commercial distro, can access the same boot
|
|
@@ -91,24 +135,41 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></
|
|
|
linux kernel you just built in the previous section) to the new partition.
|
|
|
You will then need to unmount the partition and remount it as <filename
|
|
|
class="directory">/boot</filename>. If you do this, be sure to update
|
|
|
- <filename>/etc/fstab</filename>.</para>
|
|
|
-
|
|
|
- <para>Using the current lfs partition will also work, but configuration
|
|
|
- for multiple systems is more difficult.</para>
|
|
|
-
|
|
|
- <para>Using the above information, determine the appropriate
|
|
|
+ <filename>/etc/fstab</filename>.</para-->
|
|
|
+ <para>引导分区的位置由负责进行配置的用户自己决定,
|
|
|
+ 作者推荐创建一个小的(建议大小为 100 MB)分区,
|
|
|
+ 专门存放引导信息。这样,不同的 Linux 系统(无论是 LFS
|
|
|
+ 还是商业发行版)在启动时和启动后都能访问相同的引导文件。
|
|
|
+ 如果您选择这样做,您需要挂载这个单独的分区,将 /boot
|
|
|
+ 中已有的文件(例如上一节中构建的内核)移动到新的分区中。
|
|
|
+ 之后,解除该分区的挂载,并将它挂载为
|
|
|
+ <filename class="directory">/boot</filename>,
|
|
|
+ 而且还要注意更新 <filename>/etc/fstab</filename>。</para>
|
|
|
+
|
|
|
+ <!--para>Using the current lfs partition will also work, but configuration
|
|
|
+ for multiple systems is more difficult.</para-->
|
|
|
+ <para>直接使用 LFS 分区也是可以的,但这样在配置多系统启动时比较麻烦。
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <!--para>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 <filename
|
|
|
- class="partition">sda2</filename>.</para>
|
|
|
+ class="partition">sda2</filename>.</para-->
|
|
|
+ <para>根据以上信息,确定 LFS 根分区(或 boot 分区)的名称。
|
|
|
+ 下面假设 LFS 根分区(或 boot 分区)是
|
|
|
+ <filename class="partition">sda2</filename>。</para>
|
|
|
|
|
|
- <para>Install the GRUB files into <filename
|
|
|
- class="directory">/boot/grub</filename> and set up the boot track:</para>
|
|
|
+ <para>将 GRUB 文件安装到<filename
|
|
|
+ class="directory">/boot/grub</filename> 并设定引导磁道:</para>
|
|
|
|
|
|
<warning>
|
|
|
- <para>The following command will overwrite the current boot loader. Do not
|
|
|
+ <!--para>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).</para>
|
|
|
+ boot manager to manage the Master Boot Record (MBR).</para-->
|
|
|
+ <para>下列命令会覆盖当前启动引导器,如果这不是您希望的,
|
|
|
+ 不要运行该命令。例如,如果您使用第三方启动引导器管理主引导记录
|
|
|
+ (MBR)。</para>
|
|
|
</warning>
|
|
|
|
|
|
<screen role="nodump"><userinput>grub-install /dev/sda</userinput></screen>
|
|
@@ -127,9 +188,9 @@ xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso</userinput></
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="grub-cfg">
|
|
|
- <title>Creating the GRUB Configuration File</title>
|
|
|
+ <title>创建 GRUB 配置文件</title>
|
|
|
|
|
|
- <para>Generate <filename>/boot/grub/grub.cfg</filename>:</para>
|
|
|
+ <para>生成 <filename>/boot/grub/grub.cfg</filename>:</para>
|
|
|
|
|
|
<screen revision="sysv"><userinput>cat > /boot/grub/grub.cfg << "EOF"
|
|
|
<literal># Begin /boot/grub/grub.cfg
|
|
@@ -158,25 +219,35 @@ menuentry "GNU/Linux, Linux &linux-version;-lfs-&versiond;" {
|
|
|
EOF</userinput></screen>
|
|
|
|
|
|
|
|
|
- <note><para>From <application>GRUB</application>'s perspective, the
|
|
|
- kernel files are relative to the partition used. If you
|
|
|
- used a separate /boot partition, remove /boot from the above
|
|
|
- <emphasis>linux</emphasis> line. You will also need to change the
|
|
|
- <emphasis>set root</emphasis> line to point to the boot partition.
|
|
|
- </para></note>
|
|
|
+ <note><para>从 <application>GRUB</application>的视角来看,
|
|
|
+ 内核文件的位置相对于它使用的分区。如果您使用了单独的 /boot
|
|
|
+ 分区,需要从上面的 <emphasis>linux</emphasis> 行删除 /boot,
|
|
|
+ 然后修改 <emphasis>set root</emphasis> 行,
|
|
|
+ 指向 /boot 分区。</para></note>
|
|
|
|
|
|
- <para>GRUB is an extremely powerful program and it provides a tremendous
|
|
|
+ <!--para>GRUB is an extremely powerful program and it provides a tremendous
|
|
|
number of options for booting from a wide variety of devices, operating
|
|
|
systems, and partition types. There are also many options for customization
|
|
|
such as graphical splash screens, playing sounds, mouse input, etc. The
|
|
|
- details of these options are beyond the scope of this introduction.</para>
|
|
|
+ details of these options are beyond the scope of this introduction.</para-->
|
|
|
+ <para>GRUB 是一个很强大的程序,它提供了非常多的选项,
|
|
|
+ 可以支持多种设备、操作系统和分区类型,还有很多用于定制启动屏幕、
|
|
|
+ 声音、鼠标输入等的选项。这些选项的细节超过了本书的范围,
|
|
|
+ 不予讨论。</para>
|
|
|
|
|
|
- <caution><para>There is a command, <application>grub-mkconfig</application>, that
|
|
|
+ <!--caution><para>There is a command, <application>grub-mkconfig</application>, that
|
|
|
can write a configuration file automatically. It uses a set of scripts in
|
|
|
/etc/grub.d/ and will destroy any customizations that you make. These scripts
|
|
|
are designed primarily for non-source distributions and are not recommended for
|
|
|
LFS. If you install a commercial Linux distribution, there is a good chance
|
|
|
- that this program will be run. Be sure to back up your grub.cfg file.</para></caution>
|
|
|
+ that this program will be run. Be sure to back up your grub.cfg file.</para></caution-->
|
|
|
+ <caution><para>有一个命令 <application>grub-mkconfig</application>
|
|
|
+ 被用于自动创建配置文件。它使用 /etc/grub.d
|
|
|
+ 中的脚本创建新配置文件,这会覆盖您手动编写的 grub.cfg。
|
|
|
+ 这些脚本主要是为非源代码发行版设计的,
|
|
|
+ 在 LFS 中不推荐使用。但是,如果您安装了商业发行版,
|
|
|
+ 它很可能在发行版中被运行,记得备份 grub.cfg 以防它被覆盖。
|
|
|
+ </para></caution>
|
|
|
|
|
|
</sect2>
|
|
|
|