Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I determine whether a particular running Ubuntu system was booted using EFI/UEFI, or BIOS?

share|improve this question
    
Interesting question. Not an exact dupe but try the answer here, to a similar question. – Tom Brossman Jul 11 '12 at 21:10
1  
up vote 49 down vote accepted

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
share|improve this answer
    
Tested on QEMU 2.0.0, OVFM and Ubuntu 14.04: github.com/cirosantilli/runlinux/tree/… – Ciro Santilli 巴拿馬文件 六四事件 法轮功 Sep 7 '15 at 13:36
    
Works on Ubuntu 16.04, and Fedora 24 – geek1011 Jun 23 at 22:32

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.

share|improve this answer
2  
I'd simplify that to if dmesg | grep -Fq "EFI v"; then .... No point in running the [ command in addition, just to test for success/failure. $? is mainly useful for checking for specific errors. – geirha Jul 12 '12 at 10:50
2  
This is brittle, as there is no guarantee that the string searched for is generated by the desired feature. – Thorbjørn Ravn Andersen Jul 13 '12 at 1:28
1  
@izx, any script can happen to write "EFI v" as part of something else. If that happens on a BIOS machine, this would be a false positive. – Thorbjørn Ravn Andersen Jul 13 '12 at 1:37
2  
Best not to grep for text in the kernel log, it is subject to change. Best to look at /sys/firmware/efi – Colin Ian King Jul 27 '12 at 18:24
1  
I'd like to mention however that this is a great way to get the EFI version! – Omega Sep 3 '12 at 2:01

Python code to check if system is booted with UEFI or ROM BIOS:

import os,sys
def main():
    if(os.path.exists("/sys/firmware/efi")):
        print"\n\n System is booted with uefi!"
    else:
        print"\n\n System is booted with rom bios"
main()
sys.exit(0)
share|improve this answer

Had build my "Puppy"-Linux 64bit for my own, based on PuppyPrecise which is based on Ubuntu Precise, but cut down to be a "small" Linux.

Just at the Moment, my Puppy has booted in UEFI, but didn't have a directory /sys/firmware/efi

so, check for this directory would give wrong info on my AccerAspire ES 15

maybe this is because of new compiled Kernel (3.9.11) or because of the completly other initrd.gz, but it is

hope it helps

share|improve this answer
    
-1 for two reasons: First, this answer doesn't suggest the alternative way to tell whether "system was booted as EFI or BIOS". Second, while Puppy is based on Ubuntu, it doesn't necessarily handle features, such as EFI firmware location, the same way as Ubuntu does (and this was not explained in this answer either). – clearkimura May 6 at 7:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.