Grub2 无法启动加密的根

Jak*_*ake 6 arch-linux grub2 dm-crypt

我正在使用 ArchLinux,我遵循了他们关于加密根文件系统的教程:

https://wiki.archlinux.org/index.php/Using_DM-Crypt

但是我无法让 grub 引导加密分区。

我的 grub 文件如下所示:

root (hd0,2)
kernel /vmlinuz-linux cryptdevice=/dev/sda4:root root=/dev/mapper/root ro
initramfs /intiramfs-linux.img
Run Code Online (Sandbox Code Playgroud)

我已经尝试将其编辑为我能想到的所有内容以及我可以在网上找到的所有内容,但没有任何内容可以启动。它总是给我这个错误:

ERROR: device '/dev/mapper/root' not found. Skipping fsck.
ERROR: unable to find root device '/dev/mapper/root'.
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激。

Mar*_*čka 2

正如Wieland 所说,您必须通知 ramfs 映像才能解密根分区。

这意味着通过更改此行将加密挂钩添加到/etc/mkinitcpio.conf文件系统挂钩之前(这应该是 vanilla Arch 安装中的默认设置):

HOOKS="base udev autodetect modconf block filesystems keyboard fsck"
Run Code Online (Sandbox Code Playgroud)

对此:

HOOKS="base udev autodetect modconf block encrypt filesystems keyboard fsck"
Run Code Online (Sandbox Code Playgroud)

(更多详情请参见:https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_entire_system#Configuring_mkinitcpio

然后使用以下命令重新编译 ramfs 映像(在 arch-chroot 中安装/boot):

# mkinitcpio -p linux
Run Code Online (Sandbox Code Playgroud)

(同样,有关更多详细信息,请参阅:https://wiki.archlinux.org/index.php/mkinitcpio#Image_creation_and_activation