2

I have installed Debian 10 on an internal hdd it worked fine with UEFI secure boot.

When I installed second Debian on external USB, then it only boots from that USB.

When I unplug the USB from the laptop to boot into the SSD, it comes to error

Minimal bash-like line editing.

Disabling secure boot didn't help.

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 output

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 
2

You should note that at the time of this writing, Debian 10 is still in testing state, so there may be rough edges here and there.

My guess would be that the Debian installer had no clue that the second installation was going to be on a removable drive, and overwrote the first installation's copy of GRUB on your EFI System Partition (ESP) with one configured to boot from the USB device.

To fix, you would have to do two things, in any order:

1.) You should ensure that the USB-based installation is bootable on its own, i.e. the USB drive should include a FAT32 partition containing a copy of the bootloader at \EFI\boot\bootx64.efi. That is what makes a removable USB bootable in the UEFI sense.

2.) To fix the bootloader of the installation on the internal HDD, you could boot into the USB-based installation, then mount the partition(s) of the internal HDD-based installation and chroot into that installation.

Your fdisk -l output indicates that there is probably LVM in use too.

Based on your fdisk -l output, this should be the beginning of the commands required. Note that all this should be run as root, so first use either su - and enter the root password, or sudo -i and enter your own password, to become 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

At this point, it might be easy to fix the boot of the USB system too, by just copying the version of GRUB that looks for USB media to boot actually onto the USB, before we overwrite it on the 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

Back to fixing the HDD installation...

# 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.>
  • thank you.mount /dev/sdb1 /mnt/hddsystem – fernand Jun 8 at 20:21
  • thank you.mount /dev/sdb1 /mnt/hddsystem sdb1 for wat is that. the third line with dev at last didnt work... i forgott to say both hdd usb are full hd encrypted. during inatallation grub installs automatically without asking. shoud i mount encrypted partition to fix it if yes can u give me all commands again. otherway i plan to go for debian9 an then upgrad to 10 – fernand Jun 8 at 20:28
  • That complicates things a bit. Please edit your question and add the output of fdisk -l command (you'll need to run it as root), so that I can identify the correct disk devices to use. Instead of mount /dev/sdb1 /mnt/hddsystem you would need two steps like cryptsetup luksOpen /dev/<your encrypted partition> hddroot, then mount /dev/mapper/hddroot /mnt/hddsystem, then you might be able to continue as above. – telcoM Jun 8 at 20:40
  • ok , pleas giv me then all needed commands for test . otherways i switch to debian9 . as i said .when hdd works then usb not when usb fixed then hdd not – fernand Jun 8 at 20:54
  • question has been edited – fernand Jun 8 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.