https://wiki.archlinux.org/api.php?action=feedcontributions&user=%E7%A5%9E%E6%A5%BD%E5%9D%82%E8%8A%B1%E7%81%AB&feedformat=atom
ArchWiki - User contributions [en]
2024-03-28T11:38:22Z
User contributions
MediaWiki 1.41.0
https://wiki.archlinux.org/index.php?title=Systemd-boot_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=599640
Systemd-boot (简体中文)
2020-02-29T16:31:13Z
<p>神楽坂花火: 更新过时的翻译</p>
<hr />
<div>{{lowercase title}}<br />
[[Category:Boot loaders (简体中文)]]<br />
[[de:Systemd-boot]]<br />
[[en:Systemd-boot]]<br />
[[es:Systemd-boot]]<br />
[[ja:Systemd-boot]]<br />
[[ru:Systemd-boot]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Arch boot process}}<br />
{{Related|Secure Boot}}<br />
{{Related|Unified Extensible Firmware Interface (简体中文)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|Systemd-boot|2019-03-16|567880}}<br />
'''systemd-boot''' (以前被称为'''gummiboot''') 是可以执行 EFI 镜像文件的简单 UEFI 启动管理器。启动的内容可以通过一个配置(glob)或者屏幕菜单选择。Arch 默认安装的 {{Pkg|systemd}} 提供了这个功能。<br />
<br />
配置很简单,但是只能启动 EFI 可执行程序,例如 Linux 内核 [[EFISTUB]], UEFI Shell, GRUB, Windows Boot Manager等。<br />
<br />
{{Note|本文用 {{ic|$esp}} 表示[[EFI system partition|EFI 系统分区]],也就是 ESP 的挂载位置。}}<br />
<br />
== 安装 ==<br />
<br />
=== 安装 EFI 启动管理器 ===<br />
要安装 ''systemd-boot'' EFI 启动管理器,首先确保启动方式是 UEFI 模式,可以访问 [[Unified Extensible Firmware Interface#UEFI variables|UEFI 变量]]。用 {{ic|efivar --list}} 命令进行检查,如果没有安装 {{Pkg|efivar}} ,使用 {{ic|ls /sys/firmware/efi/efivars}} (如果目录存在,系统是以 UEFI 模式启动的)。<br />
<br />
''systemd-boot'' 仅可以从[[EFI system partition|ESP]] 分区加载 [[EFISTUB]] 内核。要持续更新内核,建议将 ESP 挂载到 {{ic|/boot}}. 如果没将 ESP 挂载到 {{ic|/boot}},需要手动将内核和 initramfs 复制到 ESP. 详情请参考 [[EFI system partition#Alternative mount points]] .<br />
<br />
下面的例子中会用 {{ic|$esp}} 代替 EFI 系统分区的实际位置,例如 {{ic|/boot}}。<br />
<br />
ESP 挂载到 {{ic|''esp''}} 后,使用 {{man|1|bootctl}} 将 ''systemd-boot'' 安装到 EFI 系统分区: <br />
<br />
# bootctl --path=''esp'' install<br />
<br />
在 x64 架构的系统上,两个完全一样的二进制文件 {{ic|''esp''/EFI/systemd/systemd-bootx64.efi}} 和 {{ic|''esp''/EFI/BOOT/BOOTX64.EFI}} 会被复制到 ESP. 然后将 ''systemd-boot'' 设置为 EFI 启动管理器的默认 EFI 程序(默认启动项)。<br />
<br />
要完成安装,请 [[#配置|配置]] ''systemd-boot''。<br />
<br />
=== 更新 EFI 启动管理器 ===<br />
<br />
每当 ''systemd-boot'' 有新版本时,用户都需要更新启动管理器。<br />
<br />
==== 手动更新 ====<br />
<br />
更新 ''systemd-boot'' 需要使用 ''bootctl''。如果没指定 {{ic|path}},会按顺序检查 {{ic|/efi}}, {{ic|/boot}} 和 {{ic|/boot/efi}}。 <br />
<br />
# bootctl update<br />
<br />
可以用 {{ic|path}} 指定具体位置:<br />
<br />
# bootctl --path=''esp'' update<br />
<br />
{{Note|这条命令同样用于在移除 ''gummiboot'' 之前迁移。但是如果该软件包已被删除,请运行 {{ic|1=bootctl --path=''esp'' install}}。}}<br />
<br />
==== 自动更新 ====<br />
<br />
软件包 {{AUR|systemd-boot-pacman-hook}} 提供了一个 [[Pacman hook]] 以自动化更新过程。 [[安装|安装]] 该软件包将添加一个在每次更新 {{Pkg|systemd}} 时执行的 hook。<br />
<br />
或者,不安装 ''systemd-boot-pacman-hook'' 实现相同功能,在 {{ic|/etc/pacman.d/hooks/}} 放置以下 Pacman Hook:<br />
<br />
{{hc|/etc/pacman.d/hooks/100-systemd-boot.hook|2=<br />
[Trigger]<br />
Type = Package<br />
Operation = Upgrade<br />
Target = systemd<br />
<br />
[Action]<br />
Description = Updating systemd-boot<br />
When = PostTransaction<br />
Exec = /usr/bin/bootctl update<br />
}}<br />
<br />
== 配置 ==<br />
<br />
=== 启动选单配置 ===<br />
<br />
配置文件保存于 {{ic|''esp''/loader/loader.conf}} ,可指定以下设置:<br />
<br />
* {{ic|default}} – [[#增加启动选项]] 中默认选择的选项;不带 ''.conf'' 后缀,可以使用通配符,例如 {{ic|arch-*}};<br />
* {{ic|timeout}} – 启动默认选项前的超时时间(以秒为单位)。如果未设定,选单仅在启动时按空格键(或大多数其他键)显示;<br />
* {{ic|editor}} – 是否启用内核参数编辑器。 {{ic|yes}} (默认)为启用, {{ic|no}} 为禁用;因为用户可以添加 {{ic|1=init=/bin/bash}} 以绕过密码获取 root 权限,如果未经授权的人可以使用这台机器,强烈建议将此选项设置为 {{ic|no}} ;<br />
* {{ic|auto-entries}} – 自动为 Windows、EFI Shell 和 Default Loader 添加选项, {{ic|1}} (默认)启用, {{ic|0}} 为禁用;<br />
* {{ic|auto-firmware}} – 显示「重启到 UEFI 固件设置」的选项, {{ic|1}} (默认)启用, {{ic|0}} 为禁用;<br />
* {{ic|console-mode}} – changes UEFI console mode: {{ic|0}} for 80x25, {{ic|1}} for 80x50, {{ic|2}} and above for non-standard modes provided by the device firmware, if any, {{ic|auto}} picks a suitable mode automatically, {{ic|max}} for highest available mode, {{ic|keep}} (default) for the firmware selected mode.<br />
* {{ic|random-seed-mode}} - 控制是否从文件 {{ic|''esp''/loader/random-seed}} 中读取随机种子。如果设为 {{ic|with-system-token}} (默认),仅在设置了 EFI 变量 {{ic|LoaderSystemToken}} 的情况下才从文件加载种子;如果设为 {{ic|always}},即使未设置 EFI 变量,它也会从文件加载种子;如果设为 {{ic|off}} 文件将被忽略。<br />
现有设置的详细解释和对应的参数位于 {{man|5|loader.conf}} 手册。以下是一个简单的示例:<br />
<br />
{{hc|''esp''/loader/loader.conf|<br />
default arch<br />
timeout 4<br />
console-mode max<br />
editor no<br />
}}<br />
<br />
{{Tip|<br />
* {{ic|default}} 和 {{ic|timeout}} 可在启动选单中修改并保存为 EFI 变量,这些选项会被覆盖。<br />
* {{ic|bootctl set-default ""}} 可用于清除覆盖了 {{ic|default}} 选项的 EFI 变量。<br />
* 基本配置文件示例位于 {{ic|/usr/share/systemd/bootctl/loader.conf}}。}}<br />
<br />
=== 增加启动选项 ===<br />
{{Note|如果存在的话,bootctl 会自动为 "'''Windows Boot Manager (Windows 启动管理器)'''" ({{ic|\EFI\Microsoft\Boot\Bootmgfw.efi}}), "'''EFI Shell'''" ({{ic|\shellx64.efi}}) 和 "'''EFI Default Loader'''" ({{ic|\EFI\Boot\bootx64.efi}})增加启动选项. 但并不会为其他EFI应用程序创建启动选项,所以需要进行进一步设置.<br />
<br />
如果你是和Windows 组成双重启动,建议禁用 [[Dual boot with Windows#Fast_Start-Up|Windows 中的"快速启动"]]{{Broken section link}} 选项.}}<br />
<br />
如果需要 Intel [[microcode]],不要忘了修改 {{ic|initrd}}。<br />
<br />
{{Tip|你能用 {{ic|1=blkid -s PARTUUID -o value /dev/sdxY}} 找到某个分区的PARTUUID, 'x' 和 'Y' 分别是磁盘和分区编号.稍后可能需要这些信息.}}<br />
<br />
bootctl 会在 {{ic|$esp/loader/entries/*.conf}} 搜索启动选项– 一个文件中只能包含一个启动选项,下面是参数列表:<br />
<br />
* {{ic|title}} – '''必须选项.''' 系统的名称.<br />
<br />
* {{ic|version}} – 内核版本,只在有多个{{ic|title}} 时需要.<br />
<br />
* {{ic|machine-id}} – 通过 {{ic|/etc/machine-id}}用于区分不同设备的名称, 只在有多个{{ic|title}} 和 {{ic|version}} 时需要.<br />
<br />
* {{ic|efi}} – 要启动的EFI应用程序的位置,以 ({{ic|$esp}}) 为相对路径,; 例如 {{ic|/vmlinuz-linux}}. '''需要此选项或是 {{ic|linux}} (参阅下文) 的一项.'''<br />
<br />
* {{ic|options}} – 传递给 EFI 应用程序或内核启动的参数,可选.但如果你要启动linux,至少需要 {{ic|1=initrd=''efipath''}} 和 {{ic|1=root=''dev''}}选项.<br />
<br />
要启动linux,你还可以指定 {{ic|linux ''path-to-vmlinuz''}} 和 {{ic|initrd ''path-to-initramfs''}};这会自动转换成 {{ic|efi ''path''}} 和 {{ic|1=options initrd=''path''}} – 这个语法只是为了方便,在功能上并没有区别. <br />
<br />
==== 一般的安装选项 ====<br />
<br />
这是一个根分区既不在LVM逻辑卷又没有加密时的配置选项:<br />
<br />
{{hc|$esp/loader/entries/arch.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw<br />
}}<br />
<br />
注意这个例子中用PARTUUID(或是PARTLABEL)来标识一个GPT分区(和UUID/LABEL不同,它标识一个文件系统).使用因为PARTUUID/PARTLABEL是因为它不像UUID/LABEL会在格式化时改变,也不像 /dev/sd* 会在某些时候交换.在某些无文件系统分区(或是不支持卷标的LUKS 加密卷)上也能工作.<br />
<br />
{{Tip|{{ic|/usr/share/systemd/bootctl}} 提供了参考示例文件.}}<br />
<br />
==== 根分区在LVM 逻辑卷上时====<br />
{{Warning|如果没有一个在LVM卷组外的{{ic|/boot}}分区,不要用 Systemd-boot .}}<br />
<br />
这是一个根分区在[[LVM]]逻辑卷上时的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-lvm.conf|2=<br />
title Arch Linux (LVM)<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=/dev/mapper/<VolumeGroup-LogicalVolume> rw<br />
}}<br />
<br />
用实际的逻辑卷组和逻辑卷名替换 {{ic|<VolumeGroup-LogicalVolume>}} (例如 {{ic|1=root=/dev/mapper/volgroup00-lvolroot}}). 也可以使用UUID:<br />
....<br />
options root=UUID=<UUID identifier> rw<br />
<br />
==== 加密的根分区 ====<br />
<br />
这是一个加密的根分区 ([[Dm-crypt|例如通过DM-Crypt / LUKS]])的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-encrypted.conf|2=<br />
title Arch Linux Encrypted<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:<mapped-name> root=/dev/mapper/<mapped-name> quiet rw<br />
}}<br />
<br />
这个例子中用了UUID; PARTUUID 应该也可以使用, 如果你愿意,也可以用UUID替换/dev/段. 参阅 [[Dm-crypt/System configuration#Boot loader]].<br />
<br />
如果使用 LVM,cryptdevice 行应该类似于:<br />
<br />
{{hc|''esp''/loader/entries/arch-encrypted-lvm.conf|2=<br />
title Arch Linux Encrypted LVM<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:MyVolGroup root=/dev/mapper/MyVolGroup-MyVolRoot quiet rw<br />
}}<br />
<br />
你也可以加入类似于 {{ic|\EFI\arch\grub.efi}}的EFI应用程序.<br />
<br />
==== 根分区是btrfs子卷====<br />
<br />
如果用[[btrfs]]子卷作为根分区,记得加入 {{ic|rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki><root 子卷名称>}}到{{ic|options}}选项中,在这个例子中,根分区挂载在名称为'ROOT'的btrfs子卷中 (例如 {{ic|mount -o subvol<nowiki>=</nowiki>ROOT /dev/sdxY /mnt}}):<br />
<br />
{{hc|$esp/loader/entries/arch-btrfs-subvol.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki>ROOT<br />
}}<br />
<br />
如果做不到这一点的话,会出现这样的错误消息: {{ic|ERROR: Root device mounted successfully, but /sbin/init does not exist.}}<br />
<br />
==== EFI Shells 或其他 EFI 应用程序 ====<br />
<br />
你可以像这样加载EFI Shell或其他EFI应用程序:<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v1-x86_64.conf|2=<br />
title UEFI Shell x86_64 v1<br />
efi /EFI/shellx64_v1.efi<br />
}}<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v2-x86_64.conf|2=<br />
title UEFI Shell x86_64 v2<br />
efi /EFI/shellx64_v2.efi<br />
}}<br />
<br />
{{Expansion|加入如何进入UEFI固件设置的配置.}}<br />
<br />
=== 对休眠的支持 ===<br />
<br />
参阅 [[Suspend and hibernate]].<br />
<br />
== 启动选单中的按键操作 ==<br />
<br />
启动选单中支持的按键操作有:<br />
* {{ic|Up/Down}} - 选择选项<br />
* {{ic|Enter}} - 加载所选的选项<br />
* {{ic|d}} - 设置默认的启动选项 (会保存在 EFI 变量中)<br />
* {{ic|-/T}} - 增加超时时间 (会保存在 EFI 变量中)<br />
* {{ic|+/t}} - 减少超时时间 (会保存在 EFI 变量中)<br />
* {{ic|e}} - 编辑内核参数,如果 {{ic|editor}} 选项设置为{{ic|0}},则没有任何作用.<br />
* {{ic|v}} - 显示版本信息<br />
* {{ic|Q}} - 退出<br />
* {{ic|P}} - 显示目前的配置<br />
* {{ic|h/?}} - 帮助<br />
<br />
这些热键可以在启动管理器时直接指定启动哪一个选项<br />
<br />
* {{ic|l}} - Linux<br />
* {{ic|w}} - Windows<br />
* {{ic|a}} - OS X<br />
* {{ic|s}} - EFI Shell<br />
* {{ic|1-9}} -选项的编号<br />
<br />
==排除问题 ==<br />
<br />
<br />
=== 在传统启动下安装===<br />
<br />
{{Warning|这不是建议的方法!}}<br />
<br />
如果你以传统方式(MBR)启动电脑,或许能成功安装,不过需要在安装之后像你的固件提供如何启动systemd-boot的相关信息,为此你需要:<br />
<br />
* 一个EFI Shell;<br />
* 或是你的UEFI 固件设置中提供了更改启动选项的界面.<br />
<br />
{{Note|例如某些 Dell Latitude 计算机上,UEFI固件设置界面提供了设置EFI启动所需的工具,而EFI Shell 无法修改那些设置.}}<br />
<br />
如果能这样做的话,进入你的 EFI Shell 或是 UEFI 固件设置,修改你的默认EFI启动加载器为 {{ic|$esp/EFI/systemd/systemd-bootx64.efi}} (在i686架构上是 {{ic|systemd-bootia32.efi}}).<br />
<br />
=== 通过efibootmgr手动添加启动选项 ===<br />
<br />
如果运行{{ic|bootctl install}} 命令失败,你可以通过 {{Pkg|efibootmgr}}手动增加选项:<br />
<br />
# efibootmgr -c -d /dev/sdX -p Y -l /EFI/systemd/systemd-bootx64.efi -L "Linux Boot Manager"<br />
<br />
用[[UEFI#EFI System Partition|EFI 系统分区]]{{Broken section link}}的设备名称替换{{ic|/dev/sdXY}}.<br />
<br />
=== 在Windows升级后不能看到启动菜单===<br />
<br />
参阅[[Unified_Extensible_Firmware_Interface_(简体中文)|Windows 修改了启动顺序]]。<br />
<br />
== 参阅 ==<br />
<br />
* http://www.freedesktop.org/wiki/Software/systemd/systemd-boot/</div>
神楽坂花火
https://wiki.archlinux.org/index.php?title=Systemd-boot_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=599633
Systemd-boot (简体中文)
2020-02-29T15:53:46Z
<p>神楽坂花火: 翻译本章节</p>
<hr />
<div>{{lowercase title}}<br />
[[Category:Boot loaders (简体中文)]]<br />
[[de:Systemd-boot]]<br />
[[en:Systemd-boot]]<br />
[[es:Systemd-boot]]<br />
[[ja:Systemd-boot]]<br />
[[ru:Systemd-boot]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Arch boot process}}<br />
{{Related|Secure Boot}}<br />
{{Related|Unified Extensible Firmware Interface (简体中文)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|Systemd-boot|2019-03-16|567880}}<br />
'''systemd-boot''' (以前被称为'''gummiboot''') 是可以执行 EFI 镜像文件的简单 UEFI 启动管理器。启动的内容可以通过一个配置(glob)或者屏幕菜单选择。Arch 默认安装的 {{Pkg|systemd}} 提供了这个功能。<br />
<br />
配置很简单,但是只能启动 EFI 可执行程序,例如 Linux 内核 [[EFISTUB]], UEFI Shell, GRUB, Windows Boot Manager等。<br />
<br />
{{Note|本文用 {{ic|$esp}} 表示[[EFI system partition|EFI 系统分区]],也就是 ESP 的挂载位置。}}<br />
<br />
== 安装 ==<br />
<br />
=== 安装 EFI 启动管理器 ===<br />
要安装 ''systemd-boot'' EFI 启动管理器,首先确保启动方式是 UEFI 模式,可以访问 [[Unified Extensible Firmware Interface#UEFI variables|UEFI 变量]]。用 {{ic|efivar --list}} 命令进行检查,如果没有安装 {{Pkg|efivar}} ,使用 {{ic|ls /sys/firmware/efi/efivars}} (如果目录存在,系统是以 UEFI 模式启动的)。<br />
<br />
''systemd-boot'' 仅可以从[[EFI system partition|ESP]] 分区加载 [[EFISTUB]] 内核。要持续更新内核,建议将 ESP 挂载到 {{ic|/boot}}. 如果没将 ESP 挂载到 {{ic|/boot}},需要手动将内核和 initramfs 复制到 ESP. 详情请参考 [[EFI system partition#Alternative mount points]] .<br />
<br />
下面的例子中会用 {{ic|$esp}} 代替 EFI 系统分区的实际位置,例如 {{ic|/boot}}。<br />
<br />
ESP 挂载到 {{ic|''esp''}} 后,使用 {{man|1|bootctl}} 将 ''systemd-boot'' 安装到 EFI 系统分区: <br />
<br />
# bootctl --path=''esp'' install<br />
<br />
在 x64 架构的系统上,两个完全一样的二进制文件 {{ic|''esp''/EFI/systemd/systemd-bootx64.efi}} 和 {{ic|''esp''/EFI/BOOT/BOOTX64.EFI}} 会被复制到 ESP. 然后将 ''systemd-boot'' 设置为 EFI 启动管理器的默认 EFI 程序(默认启动项)。<br />
<br />
要完成安装,请 [[#配置|配置]] ''systemd-boot''。<br />
<br />
=== 更新 EFI 启动管理器 ===<br />
<br />
每当 ''systemd-boot'' 有新版本时,用户都需要更新启动管理器。<br />
<br />
==== 手动更新 ====<br />
<br />
更新 ''systemd-boot'' 需要使用 ''bootctl''。如果没指定 {{ic|path}},会按顺序检查 {{ic|/efi}}, {{ic|/boot}} 和 {{ic|/boot/efi}}。 <br />
<br />
# bootctl update<br />
<br />
可以用 {{ic|path}} 指定具体位置:<br />
<br />
# bootctl --path=''esp'' update<br />
<br />
{{Note|这条命令同样用于在移除 ''gummiboot'' 之前迁移。但是如果该软件包已被删除,请运行 {{ic|1=bootctl --path=''esp'' install}}。}}<br />
<br />
==== 自动更新 ====<br />
<br />
软件包 {{AUR|systemd-boot-pacman-hook}} 提供了一个 [[Pacman hook]] 以自动化更新过程。 [[安装|安装]] 该软件包将添加一个在每次更新 {{Pkg|systemd}} 时执行的 hook。<br />
<br />
或者,不安装 ''systemd-boot-pacman-hook'' 实现相同功能,在 {{ic|/etc/pacman.d/hooks/}} 放置以下 Pacman Hook:<br />
<br />
{{hc|/etc/pacman.d/hooks/100-systemd-boot.hook|2=<br />
[Trigger]<br />
Type = Package<br />
Operation = Upgrade<br />
Target = systemd<br />
<br />
[Action]<br />
Description = Updating systemd-boot<br />
When = PostTransaction<br />
Exec = /usr/bin/bootctl update<br />
}}<br />
<br />
== 配置 ==<br />
<br />
=== 基本配置 ===<br />
<br />
基本设置保存在{{ic|$esp/loader/loader.conf}},有三个选项:<br />
The basic configuration is kept in {{ic|$esp/loader/loader.conf}}, with three possible configuration options:<br />
<br />
* {{ic|default}} –默认加载的配置文件 (不含 {{ic|.conf}} 后缀); 可以使用通配符 {{ic|arch-*}}<br />
<br />
* {{ic|timeout}} –启动选单的超时时间,如果不设置的话,启动选单只有在按键时才显示.<br />
<br />
* {{ic|editor}} -是否允许用户编辑内核参数. {{ic|1}} (默认值) 是允许, {{ic|0}} 是阻止. 因为用户可以通过 {{ic|1=init=/bin/bash}} 来绕过root密码并获得root权限,建议设置成{{ic|0}}.<br />
<br />
下面是一个样例:<br />
<br />
{{hc|esp/loader/loader.conf|<br />
default arch<br />
timeout 4<br />
console-mode max<br />
editor no<br />
}}<br />
<br />
你也可以在启动选单中改变默认值和超时时间,所做的改动会保存到efivars中.<br />
<br />
{{Tip|{{ic|/usr/share/systemd/bootctl}}包含参考示例文件.}}<br />
<br />
=== 增加启动选项 ===<br />
{{Note|如果存在的话,bootctl 会自动为 "'''Windows Boot Manager (Windows 启动管理器)'''" ({{ic|\EFI\Microsoft\Boot\Bootmgfw.efi}}), "'''EFI Shell'''" ({{ic|\shellx64.efi}}) 和 "'''EFI Default Loader'''" ({{ic|\EFI\Boot\bootx64.efi}})增加启动选项. 但并不会为其他EFI应用程序创建启动选项,所以需要进行进一步设置.<br />
<br />
如果你是和Windows 组成双重启动,建议禁用 [[Dual boot with Windows#Fast_Start-Up|Windows 中的"快速启动"]]{{Broken section link}} 选项.}}<br />
<br />
如果需要 Intel [[microcode]],不要忘了修改 {{ic|initrd}}。<br />
<br />
{{Tip|你能用 {{ic|1=blkid -s PARTUUID -o value /dev/sdxY}} 找到某个分区的PARTUUID, 'x' 和 'Y' 分别是磁盘和分区编号.稍后可能需要这些信息.}}<br />
<br />
bootctl 会在 {{ic|$esp/loader/entries/*.conf}} 搜索启动选项– 一个文件中只能包含一个启动选项,下面是参数列表:<br />
<br />
* {{ic|title}} – '''必须选项.''' 系统的名称.<br />
<br />
* {{ic|version}} – 内核版本,只在有多个{{ic|title}} 时需要.<br />
<br />
* {{ic|machine-id}} – 通过 {{ic|/etc/machine-id}}用于区分不同设备的名称, 只在有多个{{ic|title}} 和 {{ic|version}} 时需要.<br />
<br />
* {{ic|efi}} – 要启动的EFI应用程序的位置,以 ({{ic|$esp}}) 为相对路径,; 例如 {{ic|/vmlinuz-linux}}. '''需要此选项或是 {{ic|linux}} (参阅下文) 的一项.'''<br />
<br />
* {{ic|options}} – 传递给 EFI 应用程序或内核启动的参数,可选.但如果你要启动linux,至少需要 {{ic|1=initrd=''efipath''}} 和 {{ic|1=root=''dev''}}选项.<br />
<br />
要启动linux,你还可以指定 {{ic|linux ''path-to-vmlinuz''}} 和 {{ic|initrd ''path-to-initramfs''}};这会自动转换成 {{ic|efi ''path''}} 和 {{ic|1=options initrd=''path''}} – 这个语法只是为了方便,在功能上并没有区别. <br />
<br />
==== 一般的安装选项 ====<br />
<br />
这是一个根分区既不在LVM逻辑卷又没有加密时的配置选项:<br />
<br />
{{hc|$esp/loader/entries/arch.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw<br />
}}<br />
<br />
注意这个例子中用PARTUUID(或是PARTLABEL)来标识一个GPT分区(和UUID/LABEL不同,它标识一个文件系统).使用因为PARTUUID/PARTLABEL是因为它不像UUID/LABEL会在格式化时改变,也不像 /dev/sd* 会在某些时候交换.在某些无文件系统分区(或是不支持卷标的LUKS 加密卷)上也能工作.<br />
<br />
{{Tip|{{ic|/usr/share/systemd/bootctl}} 提供了参考示例文件.}}<br />
<br />
==== 根分区在LVM 逻辑卷上时====<br />
{{Warning|如果没有一个在LVM卷组外的{{ic|/boot}}分区,不要用 Systemd-boot .}}<br />
<br />
这是一个根分区在[[LVM]]逻辑卷上时的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-lvm.conf|2=<br />
title Arch Linux (LVM)<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=/dev/mapper/<VolumeGroup-LogicalVolume> rw<br />
}}<br />
<br />
用实际的逻辑卷组和逻辑卷名替换 {{ic|<VolumeGroup-LogicalVolume>}} (例如 {{ic|1=root=/dev/mapper/volgroup00-lvolroot}}). 也可以使用UUID:<br />
....<br />
options root=UUID=<UUID identifier> rw<br />
<br />
==== 加密的根分区 ====<br />
<br />
这是一个加密的根分区 ([[Dm-crypt|例如通过DM-Crypt / LUKS]])的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-encrypted.conf|2=<br />
title Arch Linux Encrypted<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:<mapped-name> root=/dev/mapper/<mapped-name> quiet rw<br />
}}<br />
<br />
这个例子中用了UUID; PARTUUID 应该也可以使用, 如果你愿意,也可以用UUID替换/dev/段. 参阅 [[Dm-crypt/System configuration#Boot loader]].<br />
<br />
如果使用 LVM,cryptdevice 行应该类似于:<br />
<br />
{{hc|''esp''/loader/entries/arch-encrypted-lvm.conf|2=<br />
title Arch Linux Encrypted LVM<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:MyVolGroup root=/dev/mapper/MyVolGroup-MyVolRoot quiet rw<br />
}}<br />
<br />
你也可以加入类似于 {{ic|\EFI\arch\grub.efi}}的EFI应用程序.<br />
<br />
==== 根分区是btrfs子卷====<br />
<br />
如果用[[btrfs]]子卷作为根分区,记得加入 {{ic|rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki><root 子卷名称>}}到{{ic|options}}选项中,在这个例子中,根分区挂载在名称为'ROOT'的btrfs子卷中 (例如 {{ic|mount -o subvol<nowiki>=</nowiki>ROOT /dev/sdxY /mnt}}):<br />
<br />
{{hc|$esp/loader/entries/arch-btrfs-subvol.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki>ROOT<br />
}}<br />
<br />
如果做不到这一点的话,会出现这样的错误消息: {{ic|ERROR: Root device mounted successfully, but /sbin/init does not exist.}}<br />
<br />
==== EFI Shells 或其他 EFI 应用程序 ====<br />
<br />
你可以像这样加载EFI Shell或其他EFI应用程序:<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v1-x86_64.conf|2=<br />
title UEFI Shell x86_64 v1<br />
efi /EFI/shellx64_v1.efi<br />
}}<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v2-x86_64.conf|2=<br />
title UEFI Shell x86_64 v2<br />
efi /EFI/shellx64_v2.efi<br />
}}<br />
<br />
{{Expansion|加入如何进入UEFI固件设置的配置.}}<br />
<br />
=== 对休眠的支持 ===<br />
<br />
参阅 [[Suspend and hibernate]].<br />
<br />
== 启动选单中的按键操作 ==<br />
<br />
启动选单中支持的按键操作有:<br />
* {{ic|Up/Down}} - 选择选项<br />
* {{ic|Enter}} - 加载所选的选项<br />
* {{ic|d}} - 设置默认的启动选项 (会保存在 EFI 变量中)<br />
* {{ic|-/T}} - 增加超时时间 (会保存在 EFI 变量中)<br />
* {{ic|+/t}} - 减少超时时间 (会保存在 EFI 变量中)<br />
* {{ic|e}} - 编辑内核参数,如果 {{ic|editor}} 选项设置为{{ic|0}},则没有任何作用.<br />
* {{ic|v}} - 显示版本信息<br />
* {{ic|Q}} - 退出<br />
* {{ic|P}} - 显示目前的配置<br />
* {{ic|h/?}} - 帮助<br />
<br />
这些热键可以在启动管理器时直接指定启动哪一个选项<br />
<br />
* {{ic|l}} - Linux<br />
* {{ic|w}} - Windows<br />
* {{ic|a}} - OS X<br />
* {{ic|s}} - EFI Shell<br />
* {{ic|1-9}} -选项的编号<br />
<br />
==排除问题 ==<br />
<br />
<br />
=== 在传统启动下安装===<br />
<br />
{{Warning|这不是建议的方法!}}<br />
<br />
如果你以传统方式(MBR)启动电脑,或许能成功安装,不过需要在安装之后像你的固件提供如何启动systemd-boot的相关信息,为此你需要:<br />
<br />
* 一个EFI Shell;<br />
* 或是你的UEFI 固件设置中提供了更改启动选项的界面.<br />
<br />
{{Note|例如某些 Dell Latitude 计算机上,UEFI固件设置界面提供了设置EFI启动所需的工具,而EFI Shell 无法修改那些设置.}}<br />
<br />
如果能这样做的话,进入你的 EFI Shell 或是 UEFI 固件设置,修改你的默认EFI启动加载器为 {{ic|$esp/EFI/systemd/systemd-bootx64.efi}} (在i686架构上是 {{ic|systemd-bootia32.efi}}).<br />
<br />
=== 通过efibootmgr手动添加启动选项 ===<br />
<br />
如果运行{{ic|bootctl install}} 命令失败,你可以通过 {{Pkg|efibootmgr}}手动增加选项:<br />
<br />
# efibootmgr -c -d /dev/sdX -p Y -l /EFI/systemd/systemd-bootx64.efi -L "Linux Boot Manager"<br />
<br />
用[[UEFI#EFI System Partition|EFI 系统分区]]{{Broken section link}}的设备名称替换{{ic|/dev/sdXY}}.<br />
<br />
=== 在Windows升级后不能看到启动菜单===<br />
<br />
参阅[[Unified_Extensible_Firmware_Interface_(简体中文)|Windows 修改了启动顺序]]。<br />
<br />
== 参阅 ==<br />
<br />
* http://www.freedesktop.org/wiki/Software/systemd/systemd-boot/</div>
神楽坂花火
https://wiki.archlinux.org/index.php?title=Systemd-boot_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=599632
Systemd-boot (简体中文)
2020-02-29T15:46:19Z
<p>神楽坂花火: 翻译遗漏部分</p>
<hr />
<div>{{lowercase title}}<br />
[[Category:Boot loaders (简体中文)]]<br />
[[de:Systemd-boot]]<br />
[[en:Systemd-boot]]<br />
[[es:Systemd-boot]]<br />
[[ja:Systemd-boot]]<br />
[[ru:Systemd-boot]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Arch boot process}}<br />
{{Related|Secure Boot}}<br />
{{Related|Unified Extensible Firmware Interface (简体中文)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|Systemd-boot|2019-03-16|567880}}<br />
'''systemd-boot''' (以前被称为'''gummiboot''') 是可以执行 EFI 镜像文件的简单 UEFI 启动管理器。启动的内容可以通过一个配置(glob)或者屏幕菜单选择。Arch 默认安装的 {{Pkg|systemd}} 提供了这个功能。<br />
<br />
配置很简单,但是只能启动 EFI 可执行程序,例如 Linux 内核 [[EFISTUB]], UEFI Shell, GRUB, Windows Boot Manager等。<br />
<br />
{{Note|本文用 {{ic|$esp}} 表示[[EFI system partition|EFI 系统分区]],也就是 ESP 的挂载位置。}}<br />
<br />
== 安装 ==<br />
<br />
=== 安装 EFI 启动管理器 ===<br />
要安装 ''systemd-boot'' EFI 启动管理器,首先确保启动方式是 UEFI 模式,可以访问 [[Unified Extensible Firmware Interface#UEFI variables|UEFI 变量]]。用 {{ic|efivar --list}} 命令进行检查,如果没有安装 {{Pkg|efivar}} ,使用 {{ic|ls /sys/firmware/efi/efivars}} (如果目录存在,系统是以 UEFI 模式启动的)。<br />
<br />
''systemd-boot'' 仅可以从[[EFI system partition|ESP]] 分区加载 [[EFISTUB]] 内核。要持续更新内核,建议将 ESP 挂载到 {{ic|/boot}}. 如果没将 ESP 挂载到 {{ic|/boot}},需要手动将内核和 initramfs 复制到 ESP. 详情请参考 [[EFI system partition#Alternative mount points]] .<br />
<br />
下面的例子中会用 {{ic|$esp}} 代替 EFI 系统分区的实际位置,例如 {{ic|/boot}}。<br />
<br />
ESP 挂载到 {{ic|''esp''}} 后,使用 {{man|1|bootctl}} 将 ''systemd-boot'' 安装到 EFI 系统分区: <br />
<br />
# bootctl --path=''esp'' install<br />
<br />
在 x64 架构的系统上,两个完全一样的二进制文件 {{ic|''esp''/EFI/systemd/systemd-bootx64.efi}} 和 {{ic|''esp''/EFI/BOOT/BOOTX64.EFI}} 会被复制到 ESP. 然后将 ''systemd-boot'' 设置为 EFI 启动管理器的默认 EFI 程序(默认启动项)。<br />
<br />
要完成安装,请 [[#配置|配置]] ''systemd-boot''。<br />
<br />
=== 更新 EFI 启动管理器 ===<br />
<br />
每当 ''systemd-boot'' 有新版本时,用户都需要更新启动管理器。<br />
<br />
==== 手动更新 ====<br />
<br />
更新 ''systemd-boot'' 需要使用 ''bootctl''。如果没指定 {{ic|path}},会按顺序检查 {{ic|/efi}}, {{ic|/boot}} 和 {{ic|/boot/efi}}。 <br />
<br />
# bootctl update<br />
<br />
可以用 {{ic|path}} 指定具体位置:<br />
<br />
# bootctl --path=''esp'' update<br />
<br />
{{Note|这条命令同样用于在移除 ''gummiboot'' 之前迁移。但是如果该软件包已被删除,请运行 {{ic|1=bootctl --path=''esp'' install}}。}}<br />
<br />
==== 自动更新 ====<br />
<br />
The package {{AUR|systemd-boot-pacman-hook}} provides a [[Pacman hook]] to automate the update process. [[Install|Installing]] the package will add a hook which will be executed every time the {{Pkg|systemd}} package is upgraded.<br />
Alternatively, to replicate what the ''systemd-boot-pacman-hook'' package does without installing it, place the following pacman hook in the {{ic|/etc/pacman.d/hooks/}} directory:<br />
<br />
{{hc|/etc/pacman.d/hooks/100-systemd-boot.hook|2=<br />
[Trigger]<br />
Type = Package<br />
Operation = Upgrade<br />
Target = systemd<br />
<br />
[Action]<br />
Description = Updating systemd-boot<br />
When = PostTransaction<br />
Exec = /usr/bin/bootctl update<br />
}}<br />
<br />
== 配置 ==<br />
<br />
=== 基本配置 ===<br />
<br />
基本设置保存在{{ic|$esp/loader/loader.conf}},有三个选项:<br />
The basic configuration is kept in {{ic|$esp/loader/loader.conf}}, with three possible configuration options:<br />
<br />
* {{ic|default}} –默认加载的配置文件 (不含 {{ic|.conf}} 后缀); 可以使用通配符 {{ic|arch-*}}<br />
<br />
* {{ic|timeout}} –启动选单的超时时间,如果不设置的话,启动选单只有在按键时才显示.<br />
<br />
* {{ic|editor}} -是否允许用户编辑内核参数. {{ic|1}} (默认值) 是允许, {{ic|0}} 是阻止. 因为用户可以通过 {{ic|1=init=/bin/bash}} 来绕过root密码并获得root权限,建议设置成{{ic|0}}.<br />
<br />
下面是一个样例:<br />
<br />
{{hc|esp/loader/loader.conf|<br />
default arch<br />
timeout 4<br />
console-mode max<br />
editor no<br />
}}<br />
<br />
你也可以在启动选单中改变默认值和超时时间,所做的改动会保存到efivars中.<br />
<br />
{{Tip|{{ic|/usr/share/systemd/bootctl}}包含参考示例文件.}}<br />
<br />
=== 增加启动选项 ===<br />
{{Note|如果存在的话,bootctl 会自动为 "'''Windows Boot Manager (Windows 启动管理器)'''" ({{ic|\EFI\Microsoft\Boot\Bootmgfw.efi}}), "'''EFI Shell'''" ({{ic|\shellx64.efi}}) 和 "'''EFI Default Loader'''" ({{ic|\EFI\Boot\bootx64.efi}})增加启动选项. 但并不会为其他EFI应用程序创建启动选项,所以需要进行进一步设置.<br />
<br />
如果你是和Windows 组成双重启动,建议禁用 [[Dual boot with Windows#Fast_Start-Up|Windows 中的"快速启动"]]{{Broken section link}} 选项.}}<br />
<br />
如果需要 Intel [[microcode]],不要忘了修改 {{ic|initrd}}。<br />
<br />
{{Tip|你能用 {{ic|1=blkid -s PARTUUID -o value /dev/sdxY}} 找到某个分区的PARTUUID, 'x' 和 'Y' 分别是磁盘和分区编号.稍后可能需要这些信息.}}<br />
<br />
bootctl 会在 {{ic|$esp/loader/entries/*.conf}} 搜索启动选项– 一个文件中只能包含一个启动选项,下面是参数列表:<br />
<br />
* {{ic|title}} – '''必须选项.''' 系统的名称.<br />
<br />
* {{ic|version}} – 内核版本,只在有多个{{ic|title}} 时需要.<br />
<br />
* {{ic|machine-id}} – 通过 {{ic|/etc/machine-id}}用于区分不同设备的名称, 只在有多个{{ic|title}} 和 {{ic|version}} 时需要.<br />
<br />
* {{ic|efi}} – 要启动的EFI应用程序的位置,以 ({{ic|$esp}}) 为相对路径,; 例如 {{ic|/vmlinuz-linux}}. '''需要此选项或是 {{ic|linux}} (参阅下文) 的一项.'''<br />
<br />
* {{ic|options}} – 传递给 EFI 应用程序或内核启动的参数,可选.但如果你要启动linux,至少需要 {{ic|1=initrd=''efipath''}} 和 {{ic|1=root=''dev''}}选项.<br />
<br />
要启动linux,你还可以指定 {{ic|linux ''path-to-vmlinuz''}} 和 {{ic|initrd ''path-to-initramfs''}};这会自动转换成 {{ic|efi ''path''}} 和 {{ic|1=options initrd=''path''}} – 这个语法只是为了方便,在功能上并没有区别. <br />
<br />
==== 一般的安装选项 ====<br />
<br />
这是一个根分区既不在LVM逻辑卷又没有加密时的配置选项:<br />
<br />
{{hc|$esp/loader/entries/arch.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw<br />
}}<br />
<br />
注意这个例子中用PARTUUID(或是PARTLABEL)来标识一个GPT分区(和UUID/LABEL不同,它标识一个文件系统).使用因为PARTUUID/PARTLABEL是因为它不像UUID/LABEL会在格式化时改变,也不像 /dev/sd* 会在某些时候交换.在某些无文件系统分区(或是不支持卷标的LUKS 加密卷)上也能工作.<br />
<br />
{{Tip|{{ic|/usr/share/systemd/bootctl}} 提供了参考示例文件.}}<br />
<br />
==== 根分区在LVM 逻辑卷上时====<br />
{{Warning|如果没有一个在LVM卷组外的{{ic|/boot}}分区,不要用 Systemd-boot .}}<br />
<br />
这是一个根分区在[[LVM]]逻辑卷上时的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-lvm.conf|2=<br />
title Arch Linux (LVM)<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=/dev/mapper/<VolumeGroup-LogicalVolume> rw<br />
}}<br />
<br />
用实际的逻辑卷组和逻辑卷名替换 {{ic|<VolumeGroup-LogicalVolume>}} (例如 {{ic|1=root=/dev/mapper/volgroup00-lvolroot}}). 也可以使用UUID:<br />
....<br />
options root=UUID=<UUID identifier> rw<br />
<br />
==== 加密的根分区 ====<br />
<br />
这是一个加密的根分区 ([[Dm-crypt|例如通过DM-Crypt / LUKS]])的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-encrypted.conf|2=<br />
title Arch Linux Encrypted<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:<mapped-name> root=/dev/mapper/<mapped-name> quiet rw<br />
}}<br />
<br />
这个例子中用了UUID; PARTUUID 应该也可以使用, 如果你愿意,也可以用UUID替换/dev/段. 参阅 [[Dm-crypt/System configuration#Boot loader]].<br />
<br />
如果使用 LVM,cryptdevice 行应该类似于:<br />
<br />
{{hc|''esp''/loader/entries/arch-encrypted-lvm.conf|2=<br />
title Arch Linux Encrypted LVM<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:MyVolGroup root=/dev/mapper/MyVolGroup-MyVolRoot quiet rw<br />
}}<br />
<br />
你也可以加入类似于 {{ic|\EFI\arch\grub.efi}}的EFI应用程序.<br />
<br />
==== 根分区是btrfs子卷====<br />
<br />
如果用[[btrfs]]子卷作为根分区,记得加入 {{ic|rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki><root 子卷名称>}}到{{ic|options}}选项中,在这个例子中,根分区挂载在名称为'ROOT'的btrfs子卷中 (例如 {{ic|mount -o subvol<nowiki>=</nowiki>ROOT /dev/sdxY /mnt}}):<br />
<br />
{{hc|$esp/loader/entries/arch-btrfs-subvol.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki>ROOT<br />
}}<br />
<br />
如果做不到这一点的话,会出现这样的错误消息: {{ic|ERROR: Root device mounted successfully, but /sbin/init does not exist.}}<br />
<br />
==== EFI Shells 或其他 EFI 应用程序 ====<br />
<br />
你可以像这样加载EFI Shell或其他EFI应用程序:<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v1-x86_64.conf|2=<br />
title UEFI Shell x86_64 v1<br />
efi /EFI/shellx64_v1.efi<br />
}}<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v2-x86_64.conf|2=<br />
title UEFI Shell x86_64 v2<br />
efi /EFI/shellx64_v2.efi<br />
}}<br />
<br />
{{Expansion|加入如何进入UEFI固件设置的配置.}}<br />
<br />
=== 对休眠的支持 ===<br />
<br />
参阅 [[Suspend and hibernate]].<br />
<br />
== 启动选单中的按键操作 ==<br />
<br />
启动选单中支持的按键操作有:<br />
* {{ic|Up/Down}} - 选择选项<br />
* {{ic|Enter}} - 加载所选的选项<br />
* {{ic|d}} - 设置默认的启动选项 (会保存在 EFI 变量中)<br />
* {{ic|-/T}} - 增加超时时间 (会保存在 EFI 变量中)<br />
* {{ic|+/t}} - 减少超时时间 (会保存在 EFI 变量中)<br />
* {{ic|e}} - 编辑内核参数,如果 {{ic|editor}} 选项设置为{{ic|0}},则没有任何作用.<br />
* {{ic|v}} - 显示版本信息<br />
* {{ic|Q}} - 退出<br />
* {{ic|P}} - 显示目前的配置<br />
* {{ic|h/?}} - 帮助<br />
<br />
这些热键可以在启动管理器时直接指定启动哪一个选项<br />
<br />
* {{ic|l}} - Linux<br />
* {{ic|w}} - Windows<br />
* {{ic|a}} - OS X<br />
* {{ic|s}} - EFI Shell<br />
* {{ic|1-9}} -选项的编号<br />
<br />
==排除问题 ==<br />
<br />
<br />
=== 在传统启动下安装===<br />
<br />
{{Warning|这不是建议的方法!}}<br />
<br />
如果你以传统方式(MBR)启动电脑,或许能成功安装,不过需要在安装之后像你的固件提供如何启动systemd-boot的相关信息,为此你需要:<br />
<br />
* 一个EFI Shell;<br />
* 或是你的UEFI 固件设置中提供了更改启动选项的界面.<br />
<br />
{{Note|例如某些 Dell Latitude 计算机上,UEFI固件设置界面提供了设置EFI启动所需的工具,而EFI Shell 无法修改那些设置.}}<br />
<br />
如果能这样做的话,进入你的 EFI Shell 或是 UEFI 固件设置,修改你的默认EFI启动加载器为 {{ic|$esp/EFI/systemd/systemd-bootx64.efi}} (在i686架构上是 {{ic|systemd-bootia32.efi}}).<br />
<br />
=== 通过efibootmgr手动添加启动选项 ===<br />
<br />
如果运行{{ic|bootctl install}} 命令失败,你可以通过 {{Pkg|efibootmgr}}手动增加选项:<br />
<br />
# efibootmgr -c -d /dev/sdX -p Y -l /EFI/systemd/systemd-bootx64.efi -L "Linux Boot Manager"<br />
<br />
用[[UEFI#EFI System Partition|EFI 系统分区]]{{Broken section link}}的设备名称替换{{ic|/dev/sdXY}}.<br />
<br />
=== 在Windows升级后不能看到启动菜单===<br />
<br />
参阅[[Unified_Extensible_Firmware_Interface_(简体中文)|Windows 修改了启动顺序]]。<br />
<br />
== 参阅 ==<br />
<br />
* http://www.freedesktop.org/wiki/Software/systemd/systemd-boot/</div>
神楽坂花火
https://wiki.archlinux.org/index.php?title=Systemd-boot_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=599631
Systemd-boot (简体中文)
2020-02-29T15:42:43Z
<p>神楽坂花火: configure -> 配置</p>
<hr />
<div>{{lowercase title}}<br />
[[Category:Boot loaders (简体中文)]]<br />
[[de:Systemd-boot]]<br />
[[en:Systemd-boot]]<br />
[[es:Systemd-boot]]<br />
[[ja:Systemd-boot]]<br />
[[ru:Systemd-boot]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Arch boot process}}<br />
{{Related|Secure Boot}}<br />
{{Related|Unified Extensible Firmware Interface (简体中文)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|Systemd-boot|2019-03-16|567880}}<br />
'''systemd-boot''' (以前被称为'''gummiboot''') 是可以执行 EFI 镜像文件的简单 UEFI 启动管理器。启动的内容可以通过一个配置(glob)或者屏幕菜单选择。Arch 默认安装的 {{Pkg|systemd}} 提供了这个功能。<br />
<br />
配置很简单,但是只能启动 EFI 可执行程序,例如 Linux 内核 [[EFISTUB]], UEFI Shell, GRUB, Windows Boot Manager等。<br />
<br />
{{Note|本文用 {{ic|$esp}} 表示[[EFI system partition|EFI 系统分区]],也就是 ESP 的挂载位置。}}<br />
<br />
== 安装 ==<br />
<br />
=== 安装 EFI 启动管理器 ===<br />
要安装 ''systemd-boot'' EFI 启动管理器,首先确保启动方式是 UEFI 模式,可以访问 [[Unified Extensible Firmware Interface#UEFI variables|UEFI 变量]]。用 {{ic|efivar --list}} 命令进行检查,如果没有安装 {{Pkg|efivar}} ,使用 {{ic|ls /sys/firmware/efi/efivars}} (如果目录存在,系统是以 UEFI 模式启动的)。<br />
<br />
''systemd-boot'' 仅可以从[[EFI system partition|ESP]] 分区加载 [[EFISTUB]] 内核。要持续更新内核,建议将 ESP 挂载到 {{ic|/boot}}. 如果没将 ESP 挂载到 {{ic|/boot}},需要手动将内核和 initramfs 复制到 ESP. 详情请参考 [[EFI system partition#Alternative mount points]] .<br />
<br />
下面的例子中会用 {{ic|$esp}} 代替 EFI 系统分区的实际位置,例如 {{ic|/boot}}。<br />
<br />
ESP 挂载到 {{ic|''esp''}} 后,使用 {{man|1|bootctl}} 将 ''systemd-boot'' 安装到 EFI 系统分区: <br />
<br />
# bootctl --path=''esp'' install<br />
<br />
在 x64 架构的系统上,两个完全一样的二进制文件 {{ic|''esp''/EFI/systemd/systemd-bootx64.efi}} 和 {{ic|''esp''/EFI/BOOT/BOOTX64.EFI}} 会被复制到 ESP. 然后将 ''systemd-boot'' 设置为 EFI 启动管理器的默认 EFI 程序(默认启动项)。<br />
<br />
要完成安装,请 [[#配置|配置]] ''systemd-boot''。<br />
<br />
=== 更新 EFI 启动管理器 ===<br />
<br />
每当 ''systemd-boot'' 有新版本时,用户都需要更新启动管理器。<br />
<br />
==== 手动更新 ====<br />
<br />
更新 ''systemd-boot'' 需要使用 ''bootctl''。如果没指定 {{ic|path}},会按顺序检查 {{ic|/efi}}, {{ic|/boot}} 和 {{ic|/boot/efi}}。 <br />
<br />
# bootctl update<br />
<br />
可以用 {{ic|path}} 指定具体位置:<br />
<br />
# bootctl --path=''esp'' update<br />
<br />
{{Note|This is also the command to use when migrating from ''gummiboot'', before removing that package. If that package has already been removed, however, run {{ic|1=bootctl --path=''esp'' install}}.}}<br />
<br />
==== 自动更新 ====<br />
<br />
The package {{AUR|systemd-boot-pacman-hook}} provides a [[Pacman hook]] to automate the update process. [[Install|Installing]] the package will add a hook which will be executed every time the {{Pkg|systemd}} package is upgraded.<br />
Alternatively, to replicate what the ''systemd-boot-pacman-hook'' package does without installing it, place the following pacman hook in the {{ic|/etc/pacman.d/hooks/}} directory:<br />
<br />
{{hc|/etc/pacman.d/hooks/100-systemd-boot.hook|2=<br />
[Trigger]<br />
Type = Package<br />
Operation = Upgrade<br />
Target = systemd<br />
<br />
[Action]<br />
Description = Updating systemd-boot<br />
When = PostTransaction<br />
Exec = /usr/bin/bootctl update<br />
}}<br />
<br />
== 配置 ==<br />
<br />
=== 基本配置 ===<br />
<br />
基本设置保存在{{ic|$esp/loader/loader.conf}},有三个选项:<br />
The basic configuration is kept in {{ic|$esp/loader/loader.conf}}, with three possible configuration options:<br />
<br />
* {{ic|default}} –默认加载的配置文件 (不含 {{ic|.conf}} 后缀); 可以使用通配符 {{ic|arch-*}}<br />
<br />
* {{ic|timeout}} –启动选单的超时时间,如果不设置的话,启动选单只有在按键时才显示.<br />
<br />
* {{ic|editor}} -是否允许用户编辑内核参数. {{ic|1}} (默认值) 是允许, {{ic|0}} 是阻止. 因为用户可以通过 {{ic|1=init=/bin/bash}} 来绕过root密码并获得root权限,建议设置成{{ic|0}}.<br />
<br />
下面是一个样例:<br />
<br />
{{hc|esp/loader/loader.conf|<br />
default arch<br />
timeout 4<br />
console-mode max<br />
editor no<br />
}}<br />
<br />
你也可以在启动选单中改变默认值和超时时间,所做的改动会保存到efivars中.<br />
<br />
{{Tip|{{ic|/usr/share/systemd/bootctl}}包含参考示例文件.}}<br />
<br />
=== 增加启动选项 ===<br />
{{Note|如果存在的话,bootctl 会自动为 "'''Windows Boot Manager (Windows 启动管理器)'''" ({{ic|\EFI\Microsoft\Boot\Bootmgfw.efi}}), "'''EFI Shell'''" ({{ic|\shellx64.efi}}) 和 "'''EFI Default Loader'''" ({{ic|\EFI\Boot\bootx64.efi}})增加启动选项. 但并不会为其他EFI应用程序创建启动选项,所以需要进行进一步设置.<br />
<br />
如果你是和Windows 组成双重启动,建议禁用 [[Dual boot with Windows#Fast_Start-Up|Windows 中的"快速启动"]]{{Broken section link}} 选项.}}<br />
<br />
如果需要 Intel [[microcode]],不要忘了修改 {{ic|initrd}}。<br />
<br />
{{Tip|你能用 {{ic|1=blkid -s PARTUUID -o value /dev/sdxY}} 找到某个分区的PARTUUID, 'x' 和 'Y' 分别是磁盘和分区编号.稍后可能需要这些信息.}}<br />
<br />
bootctl 会在 {{ic|$esp/loader/entries/*.conf}} 搜索启动选项– 一个文件中只能包含一个启动选项,下面是参数列表:<br />
<br />
* {{ic|title}} – '''必须选项.''' 系统的名称.<br />
<br />
* {{ic|version}} – 内核版本,只在有多个{{ic|title}} 时需要.<br />
<br />
* {{ic|machine-id}} – 通过 {{ic|/etc/machine-id}}用于区分不同设备的名称, 只在有多个{{ic|title}} 和 {{ic|version}} 时需要.<br />
<br />
* {{ic|efi}} – 要启动的EFI应用程序的位置,以 ({{ic|$esp}}) 为相对路径,; 例如 {{ic|/vmlinuz-linux}}. '''需要此选项或是 {{ic|linux}} (参阅下文) 的一项.'''<br />
<br />
* {{ic|options}} – 传递给 EFI 应用程序或内核启动的参数,可选.但如果你要启动linux,至少需要 {{ic|1=initrd=''efipath''}} 和 {{ic|1=root=''dev''}}选项.<br />
<br />
要启动linux,你还可以指定 {{ic|linux ''path-to-vmlinuz''}} 和 {{ic|initrd ''path-to-initramfs''}};这会自动转换成 {{ic|efi ''path''}} 和 {{ic|1=options initrd=''path''}} – 这个语法只是为了方便,在功能上并没有区别. <br />
<br />
==== 一般的安装选项 ====<br />
<br />
这是一个根分区既不在LVM逻辑卷又没有加密时的配置选项:<br />
<br />
{{hc|$esp/loader/entries/arch.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw<br />
}}<br />
<br />
注意这个例子中用PARTUUID(或是PARTLABEL)来标识一个GPT分区(和UUID/LABEL不同,它标识一个文件系统).使用因为PARTUUID/PARTLABEL是因为它不像UUID/LABEL会在格式化时改变,也不像 /dev/sd* 会在某些时候交换.在某些无文件系统分区(或是不支持卷标的LUKS 加密卷)上也能工作.<br />
<br />
{{Tip|{{ic|/usr/share/systemd/bootctl}} 提供了参考示例文件.}}<br />
<br />
==== 根分区在LVM 逻辑卷上时====<br />
{{Warning|如果没有一个在LVM卷组外的{{ic|/boot}}分区,不要用 Systemd-boot .}}<br />
<br />
这是一个根分区在[[LVM]]逻辑卷上时的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-lvm.conf|2=<br />
title Arch Linux (LVM)<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=/dev/mapper/<VolumeGroup-LogicalVolume> rw<br />
}}<br />
<br />
用实际的逻辑卷组和逻辑卷名替换 {{ic|<VolumeGroup-LogicalVolume>}} (例如 {{ic|1=root=/dev/mapper/volgroup00-lvolroot}}). 也可以使用UUID:<br />
....<br />
options root=UUID=<UUID identifier> rw<br />
<br />
==== 加密的根分区 ====<br />
<br />
这是一个加密的根分区 ([[Dm-crypt|例如通过DM-Crypt / LUKS]])的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-encrypted.conf|2=<br />
title Arch Linux Encrypted<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:<mapped-name> root=/dev/mapper/<mapped-name> quiet rw<br />
}}<br />
<br />
这个例子中用了UUID; PARTUUID 应该也可以使用, 如果你愿意,也可以用UUID替换/dev/段. 参阅 [[Dm-crypt/System configuration#Boot loader]].<br />
<br />
如果使用 LVM,cryptdevice 行应该类似于:<br />
<br />
{{hc|''esp''/loader/entries/arch-encrypted-lvm.conf|2=<br />
title Arch Linux Encrypted LVM<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:MyVolGroup root=/dev/mapper/MyVolGroup-MyVolRoot quiet rw<br />
}}<br />
<br />
你也可以加入类似于 {{ic|\EFI\arch\grub.efi}}的EFI应用程序.<br />
<br />
==== 根分区是btrfs子卷====<br />
<br />
如果用[[btrfs]]子卷作为根分区,记得加入 {{ic|rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki><root 子卷名称>}}到{{ic|options}}选项中,在这个例子中,根分区挂载在名称为'ROOT'的btrfs子卷中 (例如 {{ic|mount -o subvol<nowiki>=</nowiki>ROOT /dev/sdxY /mnt}}):<br />
<br />
{{hc|$esp/loader/entries/arch-btrfs-subvol.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki>ROOT<br />
}}<br />
<br />
如果做不到这一点的话,会出现这样的错误消息: {{ic|ERROR: Root device mounted successfully, but /sbin/init does not exist.}}<br />
<br />
==== EFI Shells 或其他 EFI 应用程序 ====<br />
<br />
你可以像这样加载EFI Shell或其他EFI应用程序:<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v1-x86_64.conf|2=<br />
title UEFI Shell x86_64 v1<br />
efi /EFI/shellx64_v1.efi<br />
}}<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v2-x86_64.conf|2=<br />
title UEFI Shell x86_64 v2<br />
efi /EFI/shellx64_v2.efi<br />
}}<br />
<br />
{{Expansion|加入如何进入UEFI固件设置的配置.}}<br />
<br />
=== 对休眠的支持 ===<br />
<br />
参阅 [[Suspend and hibernate]].<br />
<br />
== 启动选单中的按键操作 ==<br />
<br />
启动选单中支持的按键操作有:<br />
* {{ic|Up/Down}} - 选择选项<br />
* {{ic|Enter}} - 加载所选的选项<br />
* {{ic|d}} - 设置默认的启动选项 (会保存在 EFI 变量中)<br />
* {{ic|-/T}} - 增加超时时间 (会保存在 EFI 变量中)<br />
* {{ic|+/t}} - 减少超时时间 (会保存在 EFI 变量中)<br />
* {{ic|e}} - 编辑内核参数,如果 {{ic|editor}} 选项设置为{{ic|0}},则没有任何作用.<br />
* {{ic|v}} - 显示版本信息<br />
* {{ic|Q}} - 退出<br />
* {{ic|P}} - 显示目前的配置<br />
* {{ic|h/?}} - 帮助<br />
<br />
这些热键可以在启动管理器时直接指定启动哪一个选项<br />
<br />
* {{ic|l}} - Linux<br />
* {{ic|w}} - Windows<br />
* {{ic|a}} - OS X<br />
* {{ic|s}} - EFI Shell<br />
* {{ic|1-9}} -选项的编号<br />
<br />
==排除问题 ==<br />
<br />
<br />
=== 在传统启动下安装===<br />
<br />
{{Warning|这不是建议的方法!}}<br />
<br />
如果你以传统方式(MBR)启动电脑,或许能成功安装,不过需要在安装之后像你的固件提供如何启动systemd-boot的相关信息,为此你需要:<br />
<br />
* 一个EFI Shell;<br />
* 或是你的UEFI 固件设置中提供了更改启动选项的界面.<br />
<br />
{{Note|例如某些 Dell Latitude 计算机上,UEFI固件设置界面提供了设置EFI启动所需的工具,而EFI Shell 无法修改那些设置.}}<br />
<br />
如果能这样做的话,进入你的 EFI Shell 或是 UEFI 固件设置,修改你的默认EFI启动加载器为 {{ic|$esp/EFI/systemd/systemd-bootx64.efi}} (在i686架构上是 {{ic|systemd-bootia32.efi}}).<br />
<br />
=== 通过efibootmgr手动添加启动选项 ===<br />
<br />
如果运行{{ic|bootctl install}} 命令失败,你可以通过 {{Pkg|efibootmgr}}手动增加选项:<br />
<br />
# efibootmgr -c -d /dev/sdX -p Y -l /EFI/systemd/systemd-bootx64.efi -L "Linux Boot Manager"<br />
<br />
用[[UEFI#EFI System Partition|EFI 系统分区]]{{Broken section link}}的设备名称替换{{ic|/dev/sdXY}}.<br />
<br />
=== 在Windows升级后不能看到启动菜单===<br />
<br />
参阅[[Unified_Extensible_Firmware_Interface_(简体中文)|Windows 修改了启动顺序]]。<br />
<br />
== 参阅 ==<br />
<br />
* http://www.freedesktop.org/wiki/Software/systemd/systemd-boot/</div>
神楽坂花火
https://wiki.archlinux.org/index.php?title=Systemd-boot_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=599630
Systemd-boot (简体中文)
2020-02-29T15:41:41Z
<p>神楽坂花火: 增加遗漏的翻译</p>
<hr />
<div>{{lowercase title}}<br />
[[Category:Boot loaders (简体中文)]]<br />
[[de:Systemd-boot]]<br />
[[en:Systemd-boot]]<br />
[[es:Systemd-boot]]<br />
[[ja:Systemd-boot]]<br />
[[ru:Systemd-boot]]<br />
{{Related articles start (简体中文)}}<br />
{{Related|Arch boot process}}<br />
{{Related|Secure Boot}}<br />
{{Related|Unified Extensible Firmware Interface (简体中文)}}<br />
{{Related articles end}}<br />
{{TranslationStatus (简体中文)|Systemd-boot|2019-03-16|567880}}<br />
'''systemd-boot''' (以前被称为'''gummiboot''') 是可以执行 EFI 镜像文件的简单 UEFI 启动管理器。启动的内容可以通过一个配置(glob)或者屏幕菜单选择。Arch 默认安装的 {{Pkg|systemd}} 提供了这个功能。<br />
<br />
配置很简单,但是只能启动 EFI 可执行程序,例如 Linux 内核 [[EFISTUB]], UEFI Shell, GRUB, Windows Boot Manager等。<br />
<br />
{{Note|本文用 {{ic|$esp}} 表示[[EFI system partition|EFI 系统分区]],也就是 ESP 的挂载位置。}}<br />
<br />
== 安装 ==<br />
<br />
=== 安装 EFI 启动管理器 ===<br />
要安装 ''systemd-boot'' EFI 启动管理器,首先确保启动方式是 UEFI 模式,可以访问 [[Unified Extensible Firmware Interface#UEFI variables|UEFI 变量]]。用 {{ic|efivar --list}} 命令进行检查,如果没有安装 {{Pkg|efivar}} ,使用 {{ic|ls /sys/firmware/efi/efivars}} (如果目录存在,系统是以 UEFI 模式启动的)。<br />
<br />
''systemd-boot'' 仅可以从[[EFI system partition|ESP]] 分区加载 [[EFISTUB]] 内核。要持续更新内核,建议将 ESP 挂载到 {{ic|/boot}}. 如果没将 ESP 挂载到 {{ic|/boot}},需要手动将内核和 initramfs 复制到 ESP. 详情请参考 [[EFI system partition#Alternative mount points]] .<br />
<br />
下面的例子中会用 {{ic|$esp}} 代替 EFI 系统分区的实际位置,例如 {{ic|/boot}}。<br />
<br />
ESP 挂载到 {{ic|''esp''}} 后,使用 {{man|1|bootctl}} 将 ''systemd-boot'' 安装到 EFI 系统分区: <br />
<br />
# bootctl --path=''esp'' install<br />
<br />
在 x64 架构的系统上,两个完全一样的二进制文件 {{ic|''esp''/EFI/systemd/systemd-bootx64.efi}} 和 {{ic|''esp''/EFI/BOOT/BOOTX64.EFI}} 会被复制到 ESP. 然后将 ''systemd-boot'' 设置为 EFI 启动管理器的默认 EFI 程序(默认启动项)。<br />
<br />
要完成安装,请 [[#配置|configure]] ''systemd-boot''。<br />
<br />
=== 更新 EFI 启动管理器 ===<br />
<br />
每当 ''systemd-boot'' 有新版本时,用户都需要更新启动管理器。<br />
<br />
==== 手动更新 ====<br />
<br />
更新 ''systemd-boot'' 需要使用 ''bootctl''。如果没指定 {{ic|path}},会按顺序检查 {{ic|/efi}}, {{ic|/boot}} 和 {{ic|/boot/efi}}。 <br />
<br />
# bootctl update<br />
<br />
可以用 {{ic|path}} 指定具体位置:<br />
<br />
# bootctl --path=''esp'' update<br />
<br />
{{Note|This is also the command to use when migrating from ''gummiboot'', before removing that package. If that package has already been removed, however, run {{ic|1=bootctl --path=''esp'' install}}.}}<br />
<br />
==== 自动更新 ====<br />
<br />
The package {{AUR|systemd-boot-pacman-hook}} provides a [[Pacman hook]] to automate the update process. [[Install|Installing]] the package will add a hook which will be executed every time the {{Pkg|systemd}} package is upgraded.<br />
Alternatively, to replicate what the ''systemd-boot-pacman-hook'' package does without installing it, place the following pacman hook in the {{ic|/etc/pacman.d/hooks/}} directory:<br />
<br />
{{hc|/etc/pacman.d/hooks/100-systemd-boot.hook|2=<br />
[Trigger]<br />
Type = Package<br />
Operation = Upgrade<br />
Target = systemd<br />
<br />
[Action]<br />
Description = Updating systemd-boot<br />
When = PostTransaction<br />
Exec = /usr/bin/bootctl update<br />
}}<br />
<br />
== 配置 ==<br />
<br />
=== 基本配置 ===<br />
<br />
基本设置保存在{{ic|$esp/loader/loader.conf}},有三个选项:<br />
The basic configuration is kept in {{ic|$esp/loader/loader.conf}}, with three possible configuration options:<br />
<br />
* {{ic|default}} –默认加载的配置文件 (不含 {{ic|.conf}} 后缀); 可以使用通配符 {{ic|arch-*}}<br />
<br />
* {{ic|timeout}} –启动选单的超时时间,如果不设置的话,启动选单只有在按键时才显示.<br />
<br />
* {{ic|editor}} -是否允许用户编辑内核参数. {{ic|1}} (默认值) 是允许, {{ic|0}} 是阻止. 因为用户可以通过 {{ic|1=init=/bin/bash}} 来绕过root密码并获得root权限,建议设置成{{ic|0}}.<br />
<br />
下面是一个样例:<br />
<br />
{{hc|esp/loader/loader.conf|<br />
default arch<br />
timeout 4<br />
console-mode max<br />
editor no<br />
}}<br />
<br />
你也可以在启动选单中改变默认值和超时时间,所做的改动会保存到efivars中.<br />
<br />
{{Tip|{{ic|/usr/share/systemd/bootctl}}包含参考示例文件.}}<br />
<br />
=== 增加启动选项 ===<br />
{{Note|如果存在的话,bootctl 会自动为 "'''Windows Boot Manager (Windows 启动管理器)'''" ({{ic|\EFI\Microsoft\Boot\Bootmgfw.efi}}), "'''EFI Shell'''" ({{ic|\shellx64.efi}}) 和 "'''EFI Default Loader'''" ({{ic|\EFI\Boot\bootx64.efi}})增加启动选项. 但并不会为其他EFI应用程序创建启动选项,所以需要进行进一步设置.<br />
<br />
如果你是和Windows 组成双重启动,建议禁用 [[Dual boot with Windows#Fast_Start-Up|Windows 中的"快速启动"]]{{Broken section link}} 选项.}}<br />
<br />
如果需要 Intel [[microcode]],不要忘了修改 {{ic|initrd}}。<br />
<br />
{{Tip|你能用 {{ic|1=blkid -s PARTUUID -o value /dev/sdxY}} 找到某个分区的PARTUUID, 'x' 和 'Y' 分别是磁盘和分区编号.稍后可能需要这些信息.}}<br />
<br />
bootctl 会在 {{ic|$esp/loader/entries/*.conf}} 搜索启动选项– 一个文件中只能包含一个启动选项,下面是参数列表:<br />
<br />
* {{ic|title}} – '''必须选项.''' 系统的名称.<br />
<br />
* {{ic|version}} – 内核版本,只在有多个{{ic|title}} 时需要.<br />
<br />
* {{ic|machine-id}} – 通过 {{ic|/etc/machine-id}}用于区分不同设备的名称, 只在有多个{{ic|title}} 和 {{ic|version}} 时需要.<br />
<br />
* {{ic|efi}} – 要启动的EFI应用程序的位置,以 ({{ic|$esp}}) 为相对路径,; 例如 {{ic|/vmlinuz-linux}}. '''需要此选项或是 {{ic|linux}} (参阅下文) 的一项.'''<br />
<br />
* {{ic|options}} – 传递给 EFI 应用程序或内核启动的参数,可选.但如果你要启动linux,至少需要 {{ic|1=initrd=''efipath''}} 和 {{ic|1=root=''dev''}}选项.<br />
<br />
要启动linux,你还可以指定 {{ic|linux ''path-to-vmlinuz''}} 和 {{ic|initrd ''path-to-initramfs''}};这会自动转换成 {{ic|efi ''path''}} 和 {{ic|1=options initrd=''path''}} – 这个语法只是为了方便,在功能上并没有区别. <br />
<br />
==== 一般的安装选项 ====<br />
<br />
这是一个根分区既不在LVM逻辑卷又没有加密时的配置选项:<br />
<br />
{{hc|$esp/loader/entries/arch.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw<br />
}}<br />
<br />
注意这个例子中用PARTUUID(或是PARTLABEL)来标识一个GPT分区(和UUID/LABEL不同,它标识一个文件系统).使用因为PARTUUID/PARTLABEL是因为它不像UUID/LABEL会在格式化时改变,也不像 /dev/sd* 会在某些时候交换.在某些无文件系统分区(或是不支持卷标的LUKS 加密卷)上也能工作.<br />
<br />
{{Tip|{{ic|/usr/share/systemd/bootctl}} 提供了参考示例文件.}}<br />
<br />
==== 根分区在LVM 逻辑卷上时====<br />
{{Warning|如果没有一个在LVM卷组外的{{ic|/boot}}分区,不要用 Systemd-boot .}}<br />
<br />
这是一个根分区在[[LVM]]逻辑卷上时的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-lvm.conf|2=<br />
title Arch Linux (LVM)<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=/dev/mapper/<VolumeGroup-LogicalVolume> rw<br />
}}<br />
<br />
用实际的逻辑卷组和逻辑卷名替换 {{ic|<VolumeGroup-LogicalVolume>}} (例如 {{ic|1=root=/dev/mapper/volgroup00-lvolroot}}). 也可以使用UUID:<br />
....<br />
options root=UUID=<UUID identifier> rw<br />
<br />
==== 加密的根分区 ====<br />
<br />
这是一个加密的根分区 ([[Dm-crypt|例如通过DM-Crypt / LUKS]])的样例:<br />
<br />
{{hc|$esp/loader/entries/arch-encrypted.conf|2=<br />
title Arch Linux Encrypted<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:<mapped-name> root=/dev/mapper/<mapped-name> quiet rw<br />
}}<br />
<br />
这个例子中用了UUID; PARTUUID 应该也可以使用, 如果你愿意,也可以用UUID替换/dev/段. 参阅 [[Dm-crypt/System configuration#Boot loader]].<br />
<br />
如果使用 LVM,cryptdevice 行应该类似于:<br />
<br />
{{hc|''esp''/loader/entries/arch-encrypted-lvm.conf|2=<br />
title Arch Linux Encrypted LVM<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options cryptdevice=UUID=<UUID>:MyVolGroup root=/dev/mapper/MyVolGroup-MyVolRoot quiet rw<br />
}}<br />
<br />
你也可以加入类似于 {{ic|\EFI\arch\grub.efi}}的EFI应用程序.<br />
<br />
==== 根分区是btrfs子卷====<br />
<br />
如果用[[btrfs]]子卷作为根分区,记得加入 {{ic|rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki><root 子卷名称>}}到{{ic|options}}选项中,在这个例子中,根分区挂载在名称为'ROOT'的btrfs子卷中 (例如 {{ic|mount -o subvol<nowiki>=</nowiki>ROOT /dev/sdxY /mnt}}):<br />
<br />
{{hc|$esp/loader/entries/arch-btrfs-subvol.conf|2=<br />
title Arch Linux<br />
linux /vmlinuz-linux<br />
initrd /initramfs-linux.img<br />
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw rootflags<nowiki>=</nowiki>subvol<nowiki>=</nowiki>ROOT<br />
}}<br />
<br />
如果做不到这一点的话,会出现这样的错误消息: {{ic|ERROR: Root device mounted successfully, but /sbin/init does not exist.}}<br />
<br />
==== EFI Shells 或其他 EFI 应用程序 ====<br />
<br />
你可以像这样加载EFI Shell或其他EFI应用程序:<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v1-x86_64.conf|2=<br />
title UEFI Shell x86_64 v1<br />
efi /EFI/shellx64_v1.efi<br />
}}<br />
<br />
{{hc|$esp/loader/entries/uefi-shell-v2-x86_64.conf|2=<br />
title UEFI Shell x86_64 v2<br />
efi /EFI/shellx64_v2.efi<br />
}}<br />
<br />
{{Expansion|加入如何进入UEFI固件设置的配置.}}<br />
<br />
=== 对休眠的支持 ===<br />
<br />
参阅 [[Suspend and hibernate]].<br />
<br />
== 启动选单中的按键操作 ==<br />
<br />
启动选单中支持的按键操作有:<br />
* {{ic|Up/Down}} - 选择选项<br />
* {{ic|Enter}} - 加载所选的选项<br />
* {{ic|d}} - 设置默认的启动选项 (会保存在 EFI 变量中)<br />
* {{ic|-/T}} - 增加超时时间 (会保存在 EFI 变量中)<br />
* {{ic|+/t}} - 减少超时时间 (会保存在 EFI 变量中)<br />
* {{ic|e}} - 编辑内核参数,如果 {{ic|editor}} 选项设置为{{ic|0}},则没有任何作用.<br />
* {{ic|v}} - 显示版本信息<br />
* {{ic|Q}} - 退出<br />
* {{ic|P}} - 显示目前的配置<br />
* {{ic|h/?}} - 帮助<br />
<br />
这些热键可以在启动管理器时直接指定启动哪一个选项<br />
<br />
* {{ic|l}} - Linux<br />
* {{ic|w}} - Windows<br />
* {{ic|a}} - OS X<br />
* {{ic|s}} - EFI Shell<br />
* {{ic|1-9}} -选项的编号<br />
<br />
==排除问题 ==<br />
<br />
<br />
=== 在传统启动下安装===<br />
<br />
{{Warning|这不是建议的方法!}}<br />
<br />
如果你以传统方式(MBR)启动电脑,或许能成功安装,不过需要在安装之后像你的固件提供如何启动systemd-boot的相关信息,为此你需要:<br />
<br />
* 一个EFI Shell;<br />
* 或是你的UEFI 固件设置中提供了更改启动选项的界面.<br />
<br />
{{Note|例如某些 Dell Latitude 计算机上,UEFI固件设置界面提供了设置EFI启动所需的工具,而EFI Shell 无法修改那些设置.}}<br />
<br />
如果能这样做的话,进入你的 EFI Shell 或是 UEFI 固件设置,修改你的默认EFI启动加载器为 {{ic|$esp/EFI/systemd/systemd-bootx64.efi}} (在i686架构上是 {{ic|systemd-bootia32.efi}}).<br />
<br />
=== 通过efibootmgr手动添加启动选项 ===<br />
<br />
如果运行{{ic|bootctl install}} 命令失败,你可以通过 {{Pkg|efibootmgr}}手动增加选项:<br />
<br />
# efibootmgr -c -d /dev/sdX -p Y -l /EFI/systemd/systemd-bootx64.efi -L "Linux Boot Manager"<br />
<br />
用[[UEFI#EFI System Partition|EFI 系统分区]]{{Broken section link}}的设备名称替换{{ic|/dev/sdXY}}.<br />
<br />
=== 在Windows升级后不能看到启动菜单===<br />
<br />
参阅[[Unified_Extensible_Firmware_Interface_(简体中文)|Windows 修改了启动顺序]]。<br />
<br />
== 参阅 ==<br />
<br />
* http://www.freedesktop.org/wiki/Software/systemd/systemd-boot/</div>
神楽坂花火