Debian10-Bootproblem beim Booten zwischen externem USB und SSD

Debian10-Bootproblem beim Booten zwischen externem USB und SSD

Ich habe Debian 10 auf einer internen Festplatte installiert, es hat mit dem sicheren UEFI-Boot einwandfrei funktioniert.

Wenn ich das zweite Debian auf einem externen USB-Stick installiert habe, bootet es nur von diesem USB-Stick.

Wenn ich den USB-Stick vom Laptop abziehe, um die SSD zu booten, kommt es zu einem Fehler

Minimale bash-ähnliche Zeilenbearbeitung.

Das Deaktivieren des sicheren Starts hat nicht geholfen.

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-Ausgabe

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 

Antwort1

Bitte beachten Sie, dass sich Debian 10 zum Zeitpunkt des Schreibens dieses Artikels noch im testingEntwicklungsstadium befindet und es daher hier und da noch einige Ecken und Kanten geben kann.

Ich vermute, dass das Debian-Installationsprogramm keine Ahnung davon hatte, dass die zweite Installation auf einem Wechseldatenträger erfolgen würde, und die GRUB-Kopie der ersten Installation auf Ihrer EFI-Systempartition (ESP) mit einer Kopie überschrieben hat, die für den Bootvorgang vom USB-Gerät konfiguriert war.

Zur Behebung des Problems müssen Sie zwei Dinge in beliebiger Reihenfolge tun:

1.) Sie sollten sicherstellen, dass die USB-basierte Installation selbst bootfähig ist, d. h. das USB-Laufwerk sollte eine FAT32-Partition enthalten, die eine Kopie des Bootloaders unter enthält \EFI\boot\bootx64.efi. Dadurch wird ein entfernbarer USB-Stick im UEFI-Sinne bootfähig.

2.) Um den Bootloader der Installation auf der internen Festplatte zu reparieren, können Sie die USB-basierte Installation booten, dann die Partition(en) der internen Festplatte-basierten Installation mounten und per chroot in diese Installation einsteigen.

Ihre fdisk -lAusgabe zeigt, dass wahrscheinlich auch LVM verwendet wird.

Basierend auf Ihrer fdisk -lAusgabe sollte dies der Anfang der erforderlichen Befehle sein. Beachten Sie, dass all dies als Root ausgeführt werden sollte. Verwenden Sie also zuerst entweder su -und geben Sie das Root-Passwort ein oder sudo -iund geben Sie Ihr eigenes Passwort ein, um Root zu werden.

# 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

An diesem Punkt könnte es auch einfach sein, den Bootvorgang des USB-Systems zu reparieren, indem Sie einfach die Version von GRUB, die nach USB-Medien sucht, um sie tatsächlich auf den USB-Stick zu booten, kopieren, bevor wir sie auf der Festplatte überschreiben.

# 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

Zurück zum Reparieren der Festplatteninstallation ...

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

verwandte Informationen