Page 1 of 1

[SOLVED] - Legacy BIOS versus UEFI check within RHEL 7

Posted: 2019/07/11 21:07:59
by warron.french
Is there a command that can be executed to determine if a machine is running off of a UEFI BIOS versus a Legacy (old style) BIOS from within the RHEL or CentOS 7 operating system?

I am aware of the /sys/firmware/efi (??) directory but I am wondering if there is a command that can be executed to provide a very succinct and unquestionable answer.

The reason is on my contract we have been building RHEL 7 hosts (servers, client and workstation alike) all with what I am referring to as Legacy BIOS (I don't know what else to call it); but recently we started realizing we (my team woke up to the idea) need to really start supporting UEFI BIOS configured and booted machines.

I want to be able/prepared to provide my management statistics that indicates how many machines are still Legacy BIOS and how many are not; and of the machines that are - which hosts by name - which I could do with a PuppetLabs Puppet custom fact that I write.

I was wondering if a command like dmidecode would have an authoritative answer? What is the appropriate command to use?

Thanks in advance.

Re: Legacy BIOS versus UEFI check within RHEL 7

Posted: 2019/07/11 21:31:33
by chemal

Code: Select all

test -d /sys/firmware/efi && echo "UEFI" || echo "Legacy"

Re: Legacy BIOS versus UEFI check within RHEL 7

Posted: 2019/07/11 21:43:11
by TrevorH
The detectable difference is that /sys/firmware/efi exists (UEFI) or it doesn't (Legacy BIOS)

Re: Legacy BIOS versus UEFI check within RHEL 7

Posted: 2019/07/12 19:25:28
by warron.french
Awesome, thank you both!

Re: [SOLVED] - Legacy BIOS versus UEFI check within RHEL 7

Posted: 2019/10/11 03:41:57
by zerofire
Does this also work for detecting systems that have UEFI but are running in Legacy mode?

Re: [SOLVED] - Legacy BIOS versus UEFI check within RHEL 7

Posted: 2019/10/11 15:46:56
by TrevorH
As far as I know, if you put your hardware in UEFI mode and then boot off a corrupted CentOS iso image that has had the UEFI code removed from it by a broken USB-stick utility, then it will boot in Legacy mode and /sys/firmware/efi will NOT be present. But to do that you have to be booting broken installation media.

Re: [SOLVED] - Legacy BIOS versus UEFI check within RHEL 7

Posted: 2019/10/11 16:25:53
by jlehtone
zerofire wrote:
2019/10/11 03:41:57
Does this also work for detecting systems that have UEFI but are running in Legacy mode?
Logically, there are four (boolean) cases:
1. Legacy hardware, legacy mode
2. Legacy hardware, UEFI mode (which is obviously impossible)
3. UEFI hardware, legacy mode
4. UEFI hardware, UEFI mode (/sys/firmware/efi exists)

Only on case 4 does the kernel mount/expose the UEFI variables via sysfs.

The case 3 is possible also by setting the UEFI boot options to support both legacy and UEFI and then selecting (in boot menu) the legacy boot media.

I presume that the (followup) question is whether zerofire can distinguish cases 1 and 3 from each other?


I have access to a Dell desktop that does boot in legacy mode even though it could use UEFI.
(warron.french's style "we install standard image" case)
* There is no /sys/firmware/efi
* dmidecode -t BIOS reports "UEFI supported"

I do presume that it depends on the "BIOS" vendor, whether dmicode will see what we'd like to see.

Re: [SOLVED] - Legacy BIOS versus UEFI check within RHEL 7

Posted: 2019/10/12 18:38:21
by zerofire
Thank you. You are correct jlehtone. While we have our systems custom tuned here there are many of them from different times. I thought some might be tuned wrong and I was correct but not on the systems I thought. I was having a headache from some of them because there are BIOS units, UEFI-like BIOS units, and UEFI units. The UEFI-like BIOS units had mouse control and everything but no UEFI boot since they are still BIOS based. I also noticed some of our UEFI units were configured wrong and were using Legacy Mode but they were dated during the transition.

When I read "standard images" I also thought they might be turning off UEFI boot on newer hardware to make it work.Good to know the first method might not be available as detection. Be aware that there are three different UEFI types based on how much you are spending/friendliness of manufacturer.

UEFI Config's
1. UEFI Boot, UEFI Boot with Legacy support, Legacy Boot
2. UEFI Boot, Legacy Boot
3. UEFI Boot only