3

I have installed Ubuntu 18.04 (Bionic Beaver) on my PC in dual boot with Windows 10. I need to check if Ubuntu is booting in UEFI mode or legacy mode. I found a few sources online to check this, but I'm getting ambiguous results.

To be specific, this page, section "Identifying if an Ubuntu has been installed in UEFI mode" gives three ways to check this.

  1. Its /etc/fstab file contains an UEFI partition (mount point: /boot/efi)
  2. It uses the grub-efi bootloader (not grub-pc)
  3. From the installed Ubuntu, open a terminal (Ctrl+Alt+T) then type the following command: [ -d /sys/firmware/efi ] && echo "Installed in UEFI mode" || echo "Installed in Legacy mode"

I tried the 1st and 3rd ways.

My fstab file contains the below entry:

UUID=xxx    /boot/efi    ntfs    defaults    0   1

So, that means Ubuntu has booted in UEFI mode.

But running the command given in the third method

[ -d /sys/firmware/efi ] && echo "Installed in UEFI mode" || echo "Installed in Legacy mode"

prints Installed in Legacy mode.

Which is correct? Which is a reliable method for Ubuntu 18.04?

5

You can use the following command line,

test -d /sys/firmware/efi && echo efi || echo bios

or longer but easier to understand

if test -d /sys/firmware/efi;then echo efi;else echo bios;fi

See the following link,

help.ubuntu.com/community/Installation/FromUSBStick#Test_if_running_in_UEFI_mode


Edit: Comment about /boot/efi

/boot/efi is a persistent directory (that survives shutdown and reboot), while /sys/firmware/efi, actually the content of the /sys file system is created every time the computer is booted.

The existence of /boot/efi, a directory in an EFI system partition, can make it possible to boot in UEFI mode, but it does not make it impossible to boot in BIOS mode. So it does not tell you in which mode the computer is booted. It is possible to have installed Ubuntu and other linux systems that can boot both in UEFI and BIOS mode.

  • Yes. Both answers are almost same. This one is easier for newbies. Since that was the first answer, I accepted that. Also, both of the answers didn't answer my question completely. What is the difference between the two methods and why they give different outputs? – Nagabhushan S N Jan 20 at 7:20
  • @NagabhushanSN, /boot/efi is a persistent directory (that survives shutdown and reboot), while /sys/firmware/efi, actually the content of /sys file system is created every time the computer is booted. -- The existence of /boot/efi, an EFI system partition, can make it possible to boot in UEFI mode, but it does not make it impossible to boot in BIOS mode. So it does not tell you in which mode the computer is booted. It is possible to have installed Ubuntu and other linux systems that can boot both in UEFI and BIOS mode. – sudodus Jan 20 at 11:42
  • Great! This was what I was looking for. Please update your answer, I'll accept it :) – Nagabhushan S N Jan 20 at 12:51
4

The easiest way to find out if you are running UEFI or BIOS is to look for a folder /sys/firmware/efi.

The folder will be missing if your system is using BIOS.

Execute:

$ ls /sys/firmware/efi

Example of UEFI boot output :enter image description here

  • This directory is not present. But fstab file has boot/efi mount-point. Ambiguous right? – Nagabhushan S N Jan 19 at 4:53
  • 4
    You boot in BIOS mode – Carlos Dagorret Jan 19 at 4:54

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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