搜索

E.8.2. 配置文件指令

download PDF
下面是 GRUB 菜单配置文件里常用的指令:
  • chainloader </path/to/file> — 将指定文件作为链载入程序载入。使用到链载入程序的绝对路径替换 </path/to/file>。如果这个文件位于指定分区的第一个扇区,则可以使用块列表记号 +1
  • color <normal-color> <selected-color> — 允许在菜单中使用特定的颜色,其中使用两个颜色作为前端颜色和后端颜色。可以使用简单的颜色名称,如 red/black。例如:
    color red/black green/blue
  • default=<integer> — 用在菜单界面超时后安装的默认项目标题的序号来替换 <integer>
  • fallback=<integer> — 用在第一次尝试失败后所用的项目标题的序号来替换 <integer>
  • hiddenmenu — 当超过 timeout 所指定的时间后,阻止 GRUB 菜单界面的显示以及安装 default 条目。用户可以按 Esc 键来查看标准 GRUB 菜单。
  • initrd </path/to/initrd> — 使用户可以指定在引导时所用的初始 RAM 磁盘文件。用初始 RAM 磁盘文件的绝对路径来替换 </path/to/initrd>
  • kernel </path/to/kernel> <option-1> <option-N> — 指定引导操作系统时安装的内核文件。用 root 命令所指定的分区的绝对路径来替换 </path/to/kernel>。可以在内核安装时传入多个选项。
    这些选项为:
    • rhgbRed Hat 图形引导)— 显示引导过程动画而不是线性文本。
    • quiet — 删除在 Red Hat 图形引导动画开始前所有最重要的引导序列信息。
  • password=<password> — 阻止不知道密码的用户编辑这个菜单的项目。
    另外,也可以在 password=<password> 命令后指定其他的菜单配置文件。在这种情况下,GRUB 会重新引导第二阶段引导装载程序并使用这个菜单配置文件来创建菜单。如果不在这个命令后指定菜单配置文件,拥有密码的用户就可以编辑当前的配置文件。

    重要

    强烈 建议在每台机器中都设置引导装载程序密码。未经保护的引导装载程序程序可导致潜在攻击者修改系统引导选项,并获取对该系统的未授权访问。有关引导装载程序密码及密码一般安全性的详情请查看《Red Hat Enterprise Linux 安全性指南》《工作站安全性》一章。
  • map — 交换分配给两个硬盘的编号。例如:
    map (hd0) (hd3)
    map (hd3) (hd0)
    将编号 0 分配给第四个硬盘,编号 3 分配给第一个硬盘。这个选项在将您的系统配置为使用一个选项引导 Windows 操作系统时特别有用,因为 Windows 引导装载程序必须在第一个硬盘中找到 Windows 安装程序。
    例如:如果 Windows 安装程序在第四个硬盘中,下面这个 grub.conf 中的条目将允许 Windows 引导装载程序正确载入 Windows:
    title Windows
    map (hd0) (hd3)
    map (hd3) (hd0)
    rootnoverify (hd3,0)
    chainloader +1
  • root (<device-type><device-number>,<partition>) — 分配 GRUB 的 root 分区,如 (hd0,0),并挂载这个分区。要指定根据 EFI 引导管理器选择的引导驱动器,语法为 <device-type>,<partition>,比如 (bd,1)
  • rootnoverify (<device-type><device-number>,<partition>) — 分配 GRUB 的 root 分区,就象 root 命令一样,但不挂载此分区。
  • timeout=<integer> — 指定 GRUB 在安装 default 命令中设置的项目前所等待时间间隔,以秒为单位。
  • splashimage=<path-to-image> — 指定 GRUB 引导时所使用的闪屏映像文件的位置。
  • title group-title — 指定和用来安装内核或操作系统的特定的一组命令一起使用的标题。
  • device grub-device-name uefi-device-name — Assigns a GRUB device name to refer to a specific UEFI device. The argument grub-device-name should be replaced with a GRUB device name, for example (hd0). The argument uefi-device-name should be replaced with a UEFI device name in the form of either HD(number, start, size, signature), or CD(index, start, size), where number is the partition number, starting at 1, index is the index of the CD's El Torito boot entry, start and size are the start position and size of the partition respectively, in sectors, in hexadecimal format, and signature is the partition's unique GUID.
菜单配置文件里的注释用井号(#)开头。
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.