How can I tell if my system was booted as EFI/UEFI or BIOS?

The easiest way is to check to see if /sys/firmware/efi exists. It does not appear if you booted using traditional BIOS.

#!/bin/bash
[ -d /sys/firmware/efi ] && echo UEFI || echo BIOS

Deprecated

The answer below is a method that may not always work.
Instead use Colin's answer based on /sys/firmware/efi.


It's very easy to tell if a system was booted in EFI (or not, in which case it must be BIOS):

Just use dmesg | grep "EFI v"

  • This will return a line like this, if the system was booted off of EFI:

    [ 0.000000] EFI v2.00 by American Megatrends
  • Or return nothing if it was not, in which case it was booted off of BIOS

Example of bash script usage based on grep's exit code:

...
dmesg | grep -q "EFI v"    # -q tell grep to output nothing
if [ $? -eq 0 ]      # check exit code; if 0 EFI, else BIOS
then
    echo "You are using EFI boot."
  else
    echo "You are using BIOS boot"
fi
...

Source: For how to determine if an EFI system is using legacy-BIOS emulation or not, as well as more information on testing for EFI and EFI compatibility, along with the strings for a number of EFI vendors/versions, please see this page from the Ubuntu Developer Summit for Precise.

Tags:

Bios

Boot

Uefi