How to detect whether Linux runs in UEFI or BIOS mode inside the Linux?

How to detect whether Linux runs in UEFI or BIOS mode inside the Linux itself without needed to boot the the management console of the mother board?

You can detect whether Linux runs in EFI mode by checking whether /sys/firmware/efi exist. In bash, you can test by

[ -d /sys/firmware/efi/ ]

This technique is used in the grub2-regen-cfg tool: http://www.systutorials.com/136638/how-to-regenerate-grub2-config-file-on-linux/

Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *