ArchGuide

安装并使用systemd-boot

systemd-boot原名gummiboot,是一个UEFI的启动引导器(仅支持UEFI)

在ArchLinux上已包含在systemd包内,只需要以下步骤即可启用

使用之前请确保esp分区挂载到/boot,systemd-boot不支持从根分区加载内核

检查/boot:

# mount|grep /boot
/dev/nvme0n1p1 on /boot type vfat (rw,noatime)

将systemd-boot安装到ESP

# bootctl install
Created "/boot/EFI".
Created "/boot/EFI/systemd".
Created "/boot/EFI/BOOT".
Created "/boot/loader".
Created "/boot/loader/entries".
Created "/boot/EFI/Linux".
Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/systemd/systemd-bootx64.efi".
Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/BOOT/BOOTX64.EFI".
Random seed file /boot/loader/random-seed successfully written (512 bytes).
Not installing system token, since we are running in a virtualized environment.
Created EFI boot entry "Linux Boot Manager".

查看根分区

# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme0n1     259:0    0    20G  0 disk 
├─nvme0n1p1 259:1    0   200M  0 part /boot
└─nvme0n1p1 259:2    0  19.8G  0 part /

查看根分区的PARTUUID

# blkid /dev/nvme0n1p2
/dev/nvme0n1p2: UUID="5aee4e6f-3a67-4fa4-9cf8-9d7c857671c7" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="25e4ce44-cccd-9a4f-9e40-e74cf8e517a9"

复制配置文件模板

cp /usr/share/systemd/bootctl/arch.conf /boot/loader/entries/

针对内核编写配置

nano /boot/loader/entries/arch.conf

文件内容:

## This is just an example config file.
## Please edit the paths and kernel parameters according to your system.

title   Arch Linux
linux   /vmlinuz-linux
initrd  /initramfs-linux.img
options root=PARTUUID=XXXX rootfstype=XXXX add_efi_memmap

将PARTUUID的值和rootfstype的值替换成实际的值

修改后:

## This is just an example config file.
## Please edit the paths and kernel parameters according to your system.

title   Arch Linux
linux   /vmlinuz-linux
initrd  /initramfs-linux.img
options root=PARTUUID=25e4ce44-cccd-9a4f-9e40-e74cf8e517a9 rootfstype=ext4 add_efi_memmap

如果有安装CPU微码的包,则添加到对应的位置。如:

## This is just an example config file.
## Please edit the paths and kernel parameters according to your system.

title   Arch Linux
linux   /vmlinuz-linux
initrd  /intel-ucode.img
initrd  /initramfs-linux.img
options root=PARTUUID=25e4ce44-cccd-9a4f-9e40-e74cf8e517a9 rootfstype=ext4 add_efi_memmap

现在保存退出后,重启即可使用systemd-boot

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注