外付け USB と SSD 間で起動する場合の Debian10 の起動問題

外付け USB と SSD 間で起動する場合の Debian10 の起動問題

内部 HDD に Debian 10 をインストールしましたが、UEFI セキュア ブートで正常に動作しました。

2 番目の Debian を外付け USB にインストールすると、その USB からのみ起動します。

SSDを起動するためにノートパソコンからUSBを抜くとエラーが発生します

最小限の 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 インストーラーは 2 番目のインストールがリムーバブル ドライブ上に行われることを知らず、EFI システム パーティション (ESP) 上の GRUB の最初のインストールのコピーを、USB デバイスから起動するように構成されたコピーで上書きしたと考えられます。

修正するには、次の 2 つの操作を任意の順序で実行する必要があります。

1.) USB ベースのインストールが単独で起動可能であることを確認する必要があります。つまり、USB ドライブには、ブートローダーのコピーを含む FAT32 パーティションが含まれている必要があります\EFI\boot\bootx64.efi。これが、リムーバブル USB を UEFI の意味で起動可能にするものです。

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

この時点で、HDD に上書きする前に、実際に起動する USB メディアを探す GRUB のバージョンを USB にコピーするだけで、USB システムの起動も簡単に修正できる可能性があります。

# 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

HDD のインストールの修正に戻ります...

# 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.>

関連情報