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

Issues related to hardware problems
Post Reply
User avatar
warron.french
Posts: 616
Joined: 2014/03/27 20:21:58

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

Post by warron.french » 2019/07/11 21:07:59

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.
Last edited by warron.french on 2019/07/22 14:32:31, edited 1 time in total.
Thanks,
War

chemal
Posts: 776
Joined: 2013/12/08 19:44:49

Re: Legacy BIOS versus UEFI check within RHEL 7

Post by chemal » 2019/07/11 21:31:33

Code: Select all

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

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Legacy BIOS versus UEFI check within RHEL 7

Post by TrevorH » 2019/07/11 21:43:11

The detectable difference is that /sys/firmware/efi exists (UEFI) or it doesn't (Legacy BIOS)
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
warron.french
Posts: 616
Joined: 2014/03/27 20:21:58

Re: Legacy BIOS versus UEFI check within RHEL 7

Post by warron.french » 2019/07/12 19:25:28

Awesome, thank you both!
Thanks,
War

zerofire
Posts: 16
Joined: 2019/10/11 01:41:41

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

Post by zerofire » 2019/10/11 03:41:57

Does this also work for detecting systems that have UEFI but are running in Legacy mode?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

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

Post by TrevorH » 2019/10/11 15:46:56

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.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

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

Post by jlehtone » 2019/10/11 16:25:53

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.

zerofire
Posts: 16
Joined: 2019/10/11 01:41:41

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

Post by zerofire » 2019/10/12 18:38:21

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

Post Reply