2

I'm doing an ssh to a PC that no one can actually physically reach, yet. Said PC was made after 2011, so it defintely has UEFI.

The issue is that every posts on the web is about checking if the PC has a UEFI or BIOS (e.g. How to know if I'm booting using UEFI?), which is not what I'm trying to find out.

 

My question is then pretty simple: How do I tell if a PC with UEFI, booted with CSM/Legacy/BIOS Mode enabled or not ?

 

Update 1: There's lot of ways to tell if it's UEFI or not, but none of them can definitely tell since they all contradict themselves.

Details:

  • The drive is MBR
  • There's no sign of an ESP partition at all (fstab, etc)
  • There's no sign of EFI files on /boot at all
  • cat /sys/firmware/efi/fw_platform_size gave 64, which wouldn't work at all if it was in CSM Mode on another PC.
  • update-grub gave Adding boot menu entry for EFI firmware configuration
  • efibootmgr gave me a boot order, which usually shows when there's a UEFI.
8
  • 1
    Kernel logs, probably. Jun 25, 2021 at 12:07
  • Do you know what keywords I must look after ?
    – X.LINK
    Jun 25, 2021 at 12:09
  • @Freddy: This is the kind of posts that didn't helped. It's more about if your PC has UEFI or BIOS only, instead of if I'm using CSM mode on a UEFI motherboard or pure UEFI mode. I do have the /sys/firmware/efi/* folders, that still doesn't tell me if I'm running CSM mode or not.
    – X.LINK
    Jun 25, 2021 at 13:38
  • 2
    If ssh'd does this show that system? Check UEFI boot mode [ -d /sys/firmware/efi ] && echo EFI || echo Legacy You can also look at ESP, if you have ESP with /EFI/ubuntu folder it probably is UEFI. If drive is gpt partitioned and no bios_grub for BIOS boot, only an ESP it is UEFI. And does fstab show mount of ESP- efi system partition.
    – oldfred
    Jun 25, 2021 at 15:19
  • @oldfred Ok that's weird, the command clearly says EFI, but there's no ESP partition nor /boot/EFI folders at all on the drives for sure.
    – X.LINK
    Jun 25, 2021 at 15:22

3 Answers 3

1

Seems reasonable to try:-

dmesg | grep efi: which will produce sensible output for an efi boot.

6
  • This command returned: [ 0.000000] efi: EFI v2.70 by American Megatrends [ 0.000000] efi: ACPI 2.0=0x9b233000 ACPI=0x9b233000 SMBIOS=0x9b8b4000 SMBIOS 3.0=0x9b8b3000 MEMATTR=0x95de1198 ESRT=0x97aca418 Would these SMBIOS values tells that I'm running on CSM mode on a UEFI motherboard ? I'm tempted to say yes, but I'm still unsure.
    – X.LINK
    Jun 25, 2021 at 15:08
  • 1
    Well, I get the same values - efi: EFI v2.70 by American Megatrends; efi: ACPI 2.0=; SMBIOS 3.0= (different addresses) and I know I have an efi boot and I did a fresh install to an empty NVME device only 3 months ago. Jun 25, 2021 at 15:34
  • Run the efibootmgr command - without any parameters it will show your efi boot order. Jun 25, 2021 at 15:36
  • Here's the order: HDD, UEFI: USB key, USB Key I see where we're going, if a USB key got its UEFI way of booting first vs its "BIOS" mode of booting, this would mean that it's in UEFI mode right ? But there's a catch: I don't have any ESP partition or /boot/EFI on the HDD. Which makes everything weird.
    – X.LINK
    Jun 25, 2021 at 15:55
  • The lack of the ESP partition looks pretty damning. Jun 25, 2021 at 16:22
1

I've found nothing in dmesg which indicates that the system has actually booted in EUFI mode as opposed to BIOS/CSM but here's a way to be absolutely sure:

Run sudo efibootmgr, if it complains EFI variables are not supported on this system then try sudo mount -t efivarfs none /sys/firmware/efi/efivars.

If you succeed, you'll see something like this:

$ sudo efibootmgr 
BootCurrent: 0002
Timeout: 1 seconds
BootOrder: 0002,0000,0001,0003,0004
Boot0000* Windows Boot Manager
Boot0001* UEFI:CD/DVD Drive
Boot0002* Fedora
Boot0003* UEFI:Removable Device
Boot0004* UEFI:Network Device

And even without this, I guess

# show the bitness of the internal EFI firmware
cat /sys/firmware/efi/fw_platform_size

could be enough.

2
  • Managed to get a laptop that does 64 bit UEFI, CSM mode and have an ESP partition, and a chinese PC that only do 32 bit UEFI. In CSM mode, /sys/firmware/efi/* is missing and trying to mount it fails, which cat /sys/firmware/efi/fw_platform_size will obviously give nothing, but will say 64 in UEFI mode, while the chinese PC will get 32. So it means cat /sys/firmware/efi/fw_platform_size should do it, but since UEFIs implementations are a mess, I'm still unsure about if that's the definite way to tell... because the ssh'd PC gave 64 while the HDD don't have an ESP partition...
    – X.LINK
    Jun 25, 2021 at 17:04
  • Ok it's really weird. I'm 100% sure I don't have an ESP partition and nothing about EFI's files on /boot, but doing an update-grub gave me Adding boot menu entry for EFI firmware configuration. What the hell...
    – X.LINK
    Jun 28, 2021 at 22:52
1

If /sys/firmware/efi/ directory exists, it means the firmware has provided UEFI Runtime Services to the kernel, which necessarily means you have booted in UEFI mode.

If the system is booted in BIOS-compatible mode (CSM), then the UEFI programming interfaces, including UEFI Runtime Services, will not be available to the kernel, and /sys/firmware/efi will not appear.

1
  • [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
    – Jedi
    Oct 6, 2021 at 19:37

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.