2

How to fix issue "EFI variables are not supported on this system."?

sudo efibootmgr -v
EFI variables are not supported on this system.

Debian11 installed in UEFI mode, but something wrong with boot stage, and system always boots into Legacy bios mode.(despite in boot menu set UEFI mode)

Edit: blkid output

sudo blkid
/dev/sda1: LABEL_FATBOOT="BOOT" LABEL="BOOT" UUID="2F1D-01E6" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="c906677e-c2c2-42b5-b818-f0b19c046e95"
/dev/sda2: LABEL="swap" UUID="1274a782-676a-41b0-8509-92f73bd675c3" TYPE="swap" PARTUUID="4a555697-e713-400d-ae9e-613d028c7893"
/dev/sda3: LABEL="root" UUID="13503165-9c5f-498d-ab5f-0c13f11cbaa6" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="5484dedd-6adf-45af-b7b0-ba105d14528b"
/dev/sda4: LABEL="home" UUID="93c98828-5fb8-4c0e-b6bf-de8d13a9d22e" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="ae15bbdb-4e29-4dfa-aa99-b39e5377a098"
14
  • Boot live installer flash drive in UEFI boot mode & add Boot-Repair. Please copy & paste the pastebin link to the Bootinfo summary report ( do not post report), do not run the auto fix till reviewed.Lets see details, use ppa version with your USB installer (2nd option) or any working install, not Boot-Repair ISO (unless 21.10) help.ubuntu.com/community/Boot-Repair
    – oldfred
    Dec 23, 2021 at 19:40
  • I tried first to reinstall GRUB based on this wiki steps, I booted from LiveUSB in UEFI mode, installed efibootmgr, from chroot run # 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.
    – Lexx Luxx
    Dec 24, 2021 at 18:03
  • Are you running old copy of Bootinfoscript? I also do not see any reference to UEFI, so did you boot in BIOS mode? Report as is, did not show anything unusual other than grub in MBR with gpt drive. Normally BIOS installs of grub require a 1 or 2MB unformatted partition with bios_grub flag for grub to work correctly in BIOS mode. Boot of installed system typically requires UEFI boot on, or legacy/CSM/BIOS off in UEFI settings. And boot of flash drive requires UEFI:XXX option regardless of default settings for installed ssytem.
    – oldfred
    Dec 24, 2021 at 19:05
  • The Bootinfoscript installed via Package Manager, the latest vers there is 0.78-3. Yes, system still boots in legacy BIOS mode, despite in the boot menu set UEFI mode. Grub-PC installed incorrectly, on /dev/sda3 partition (root).
    – Lexx Luxx
    Dec 24, 2021 at 20:12
  • Since you have gpt, you must create a bios_grub partition for the BIOS version of grub. And you always install grub2's grub-pc to a drive like sda, never to a partition like sda3. I have been using gpt for about 10 years. And when converting from BIOS to UEFI, I would make first two partitions the ESP, then a bios_grub, so I could easily reinstall the different version of grub. Its grub-pc for BIOS and grub-efi-amd64 for UEFI.
    – oldfred
    Dec 24, 2021 at 21:27

1 Answer 1

1

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.

12
  • If you zero out the MBR, you erase partition table. If BIOS/MBR system, you just erased his system. IF gpt which it should be unless also booting Windows in old BIOS mode, then it may be recoverable with gdisk.
    – oldfred
    Dec 23, 2021 at 19:39
  • @oldfred the command I gave him only the first part of the MBR: the part where the boot code lives. The partition table is just the last 66 bytes of the block #0.
    – telcoM
    Dec 23, 2021 at 21:37
  • You are correct. And answer is good. Just would like to confirm configuration. If no ESP, then that may be the issue.
    – oldfred
    Dec 23, 2021 at 22:09
  • @telcoM I reinstalled grub with command grub-install --force-extra-removable --target=x86_64-efi /dev/sda, still boots in Legacy Bios mode. bootinfo
    – Lexx Luxx
    Dec 27, 2021 at 16:11
  • You seem to have a fully valid ESP, including the alternate/removable media boot path, so double-check your BIOS settings, just in case there is something boot-related you missed. If that does not help, it seems your BIOS prefers to boot in legacy mode unless it sees absolutely nothing bootable in that mode, so you'll need to destroy the legacy MBR boot code the way I suggested earlier. After that, you may need to go into the boot order settings and re-select the disk to boot from, since UEFI style might require a boot entry that is different from the legacy style.
    – telcoM
    Dec 28, 2021 at 1:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .