1. Overview
UEFI is a modern replacement for the aging BIOS firmware. It offers several advantages, including faster boot times, support for larger hard drives, and improved security features.
In this tutorial, we’ll employ several tools and techniques available to check for the boot method in Linux. First, we’ll start with the simple dmesg utility to look for the entries regarding EFI. Then, we’ll use efibootmgr and efivar to check for the EFI variables.
Lastly, we’ll resort to a manual approach by checking the EFI mount point and the NVRAM EFI variables.
2. Checking the Boot Method
To check the boot method used to boot a Linux machine, we can examine the system’s configuration or settings to determine whether it follows the traditional BIOS boot method or the newer EFI/UEFI boot method.
For that purpose, we can use the various utilities, which we’ll explore in the following sections.
2.1. dmesg
The dmesg command displays the messages related to the kernel as well as the firmware-related information.
By default, it’s readily available on most Linux distributions. So, we’ll simply print out the log and grep the EFI entries from it:
$ sudo dmesg | grep -i "EFI v"
[ 0.000000] efi: EFI v2.25 by American Megatrends
...
As we can see, the presence of the entry indicates that we’re currently booted using UEFI. In contrast, the absence of the entry signifies that we’re using the legacy boot.
2.2. efibootmgr
The efibootmgr tool provides information about the UEFI boot entries in the system’s NVRAM (Non-Volatile Random Access Memory).
By default, it’s not installed on most Linux distributions. Therefore, we can install it from the package repository using a package manager like apt:
$ sudo apt install efibootmgr -y
Once installed, let’s verify it:
$ efibootmgr
version 17
Now, let’s use it to check whether we’re using UEFI:
$ sudo efibootmgr
EFI boot variables are not supported on this system
As we can, we’re not booted using UEFI. In this scenario, we’re running Ubuntu on KVM, which is using the legacy boot. However, let’s check it out on a system that’s booted using UEFI:
$ sudo efibootmgr
BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0001, 0003, 0000
...
Boot0001* debian
On UEFI booted systems, efibootmgr will lay out the entire booting sequence. The BootOrder variable specifies the preferred order of boot options, while the BootCurrent variable specifies the currently selected boot option.
2.3. efivar
efivar is another handy utility that allows us to interact with the UEFI environment variables.
Like efibootmgr, it might not be preinstalled on most Linux machines. However, it should be available in the official package repositories under the canonical name efivar:
$ sudo apt install efivar -y
Once installed, let’s verify it:
$ which efivar
/usr/bin/efivar
Now, if we were to run this command on a machine that’s booted through legacy boot, it would print nothing:
$ sudo efivar -l
On the other hand, on UEFI systems, it spits out the EFI NVRAM variables:
$ sudo efivar -l
Boot0001 (UEFI Hard Drive)
Boot0002 (DVD/CDROM)
Boot0003 (Generic USB Drive)
BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0001,0003,0000
...
2.4. EFI Mount Point
UEFI systems typically have an EFI System Partition (ESP) mounted at /boot/efi or /efi directory. Therefore, we can use a tool like lsblk or df to check for block devices mounted on those mount points:
$ df -h | grep -i efi
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 390M 16M 374M 4% /boot/efi
Similarly, we can also use lsblk:
$ lsblk | grep -i efi
├─vda1 2:1 0 390M 0 part /boot/efi
2.5. Manually Checking the EFI NVRAM Variables
Alternatively, we can manually examine the EFI NVRAM variables in the /sys/firmware/efi/vars directory.
To check if we’re using UEFI on Linux, you can navigate to the /sys/firmware/efi/vars/
directory using the command line or a file manager. If the directory exists and is populated with files and subdirectories, it indicates that the system is booted using UEFI:
total 0
-rw-r--r-- 1 root root 256 May 27 10:01 BootCurrent-8be4df61-93ca-11d2-aa0d-00e098032b8c
-rw-r--r-- 1 root root 256 May 27 10:02 BootOrder-8be4df61-93ca-11d2-aa0d-00e098032b8c
...
The efibootmgr and efivar tools are front-ends to this specific directory for easier management.
3. Conclusion
In this article, we covered how to check whether a Linux system is booted through UEFI. For that purpose, we used different tools such as dmesg, efibootmgr, and efivar.
Apart from that, we also discussed how we could verify the boot method without any tools by examining the /sys/firmware/efi/vars directory.