我已在内部硬盘上安装了 Debian 10,它可以在 UEFI 安全启动下正常运行。
当我在外部 USB 上安装第二个 Debian 时,它只能从该 USB 启动。
当我从笔记本电脑上拔下 USB 以启动到 SSD 时,出现错误
最小的类似 bash 的行编辑。
禁用安全启动没有帮助。
Disk /dev/sda: 238,5 GiB, 256060514304 bytes, 500118192 sectors
Disk model
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier:
Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M EFI System
/dev/sda2 1050624 1550335 499712 244M Linux filesystem
/dev/sda3 1550336 500117503 498567168 237,8G Linux filesystem
Disk /dev/sdb: 57,3 GiB, 61505273856 bytes, 120127488 sectors
Disk model: Ultra USB 3.0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier:
Device Start End Sectors Size Type
/dev/sdb1 2048 1050623 1048576 512M EFI System
/dev/sdb2 1050624 1550335 499712 244M Linux filesystem
/dev/sdb3 1550336 120125439 118575104 56,6G Linux filesystem
Disk /dev/mapper/sdc3_crypt: 56,5 GiB, 60693676032 bytes, 118542336 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/usb--vg-root: 48,7 GiB, 52240056320 bytes, 102031360 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/usb--vg-swap_1: 7,9 GiB, 8451522560 bytes, 16506880 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
lvs输出
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root intern-vg -wi-a----- 229,80g
swap_1 intern-vg -wi-a----- <7,87g
root usb-vg -wi-ao---- 48,65g
swap_1 usb-vg -wi-ao---- 7,87g
答案1
您应该注意,在撰写本文时,Debian 10 仍处于testing
状态,因此可能存在一些粗糙的地方。
我的猜测是,Debian 安装程序不知道第二次安装将位于可移动驱动器上,并使用配置为从 USB 设备启动的版本覆盖了 EFI 系统分区 (ESP) 上第一个安装的 GRUB 副本。
要修复此问题,您必须按任意顺序执行两件事:
1.) 您应确保基于 USB 的安装可自行引导,即 USB 驱动器应包含一个 FAT32 分区,其中包含位于 的引导加载程序的副本\EFI\boot\bootx64.efi
。这就是 UEFI 意义上可移动 USB 启动的原因。
2.) 要修复内部 HDD 上安装的引导加载程序,您可以启动到基于 USB 的安装,然后挂载基于内部 HDD 的安装的分区并 chroot 到该安装中。
您的fdisk -l
输出表明可能也有 LVM 正在使用。
根据您的fdisk -l
输出,这应该是所需命令的开头。请注意,所有这些都应该以 root 身份运行,因此首先使用su -
并输入 root 密码,或者sudo -i
输入您自己的密码,以成为 root。
# mkdir /mnt/hddsystem
# cryptsetup luksOpen /dev/sda3 sda3_crypt
<the above command will ask you the encryption passphrase of the HDD installation.
If successful, then /dev/mapper/sda3_crypt should now exist>
# vgscan
<this detects the LVM volume group within the encrypted container of the HDD installation>
# lvs
<this displays all the detected LVM logical volumes and their names>
# vgchange -ay intern-vg
# mount /dev/mapper/intern--vg-root /mnt/hddsystem
<if successful, directories like /mnt/hddsystem/dev, /mnt/hddsystem/proc, /mnt/hddsystem/sys
should be visible and empty at this point. Other directories should be visible under /mnt/hddsystem too.>
# mount /dev/sda2 /mnt/hddsystem/boot
# mount /dev/sda1 /mnt/hddsystem/boot/efi
此时,修复 USB 系统的启动也可能很容易,只需将查找 USB 介质的 GRUB 版本复制到 USB 上,然后再将其覆盖到 HDD 上即可。
# mkdir /mnt/usb-esp
# mount /dev/sdb1 /mnt/usb-esp
# mkdir -p /mnt/usb-esp/EFI/boot
# cp -r /mnt/hddsystem/boot/efi/EFI/debian /mnt/usb-esp/EFI/
# cp /mnt/usb-esp/EFI/debian/grubx64.efi /mnt/usb-esp/EFI/boot/
# cp /mnt/hddsystem/boot/efi/EFI/debian/shimx64.efi /mnt/usb-esp/EFI/boot/bootx64.efi
# umount /mnt/usb-esp
返回修复硬盘安装...
# mount -o bind /dev /mnt/hddsystem/dev
# mount -o bind /proc /mnt/hddsystem/proc
# mount -o bind /sys /mnt/hddsystem/sys
<these commands are preparations for the following chroot command, mounting all the necessary real and virtual filesystems so that the inactive HDD-based installation can be used like an active, running system.>
# chroot /mnt/hddsystem /bin/bash
<this command transitions us to the HDD-based environment; from this point onwards, for this shell session only, /mnt/hddsystem is /.>
# grub-install /dev/sda1
# update-grub
<these two commands to fix the bootloader are what all the preparations above were for.>