Debian10 在外部 USB 與 SSD 之間啟動時出現啟動問題

Debian10 在外部 USB 與 SSD 之間啟動時出現啟動問題

我已經在內部硬碟上安裝了 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.>

相關內容