Grub with UEFI: Local Debian doesn't boot after another installation on external SSD
I have a ThinkPad laptop with BIOS enabling UEFI mode only (no legacy). It has both Windows and Debian12 installed as dual-boot options – selectable on start via Grub. Recently my son decided to use this laptop to install Debian on an external SSD drive. Everything went fine and he was able to boot into the new Debian on the external SSD drive, however the Grub on the laptop was somehow altered so now it boots directly into Windows, without providing the start up menu to choose the OS (Debian was the default OS to boot).
-
What happened exactly? I didn’t followed the process, but it seems strange Debian install would make such a drastic change without a prior warning…
-
How can I now fix it to get my old Grub boot menu back?
Some relevant outputs (obtained externally booted Fedora):
sudo lsblk -f -o +PARTUUID
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
PARTUUID
sda
├─sda1 vfat FAT32 B7E4-5065 581.4M 3% /boot/efi f53afd02-d970-4764-a560-93dab8cf172d
├─sda2 ext4 1.0 83c95001-37bc-47f8-b1ed-f9795ad1e50e 659.9M 25% /boot 0055d417-41d1-4d56-a442-7f8bfc092912
└─sda3 btrfs fedora 80b304cc-ed4e-4024-8953-7e622aa49c31 445.9G 4% /home ea394dcd-f563-4016-b058-5303e6ba94e5
/
sdb
zram0 [SWAP]
nvme0n1
├─nvme0n1p1 vfat FAT32 7892-C839 9860d2db-9326-4a98-bfc8-e4ec84887136
├─nvme0n1p2 c69f083e-f0c0-4ceb-843e-4016ccab4515
├─nvme0n1p3 ntfs 20CA9615CA95E776 222a0d1e-ca4f-4f84-a142-53c072758867
├─nvme0n1p4 ntfs 5CFEA3A4FEA374C4 b568758e-1d6c-4208-ae8d-0e62b30045a4
├─nvme0n1p5 ext4 1.0 dcb0d97a-513a-427c-be6c-618cd5dcf1d2 1a8a88f2-3a34-4449-8528-fee23e43cb2e
└─nvme0n1p6 swap 1 c4acdea6-8ae5-453f-af91-58f75a5c6e7c 7b3cf8d9-e418-4350-8e20-beb9f65cbf2e
and:
sudo efibootmgr
BootCurrent: 0004
Timeout: 2 seconds
BootOrder: 0004,0001,0003,0002,001C,0010,0011,0012,0013,0017,0018,001A,0000,0019,001B,001D,001E,001F,0024
Boot0000* Windows Boot Manager HD(1,GPT,9860d2db-9326-4a98-bfc8-e4ec84887136,0x800,0x32000)/File(EFIMicrosoftBootbootmgfw.efi)57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d0034006500370030002d0061006300630031002d006600330032006200330034003400640034003700390035007d00000061000100000010000000040000007fff0400
Boot0001* debian HD(1,GPT,e0c16116-3b12-42eb-b28f-6f2b50950004,0x800,0x100000)/File(EFIdebianshimx64.efi)
Boot0002* Fedora HD(1,GPT,7f992509-1fa6-4ca8-b42f-99492160a566,0x800,0x12c000)/File(EFIfedorashimx64.efi)
Boot0003* Fedora HD(1,GPT,01540828-ce9e-4881-897b-751b02b41f92,0x800,0x12c000)/File(EFIfedorashimx64.efi)
Boot0004* Fedora HD(1,GPT,f53afd02-d970-4764-a560-93dab8cf172d,0x800,0x12c000)/File(EFIfedorashimx64.efi)
Boot0010 Setup FvFile(721c8b66-426c-4e86-8e99-3457c46ab0b9)
Boot0011 Boot Menu FvFile(126a762d-5758-4fca-8531-201a7f57f850)
Boot0012 Diagnostic Splash Screen FvFile(a7d8d9a6-6ab0-4aeb-ad9d-163e59a7a380)
Boot0013 Lenovo Diagnostics FvFile(3f7e615b-0d45-4f80-88dc-26b234958560)
Boot0014 Startup Interrupt Menu FvFile(f46ee6f4-4785-43a3-923d-7f786c3c8479)
Boot0015 Rescue and Recovery FvFile(665d3f60-ad3e-4cad-8e26-db46eee9f1b5)
Boot0016 MEBx Hot Key FvFile(ac6fd56a-3d41-4efd-a1b9-870293811a28)
Boot0017* USB CD VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,86701296aa5a7848b66cd49dd3ba6a55)
Boot0018* USB FDD VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,6ff015a28830b543a8b8641009461e49)
Boot0019* NVMe1 VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,001c199932d94c4eae9aa0b6e98eb8a401)
Boot001A* NVMe0 VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,001c199932d94c4eae9aa0b6e98eb8a400)
Boot001B* ATA HDD0 VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f602)
Boot001C* USB HDD VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,33e821aaaf33bc4789bd419f88c50803)
Boot001D* PCI LAN VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,78a84aaf2b2afc4ea79cf5cc8f3d3803)
Boot001E Other CD VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,aea2090adfde214e8b3a5e471856a35406)
Boot001F Other HDD VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f606)
Boot0020* USBR BOOT CDROM PciRoot(0x0)/Pci(0x14,0x0)/USB(11,1)
Boot0021* USBR BOOT Floppy PciRoot(0x0)/Pci(0x14,0x0)/USB(11,0)
Boot0022* ATA HDD VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,91af625956449f41a7b91f4f892ab0f6)
Boot0023* ATAPI CD VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,aea2090adfde214e8b3a5e471856a354)
Boot0024* PCI LAN VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,78a84aaf2b2afc4ea79cf5cc8f3d3803)
- What happened exactly?
The analysis in the comments looks correct: the existing debian
entry in efibootmgr
does not match any ESPs on the system, and the only matching Fedora
entry, Boot0004
, refers to the externally booted Fedora on sda
.
The installations onto the external drive must have overwritten the original debian
entry.
- How can I now fix it[…]?
When running on the externally booted Fedora, you’ll first need to mount the filesystems used by Debian and chroot into the Debian installation:
sudo mount /dev/nvme0n1p5 /mnt # root filesystem
# if you had a separate /boot for Debian, it would be mounted to /mnt/boot here
sudo mount /dev/nvme0n1p1 /mnt/boot/efi # EFI System Partition
sudo mount -t proc none /mnt/proc # /proc virtual filesystem
sudo mount --rbind /dev /mnt/dev # /dev and /dev/pts
sudo mount --rbind /sys /mnt/sys # /sys and /sys/firmware/efi/efivars
sudo chroot /mnt /bin/bash # chroot into Debian
Now you are accessing the Debian installation as the root user, with the exact same "view" to the filesystems as when Debian is actually running. The easiest way to fix everything that might be wrong with the bootloader at once is to run grub-install
:
grub-install /dev/nvme0n1
This will automatically make sure that the shimx64.efi
, grubx64.efi
etc. in /boot/efi/EFI/debian
are correct, and also automatically rebuild the UEFI NVRAM boot variable for it.
After this, you can exit the chroot and undo all the prep work you had to do to reach this point:
exit
sudo umount /mnt/sys
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/boot/efi
sudo umount /mnt
… and then reboot. You might have to visit the BIOS settings to ensure the debian
boot entry has the highest priority, but after this your system should boot again into Debian without trouble.
Optionally, you may want to clear the UEFI NVRAM boot variables referring to inaccessible disks from your system, i.e. at least Boot0002
and Boot0003
. You can do this with efibootmgr
:
sudo efibootmgr -b 0002 -B
sudo efibootmgr -b 0003 -B
(To avoid unnecessary inconvenience, do not remove the Boot0004
variable until you have verified that the system now boots to Debian without any issues. That boot variable is currently responsible for booting to your external Fedora installation.)