我的系统是安装在独立硬盘上的Windows10 (sdb)和Manjaro (sda)的双引导。Windows系统驱动器使用bitlocker进行加密,Manjaro通过LVM over LUKS进行加密,如下所示(lsblk)。
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 619M 0 part /boot/efi
├─sda2 8:2 0 232.8G 0 part
│ └─cryptroot 254:0 0 232.8G 0 crypt
│ ├─vg0-swap 254:1 0 32G 0 lvm [SWAP]
│ ├─vg0-system 254:2 0 20G 0 lvm /
│ └─vg0-data 254:3 0 180.8G 0 lvm /home
└─sda5 8:5 0 698.1G 0 part
sdb 8:16 0 232.9G 0 disk
├─sdb1 8:17 0 499M 0 part
├─sdb2 8:18 0 100M 0 part
├─sdb3 8:19 0 16M 0 part
└─sdb4 8:20 0 232.3G 0 part我将grub2设置为默认的引导加载程序(安装在Manjaro上),它可以要求我通过菜单选择是启动Windows还是Manjaro。然而,问题是在给我那个菜单之前,它会询问(LUKS FDE)密码。因此,因为Windows已经使用bitlocker进行了加密,所以我必须在LUKS密码之后输入Windows bitlocker密码,这非常不方便。(如果我想启动到Manjaro,令人惊讶的是,我不需要输入两次LUKS密码)
因为Windows和Manjaro安装在不同的物理硬盘上,并且引导分区没有加密(如上所示),所以当我想要引导到Windows时,grub应该没有必要向我询问LUKS的密码。只有当我选择引导到Manjaro时,它才会首先显示菜单并询问LUKS密码。但我不确定如何配置它,我也找不到太多关于它的资源。
这是我的grub配置文件(位于/etc/default/grub)
GRUB_DEFAULT=saved
GRUB_TIMEOUT=10
GRUB_TIMEOUT_STYLE=hidden
GRUB_DISTRIBUTOR="Manjaro"
GRUB_CMDLINE_LINUX_DEFAULT="quiet udev.log_priority=3"
GRUB_CMDLINE_LINUX="cryptdevice=UUID=<uuid_is_hidden>:cryptroot"
# If you want to enable the save default function, uncomment the following
# line, and set GRUB_DEFAULT to saved.
GRUB_SAVEDEFAULT=true
# Preload both GPT and MBR modules so that they are not missed
GRUB_PRELOAD_MODULES="part_gpt part_msdos"
# Uncomment to enable booting from LUKS encrypted devices
GRUB_ENABLE_CRYPTODISK=y
# Uncomment to use basic console
GRUB_TERMINAL_INPUT=console
# Uncomment to disable graphical terminal
#GRUB_TERMINAL_OUTPUT=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command 'videoinfo'
GRUB_GFXMODE=auto
# Uncomment to allow the kernel use the same resolution used by grub
GRUB_GFXPAYLOAD_LINUX=keep
# Uncomment if you want GRUB to pass to the Linux kernel the old parameter
# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx"
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY=true
# Uncomment and set to the desired menu colors. Used by normal and wallpaper
# modes only. Entries specified as foreground/background.
GRUB_COLOR_NORMAL="light-gray/black"
GRUB_COLOR_HIGHLIGHT="green/black"
# Uncomment one of them for the gfx desired, a image background or a gfxtheme
#GRUB_BACKGROUND="/usr/share/grub/background.png"
GRUB_THEME="/usr/share/grub/themes/manjaro/theme.txt"
# Uncomment to get a beep at GRUB start
#GRUB_INIT_TUNE="480 440 1"发布于 2020-10-12 06:35:55
好吧,经过大量的研究,我找到了一个解决方案,但它可能不是最好的解决方案(参见下面的警告)。
请注意lsblk中的以下行
├─sda1 8:1 0 619M 0 part /boot/efi除了efi分区/boot/efi之外,/boot分区实际上是加密的。我记得这是我安装manjaro时推荐的(也可能是默认的)设置。因为grub将从/boot/grub/grub.cfg读取菜单项,所以它必须首先解密LUKS卷(/boot/grub是加密的)。因此,如果我们希望grub在输入密码之前显示菜单项,我们必须确保/boot/grub/grub.cfg没有加密。
一种方法是将sda1挂载为/boot而不是/boot/efi。为此,我们首先需要在/etc/fstab中进行更改,以更改挂载目标。然后,我们需要将所有文件从/boot复制到sda1。在此过程中,您可能需要重新安装grub并重新生成initramfs。以下命令对此很有用。
sudo mkinitcpio -P
sudo grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=manjaro --recheck
sudo grub-mkconfig -o /boot/grub/grub.cfg最后,您需要注释掉/etc/default/grub中的行GRUB_ENABLE_CRYPTODISK=y,以禁用从grub解密。完成所有操作后,运行以下命令来更新grub以写入更改。
sudo update-grub几点注意事项
initramfs中,因此它不需要密码即可解锁LUKS卷,详情请参阅here。由于在新的设置中/boot未加密,因此我们不能在initramfs中包含此密钥文件。为此,请修改mkinitcpio的配置文件(默认配置文件应为/etc/mkinitcpio.conf)以删除密钥文件(在FILES=(...)下),并重新生成安全透视图,默认且推荐的安装/boot/efi而不是/boot的设置可提供更好的安全性,因为唯一未加密的部分是EFI二进制文件(grubx64.efi)。然而,在我的设置中,initramfs和linux内核映像(vmlinuz.img)也是未加密的。攻击者可以将恶意代码插入到这些文件中,这些文件在您输入密码后执行。由于上面提到的原因,我不认为我的解决方案是最好的,并且不确定是否有其他解决方案来解决这个问题,而不会牺牲太多的安全性。
有用的链接:
https://wiki.manjaro.org/index.php/GRUB/Restore_the_GRUB_Bootloader https://wiki.archlinux.org/index.php/GRUB https://wiki.archlinux.org/index.php/Mkinitcpio#Image_creation_and_activation
https://stackoverflow.com/questions/64307746
复制相似问题