GRUB2官方文档翻译项目2-03

启动讨论 grub/grub2/syslinux/grub4dos/Lilo
回复
kin3z
帖子: 56
注册时间: 2011-11-01 14:22

GRUB2官方文档翻译项目2-03

#1

帖子 kin3z » 2015-05-12 10:27

3 Installation
3 安装
**************

In order to install GRUB as your boot loader, you need to first install the GRUB system and utilities under your UNIX-like operating system (*note Obtaining and Building GRUB::). You can do this either from the source tarball, or as a package for your OS.
为了在你的启动引导中安装GRUB,你需要在类Unix操作系统上安装 GRUB系统工具(*获取和构建GRUB),既可以通过源码编译也可以 安装相应系统的软件包。

After you have done that, you need to install the boot loader on a drive (floppy or hard disk) by using the utility 'grub-install' (*note Invoking grub-install::) on a UNIX-like OS.
完了之后,你需要在类Unix操作系统上通过'grub-install'工具在 软盘或硬盘驱动器上安装启动引导。

GRUB comes with boot images, which are normally put in the directory '/usr/lib/grub/<cpu>-<platform>' (for BIOS-based machines '/usr/lib/grub/i386-pc'). Hereafter, the directory where GRUB images are initially placed (normally '/usr/lib/grub/<cpu>-<platform>') will be called the "image directory", and the directory where the boot loader needs to find them (usually '/boot') will be called the "boot directory".
与GRUB配套的引导镜像,一般存放在'/usr/lib/grub/<cpu>-<platform>'(如基于 BIOS的机器为'/usr/lib/grub/i386-pc')。下文将这个GRUB镜像初始位置称为“镜像 目录”,而引导启动器的加载系统镜像的位置(通常为‘/boot’)称为“引导目录”。

3.1 Installing GRUB using grub-install
3.1使用grub-install安装GRUB
======================================

For information on where GRUB should be installed on PC BIOS platforms, *note BIOS installation::.
若想知道关于GRUB安装在电脑BIOS平台哪里的信息,查找BIOS installation

In order to install GRUB under a UNIX-like OS (such as GNU), invoke the program 'grub-install' (*note Invoking grub-install::) as the superuser ("root").
为了安装GRUB到类Unix系统(如GUN),需要以超级用户root权限运行 grub-install命令

The usage is basically very simple. You only need to specify one argument to the program, namely, where to install the boot loader. The argument has to be either a device file (like '/dev/hda'). For example, under Linux the following will install GRUB into the MBR of the first IDE disk:
用法很简单,你需要给该命令指定一个参数--你需要安装启动引导的路径。这个参数 既可以是一个设备文件(类似/dev/hda),例如,在linux下下面的命令为将GRUB 安装到第一快IDE盘的mbr分区
# grub-install /dev/hda
# grub-install /dev/hda
Likewise, under GNU/Hurd, this has the same effect:
或者在GUN/Hurd下,下面命令有同样的效果:
# grub-install /dev/hd0
# grub-install /dev/hd0

But all the above examples assume that GRUB should put images under the '/boot' directory. If you want GRUB to put images under a directory other than '/boot', you need to specify the option '--boot-directory'. The typical usage is that you create a GRUB boot floppy with a filesystem. Here is an example:
但是以上的例子都假设GRUB将镜像放在/boot目录下。如果你想GRUB把镜像放在 其它目录下,你需要指明"--boot-directory"选项。典型用法是创建一个带有文件系统 的GRUB启动盘。举个例子:
# mke2fs /dev/fd0
# mke2fs /dev/fd0
# mount -t ext2 /dev/fd0 /mnt
# mount -t ext2 /dev/fd0 /mnt
# mkdir /mnt/boot
# mkdir /mnt/boot
# grub-install --boot-directory=/mnt/boot /dev/fd0
# grub-install --boot-directory=/mnt/boot /dev/fd0
# umount /mnt
# umount /mnt

Some BIOSes have a bug of exposing the first partition of a USB drive as a floppy instead of exposing the USB drive as a hard disk (they call it "USB-FDD" boot). In such cases, you need to install like this:
某些BIOS存在bug称之为USB-FDD启动。即它们错误的将USB设备的第一个分区作为软盘显示,而不是将一个USB作为一个硬盘。在这种情况下,你需要按照如下方式安装:
# losetup /dev/loop0 /dev/sdb1
# losetup /dev/loop0 /dev/sdb1
# mount /dev/loop0 /mnt/usb
# mount /dev/loop0 /mnt/usb
# grub-install --boot-directory=/mnt/usb/bugbios --force --allow-floppy /dev/loop0
# grub-install --boot-directory=/mnt/usb/bugbios --force --allow-floppy /dev/loop0

This install doesn't conflict with standard install as long as they are in separate directories.
只要它们在不同目录,这种安装不会和标准安装方法冲突。

Note that 'grub-install' is actually just a shell script and the real task is done by 'grub-mkimage' and 'grub-setup'. Therefore, you may run those commands directly to install GRUB, without using 'grub-install'. Don't do that, however, unless you are very familiar with the internals of GRUB. Installing a boot loader on a running OS may be extremely dangerous.
注意"grub-install"只是一个shell脚本,真正起作用的是"grub-mkimage"和 "grub-setup"命令。因此,你也可以直接运行这两个命令安装GRUB,而不必使用 "grub-install";然而,如果你不是十分熟悉GRUB的内部原理,不要使用这些命令。 在一个正在运行的操作系统上安装启动引导是极其危险的。

3.2 Making a GRUB bootable CD-ROM
3.2 制作一个GRUB启动光驱
=================================

GRUB supports the "no emulation mode" in the El Torito specification(1) (*note Making a GRUB bootable CD-ROM-Footnote-1::). This means that you can use the whole CD-ROM from GRUB and you don't have to make a floppy or hard disk image file, which can cause compatibility problems.
GRUB在EI Torito(1)光驱上支持"非模拟模式",这意味着你可以从GRUB利用整个光驱而不必 制作一个软盘或硬盘镜像文件,后者有可能导致兼容性问题。

For booting from a CD-ROM, GRUB uses a special image called 'cdboot.img', which is concatenated with 'core.img'. The 'core.img' used for this should be built with at least the 'iso9660' and 'biosdisk' modules. Your bootable CD-ROM will usually also need to include a configuration file 'grub.cfg' and some other GRUB modules.
要从光驱启动,GRUB使用了一个叫做'cdboot.img'的特殊镜像,并且和'core.img'交互, 用于交互的core.img镜像应至少由'iso9660'和'biosdisk'模块构建。你的可启动光驱通常也需要包含一个grub.cfg配置文件和一些其它的GRUB模块。

To make a simple generic GRUB rescue CD, you can use the 'grub-mkrescue' program (*note Invoking grub-mkrescue::):
要制作一个简易的通用GRUB恢复CD,你可以使用"grub-mkrescue"命令:
$ grub-mkrescue -o grub.iso
$ grub-mkrescue -o grub.iso

You will often need to include other files in your image. To do this, first make a top directory for the bootable image, say, 'iso':
通常你需要在你的镜像里包含其它文件,为此,首先新建一个装启动镜像的 上层目录,可以 叫做'iso':
$ mkdir iso
$ mkdir iso

Make a directory for GRUB:
为GRUB新建一个目录:
$ mkdir -p iso/boot/grub
$ mkdir -p iso/boot/grub

If desired, make the config file 'grub.cfg' under 'iso/boot/grub' (*note Configuration::), and copy any files and directories for the disc to the directory 'iso/'.
如果需要,在'iso/boot/grub'建立'grub.cfg'配置文件,然后复制所有制盘需要的 文件和目录到"iso/"目录下。
Finally, make the image:
最后,制作镜像:
$ grub-mkrescue -o grub.iso iso
$ grub-mkrescue -o grub.iso iso

This produces a file named 'grub.iso', which then can be burned into a CD (or a DVD), or written to a USB mass storage device.
这将一个产生名为grub.iso的文件,它可以被刻录到一张CD(或DVD)中,也 可以被写入到一个USB大容量存储设备中。

The root device will be set up appropriately on entering your 'grub.cfg' configuration file, so you can refer to file names on the CD without needing to use an explicit device name. This makes it easier to produce rescue images that will work on both optical drives and USB mass storage devices.
通过grub.cfg配置文件根设备将会被合理地设置,因此你可以在CD中引用文件名而 不需要使用详细的设备名称。这将使得生产能同时工作在光驱和USB存储设备中的修复 镜像更加容易。
(1) El Torito is a specification for bootable CD using BIOS functions.
(1) EI Torito是一个具有BIOS功能的可启动光驱的规范。

3.3 The map between BIOS drives and OS devices
3.3 BIOS驱动和操作系统设备间的映射
==============================================

If the device map file exists, the GRUB utilities ('grub-probe', 'grub-setup', etc.) read it to map BIOS drives to OS devices. This file consists of lines like this:
如果设备的映射文件存在,那么GRUB组件("grub-probe"、"grub-setup" 等等)会读取它将BIOS驱动器映射至操作系统设备。该文件有像这样的文本行 组成:
(DEVICE) FILE
(DEVICE) FILE

DEVICE is a drive specified in the GRUB syntax (*note Device syntax::), and FILE is an OS file, which is normally a device file.
DEVICE是GRUB语法中指明的驱动器,而FILE是一个操作系统文件,通常是一个设 备文件。

Historically, the device map file was used because GRUB device names had to be used in the configuration file, and they were derived from BIOS drive numbers. The map between BIOS drives and OS devices cannot always be guessed correctly: for example, GRUB will get the order wrong if you exchange the boot sequence between IDE and SCSI in your BIOS.
历史上,设备映射文件被使用是因为GRUB设备名在配置文件中必须被使用,并且它们 由BIOS驱动号衍生而来。BIOS驱动器和OS设备间的映射通常不能正确的被猜到:例如, 如果你在BIOS中改变IDE和SCSI的启动顺序,GRUB就会将顺序弄错。

Unfortunately, even OS device names are not always stable. Modern versions of the Linux kernel may probe drives in a different order from boot to boot, and the prefix ('/dev/hd*' versus '/dev/sd*') may change depending on the driver subsystem in use. As a result, the device map file required frequent editing on some systems.
不幸的是,尽管OS设备名称不总是稳定的,现代的Linux内核会在启动时以不同的 顺序检测驱动器,并且前缀('/dev/hd' 或'/dev/sd*)会依赖于驱动器使用的子系 统而改变。结果是,在一些系统上设备映射文件需要被频繁地修改。

GRUB avoids this problem nowadays by using UUIDs or file system labels when generating 'grub.cfg', and we advise that you do the same for any custom menu entries you write. If the device map file does not exist, then the GRUB utilities will assume a temporary device map on the fly. This is often good enough, particularly in the common case of single-disk systems.
如今,在产生grub.cfg文件时,GRUB通过使用UUIDs或文件系统标记的方法避免了 这一问题。我们也建议你在定制入口菜单时也这么做。如果设备映射文件不存在,那么 GRUB组件会动态地假设一个临时的设备映射。这已经足够好了,尤其在一般的单磁盘 系统情况下。

However, the device map file is not entirely obsolete yet, and it is used for overriding when current environment is different from the one on boot. Most common case is if you use a partition or logical volume as a disk for virtual machine. You can put any comments in the file if needed, as the GRUB utilities assume that a line is just a comment if the first character is '#'.
然而,并不意味着设备映射文件该完全被淘汰,当当前环境不同于启动环境时它 被用来重载。最常见的情况是如果你使用一个分区或一个逻辑卷当作虚拟机的磁盘, 需要的话你可以在文件中加入任何注释,因为GRUB会将一个以'#'开头的行当作注释。

3.4 BIOS installation
3.4 安装到BIOS
=====================

MBR
MBR方式
===

The partition table format traditionally used on PC BIOS platforms is called the Master Boot Record (MBR) format; this is the format that allows up to four primary partitions and additional logical partitions. With this partition table format, there are two ways to install GRUB: it can be embedded in the area between the MBR and the first partition (called by various names, such as the "boot track", "MBR gap", or "embedding area", and which is usually at least 31 KiB), or the core image can be installed in a file system and a list of the blocks that make it up can be stored in the first sector of that partition.
传统的PC BIOS平台是使用分区列表格式作为主要引导记录(MBR)的格式;这样的格式最多只允许四个主分区或四个逻辑分区。基于这样的分区列表格式,有两种安装GRUB的方法:他能够嵌入到MBR与第一个分区之间的区域(这有很多版本的称呼,例如叫"引导磁道(boot track)","MBR间隔(MBR gap)",或"嵌入区域(embedding area)",还有这区域通常至少有31KiB),或者把GRUB的内核镜像安装到文件系统的分区列表里从而实现让其储存到该分区的第一个扇区上。


Each of these has different problems. There is no way to reserve space in the embedding area with complete safety, and some proprietary software is known to use it to make it difficult for users to work around licensing restrictions; and systems are sometimes partitioned without leaving enough space before the first partition. On the other hand, installing to a filesystem means that GRUB is vulnerable to its blocks being moved around by filesystem features such as tail packing, or even by aggressive fsck implementations, so this approach is quite fragile; and this approach can only be used if the '/boot' filesystem is on the same disk that the BIOS boots from, so that GRUB does not have to rely on guessing BIOS drive numbers.
每一种都有不同的问题。无法保证嵌入到预留位置区域的做法是绝对安全的,因为已知的一些专有软件也在使用此方法这样造成了运行工作在许可限制上的困难;并且有些系统分区在分出第一个分区之前没有留下足够的空间。而另一方面,安装到文件系统意味着GRUB是脆弱的因为储存它的块可能被文件系统具有的封装特性而被移走,或者甚至被具有侵略性的fsck(可能是一个指令工具)实现破坏,所以这个安装方式很脆弱;这种方法只能用于在同一个磁盘里分有'/boot'分区的文件系统接收来自BIOS的引导,因此BRUB不需要依赖于猜测BIOS驱动器的号。

The GRUB development team generally recommends embedding GRUB before the first partition, unless you have special requirements. You must ensure that the first partition starts at least 31 KiB (63 sectors) from the start of the disk; on modern disks, it is often a performance advantage to align partitions on larger boundaries anyway, so the first partition might start 1 MiB from the start of the disk.
GRUB开发团队一般推荐把GRUB嵌入到第一个分区,除非你有特殊的要求。你必须确保第一分区的头部分最少有31KiB(63个扇区)的可用空间并且处于你要用作引导的硬盘之上,对齐的分区通常在性能上是有优势的反正大的边界(可能指硬盘容量),因此第一分区也许从磁盘的1MiB开始。

GPT
GPT
===

Some newer systems use the GUID Partition Table (GPT) format. This was specified as part of the Extensible Firmware Interface (EFI), but it can also be used on BIOS platforms if system software supports it; for example, GRUB and GNU/Linux can be used in this configuration. With this format, it is possible to reserve a whole partition for GRUB, called the BIOS Boot Partition. GRUB can then be embedded into that partition without the risk of being overwritten by other software and without being contained in a filesystem which might move its blocks around.
一些较新的系统使用GUID分区表(GPT)格式。这是可扩展固件接口(EFI)所指定的一部分,只要系统软件支持也可以转为使用BIOS平台;例如,GRUB和GNU/Linux就是使用于这样的配置。使用这种格式,是能够保存下整个GRUB分区,这称为BIOS引导分区。GRUB能够没有风险地嵌套到这个分区并且不被其他软件所覆盖或被覆盖,并且不会被文件系统去移动它的块。

When creating a BIOS Boot Partition on a GPT system, you should make sure that it is at least 31 KiB in size. (GPT-formatted disks are not usually particularly small, so we recommend that you make it larger than the bare minimum, such as 1 MiB, to allow plenty of room for growth. ) You must also make sure that it has the proper partition type. Using GNU Parted, you can set this using a command such as the following:
当创建一个GPT系统的BIOS引导分区时,你应该确保至少有31KiBd的大小。(GPT-格式化后的磁盘通常不会特别小,所以我们建议你让它大于最低限度,例如1MiB,让其有足够的空间去增长。)你还必须确保适当的分区类型。使用GNU Parted,你可以设置使用例如一下命令:
# parted /dev/DISK set PARTITION-NUMBER bios_grub on
# parted /dev/DISK set PARTITION-NUMBER bios_grub on

If you are using gdisk, set the partition type to '0xEF02'. With partitioning programs that require setting the GUID directly, it should be '21686148-6449-6e6f-744e656564454649'.
如果你使用的是Gdisk,设置分区模式为'0xEF02'。并且按照分区程序要求设置它的GUID,它应该为 '21686148-6449-6e6f-744e656564454649'.

*Caution:* Be very careful which partition you select! When GRUB finds a BIOS Boot Partition during installation, it will automatically overwrite part of it. Make sure that the partition does not contain any other data.
*警告:* 你要非常小心地去选择哪个分区!当GRUB安装期间发现BIOS引导分区时,它会自动覆盖BIOS引导分区里的一部分。确保这个分区不包含任何其他信息。
上次由 kin3z 在 2015-05-19 13:09,总共编辑 1 次。
头像
lhw828
帖子: 2797
注册时间: 2007-03-15 16:58
来自: 湖北武汉
联系:

Re: GRUB2官方文档翻译项目2-03

#2

帖子 lhw828 » 2015-05-16 23:33

好像错区了吧。。翻译文档怎么在这里。
kin3z
帖子: 56
注册时间: 2011-11-01 14:22

Re: GRUB2官方文档翻译项目2-03

#3

帖子 kin3z » 2015-05-18 10:52

lhw828 写了:好像错区了吧。。翻译文档怎么在这里。
因为这里是GRUB2引导的栏目,所以就放这里了。。。。
而且最主要的我不是公布,而是发出来给所有的人来更正,查阅,完善。。。
最后如果完成与完善了,我才再考虑公布方式。。。因为现在单初步翻译已经是蜗牛的速度了。。。
:em06
小饼仙子
帖子: 13
注册时间: 2014-03-20 8:58
系统: windowsxp

Re: GRUB2官方文档翻译项目2-03

#4

帖子 小饼仙子 » 2015-05-18 18:01

Some BIOSes have a bug of exposing the first partition of a USB drive as a floppy instead of exposing the USB drive as a hard disk (they call it "USB-FDD" boot). In such cases, you need to install like this:
有些BIOS存在一些问题,即无法将USB驱动器的第一个分区显示为软盘而是显示 为硬盘(被称为USB-FDD启动),在这种情况下,你需要像这样安装:

似乎应该是
某些BIOS存在bug称之为USB-FDD启动。即它们错误的将USB设备的第一个分区作为软盘显示,而不是将一个USB作为一个硬盘。在这种情况下,你需要按照如下方式安装:
kin3z
帖子: 56
注册时间: 2011-11-01 14:22

Re: GRUB2官方文档翻译项目2-03

#5

帖子 kin3z » 2015-05-19 13:11

小饼仙子 写了:Some BIOSes have a bug of exposing the first partition of a USB drive as a floppy instead of exposing the USB drive as a hard disk (they call it "USB-FDD" boot). In such cases, you need to install like this:
有些BIOS存在一些问题,即无法将USB驱动器的第一个分区显示为软盘而是显示 为硬盘(被称为USB-FDD启动),在这种情况下,你需要像这样安装:

似乎应该是
某些BIOS存在bug称之为USB-FDD启动。即它们错误的将USB设备的第一个分区作为软盘显示,而不是将一个USB作为一个硬盘。在这种情况下,你需要按照如下方式安装:
修改好了,谢谢! :em11
回复