Handbook:AMD64/Blocks/Bootloader/zh-cn

选择一个引导器
完成配置Linux内核、安装系统工具和编辑配置文件，现在是时候去安装Linux安装的最后一个重要的片：引导器.

引导器负责在引导过程中启动内核——如果没有它，系统将不知道按下电源键后将如何进行.

For, we document how to configure either GRUB2 or LILO for BIOS based systems, and GRUB2 or efibootmgr for UEFI systems.

In this section of the Handbook a delineation has been made between emerging the boot loader's package and installing a boot loader to a system disk. Here the term emerge will be used to ask Portage to make the software package available to the system. The term install will signify the boot loader copying files or physically modifying appropriate sections of the system's disk drive in order to render the boot loader activated and ready to operate on the next power cycle.

Default: GRUB2
过去，Gentoo Linux建议使用的是一个现在叫作传统GRUB的引导器. 顾名思义，老的GRUB包不再积极地维护并且被GRUB2所取代. 关于传统GRUB的更多信息，请参考在Gentoo维基上的GRUB文章.

By default, the majority of Gentoo systems now rely upon GRUB2 (found in the package), which is the direct successor to GRUB Legacy. With no additional configuration, GRUB2 gladly supports older BIOS systems. With a small amount of configuration, necessary before build time, GRUB2 can support more than a half a dozen additional platforms. For more information, consult the Prerequisites section of the GRUB2 article.

Emerge
When using an older BIOS system supporting only MBR partition tables, no additional configuration is needed in order to emerge GRUB:



A note for UEFI users: running the the above command will output the enabled GRUB_PLATFORMS values before emerging. When using UEFI capable systems, users will need to ensure  is enabled (as it is the case by default). If that is not the case for the setup,  will need to be added to the  file before emerging GRUB2 so that the package will be built with EFI functionality:






 * 如果GRUB2在未先添加 到时就已经emerge过，可以添加这一行（像上面显示那样）然后通过的 选项来重新计算世界包集：



The GRUB2 software has now been merged to the system, but not yet installed.

Install
接下来，通过命令安装GRUB2所需的文件到目录. 假设第一块磁盘（引导系统的那块）是，将使用下面的一条命令：


 * 使用BIOS时：


 * 使用UEFI时：







Configure
接下来，基于用户在文件和中特别配置的脚本文件来生成GRUB2. 在大多数场景中，不需要由用户来配置，GRUB2就可以自动检测出哪个内核用于引导（位于中最高的那一个）以及根文件系统是什么.

要生成最终的GRUB2配置，运行命令：

需要注意至少找到一个Linux镜像在命令的输出中，它们是用来引导系统的. 如何使用一个initramfs或用建立内核，同样会检测到正确的initrd 镜像. 如果不是这样，进入到并使用命令检查内容. 如果文件确实不存在，回到内核配置和安装的介绍.

Emerge
LILO, the LInuxLOader, is the tried and true workhorse of Linux boot loaders. However, it lacks features when compared to GRUB. LILO is still used because, on some systems, GRUB does not work and LILO does. Of course, it is also used because some people know LILO and want to stick with it. Either way, Gentoo supports both bootloaders.

安装LILO是一件轻而易举的事，使用emerge就可以了.

Configure
要配置LILO，首先要创建 :

在配置文件中，小节（sections）被用于指向可引导的内核. 请确保内核文件（与内核版本号一起）和initramfs文件都可以被知晓，因为它们都需要被这个配置文件所引用.

如果initramfs是必须的，那么就更改配置文件以便引用这个initramfs文件，并且告诉initramfs根设备的所在位置.

如果额外的选项需要被传递到内核，使用 语句. 例如增加  语句来使能framebuffer：

使用 的用户应该了解他们的内核使用与安装CD相同的引导选项. 例如，如果对SCSI设备的支持需要被使能，就增加 到内核选项中.

现在保存这个文件并退出.

Install
To finish up, run the executable so LILO can apply the  settings to the system (I.E. install itself on the disk). Keep in mind that must be executed each time a new kernel is installed or a change has been made to the  file in order for the system to boot if the filename of the kernel has changed.

Alternative 2: efibootmgr
On UEFI based systems, the UEFI firmware on the system (in other words the primary bootloader), can be directly manipulated to look for UEFI boot entries. Such systems do not need to have additional (also known as secondary) bootloaders like GRUB2 in order to help boot the system. With that being said, the reason EFI-based bootloaders such as GRUB2 exist is to extend the functionality of UEFI systems during the boot process. Using is really for those who desire to take a minimalist (although more rigid) approach to booting their system; using GRUB2 (see above) is easier for the majority of users because it offers a flexible approach when booting UEFI systems.

记住应用程序不是一个引导器，它是一个和UEFI固件相互作用并更新它的设置，因为之前安装的Linux内核可以通过额外的选项（如果需要）来引导，或允许多重引导条目. 可以通过EFI变量（需要支持EFI变量的内核）来完成这个相互作用.

Be sure to read though the EFI stub kernel article before continuing. The kernel must have specific options enabled to be directly bootable by the system's UEFI firmware. It might be necessary to recompile the kernel. It is also a good idea to take a look at the article.

Those that have decided to take this approach must install the software:

Then, create the location, and then copy the kernel into this location, calling it :

接下来，告诉UEFI固件创建一个叫作“Gentoo”的引导条目，它拥有全新编译EFI桩Linux内核：

如果使用一个内存文件系统（initramfs），为它添加相应的引导选项：

完成这些变更后，当系统重新启动时，会有一个叫作“Gentoo”的引导条目.