It seems your system prefers a legacy bootloader if it can find one.
If so, and there is no way to change this preference in BIOS settings, then the answer could be to actively destroy the legacy boot code that has been placed into block #0 of the system disk.
Assuming your system disk is /dev/sda
, this should do it:
dd if=/dev/zero of=/dev/sda bs=446 count=1
This should make /dev/sda
unbootable in the legacy BIOS sense, leaving only UEFI bootloader(s) if any are present on the disk.
If the system then fails to boot altogether, you may need to boot from external media, e.g. from Debian 11 installation media in rescue mode. When you do so, make sure you choose to boot the external media in UEFI mode too. If the external media is booted in legacy mode, the run-time interface to UEFI firmware settings will be disabled, and the UEFI bootloader installation process will fail.
If you need to reinstall the UEFI version of the GRUB bootloader, you may want to use a command line like this when chrooted into your installed system:
grub-install --force-extra-removable --target=x86_64-efi /dev/sda
If your system is supposed to use Secure Boot, add the --uefi-secure-boot
option.
The --force-extra-removable
option sets up an extra copy of the bootloader at /boot/efi/EFI/BOOT/BOOTX64.EFI
which is normally used on UEFI-bootable removable disks, and may be helpful if your system has a buggy implementation of UEFI.
The removable-media bootloader location can also be set up without access to the UEFI firmware settings, so in theory it should succeed even if the rescue boot has actually started in legacy mode. If this allows you to make the system boot from its own disk in UEFI mode, you should then be able to use efibootmgr
to try and complete the UEFI bootloader registration process once the system is running in UEFI mode.
# apt remove grub-pc
(return it not installed)# apt install --reinstall grub-efi
# grub-install /dev/sda
# update-grub
,exit, rebooted, but not help, debian still boots in Legacy mode. Bootinfo summary.