Let's say, I have an OpenWrt device, but someone else installed OpenWrt on it and I don't know whether the system was installed from a BIOS image or a UEFI image. How can I tell? Assume that I am accessing the device over SSH, so a direct peek into the BIOS is not in the cards right now...
The "general Linux" way, checking for /sys/firmware/efi, doesn't seem to work on OpenWrt, as there is no /sys/firmware/efi on UEFI systems (at least there isn't one on the SquashFS / UEFI box I am testing right now). It appears that lsblk -o PATH,SIZE,PARTUUID can provide some insight here.
So, can I conclude with a reasonable degree of confidence that the presence of the small third partition (/dev/whatever128) on the primary storage device in addition to /dev/whatever1 and /dev/whatever2 is an indicator of the system being UEFI? How about the length and format of partition IDs? Are they a reliable indicator?
Or perhaps there's a more obvious way to tell, which I am totally overlooking?
Hi.
Not sure that this is easiest way but ... install fdisk, and than run the command fdisk -l
If disklabel type is DOS, than you have a mbr disk
Another solution would be to boot a partition tool such as gparted from a USB stick.
I'm quite a fan of file -s /dev/sdx, if I remember correctly that tells me the boot sector type, mbr or gpt. Not completely sure if it tells me if uefi or not.
Addition: I installed the OpenWrt x86-64 combined ext4 EFI image into a virtual machine and file -s doesn't help but /sys/firmware/efi/ does exist.
And another addition: Based a virtual machine installation on OpenWrt x86-64 combined squashfs EFI image and here /sys/firmware/efi/ does exist for me too.
I don't understand how that can be. AFAICS, you will have at least /sys/firmware/efi/fw_platform_size if CONFIG_EFI is enabled and efi_enabled(EFI_BOOT) is true.
I am confused by this, too... If you are (or anyone else is) interested in digging into this some more, please let me know what you would like me to run on this anomalous box of mine, and I'll post the output here.
On both my EFI VM installation this was exactly the same:
root@OpenWrt:~# fdisk -lu /dev/sda
GPT PMBR size mismatch (246303 != 246334) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/sda: 120.28 MiB, 126123520 bytes, 246335 sectors
Disk model: VMware Virtual S
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: ABEAE232-5289-82A1-0E57-FLUFFYBUNNY
Device Start End Sectors Size Type
/dev/sda1 512 33279 32768 16M Linux filesystem
/dev/sda2 33280 246271 212992 104M Linux filesystem
/dev/sda128 34 511 478 239K BIOS boot
Partition table entries are not in disk order.
Plus, the fact that you have a gpt label type and a /dev/sda128 would suggest an EFI system.
Now there is still the question why no /sys/firmware/efi folder exists. Your on latest stable as I am.
Is your device a Sophos SG105 by any chance? Reminds me of mine
What does find /sys -iname '*efi* report? Any entries with 'efi' in it's name? For me it reports:
Mmmmh, I'm out of my depth here. I assume it has to be some oddity with older CPU and the BIOS implementation, or CSM mode enabled.
Since both of you got /sys/firmware/acpi/tables/UEFI then maybe a check for /sys/firmware/efi and if it doesn't exist then check for /sys/firmware/acpi/tables/UEFI. The later doesn't exist on my EFI VMs.