Loading...
X

How to check if a computer is using BIOS or UEFI; GRUB or systemd-boot bootloader; MBR or GPT partition table

How to know if UEFI or GRUB is being used?

The system booting process consists of the following 4 steps:

  1. System initialization: UEFI or BIOS (POST)
  2. Starting the bootloader (GRUB2 or systemd-boot)
  3. Kernel initialization
  4. Starting systemd, the parent of all processes

Related:

If the BIOS is used in the first step, then the GRUB bootloader is most likely involved in the second step.

If UEFI is used in the first step, then both the GRUB bootloader and the systemd-boot bootloader can be used in the second step.

If you're wondering if your computer is running UEFI or GRUB, then this question is the wrong one because UEFI and GRUB are not mutually exclusive.

Modern GRUB2 can work with both BIOS and UEFI (using efibootmgr). On Arch Linux, BIOS and UEFI support is bundled into a single grub package. In Debian and derivative distributions, GRUB comes in two versions:

  • grub-pc (BIOS version)
  • grub-efi (UEFI version)

How to find out if your computer is using BIOS or UEFI

The easiest way is to check if the computer is using UEFI. If the answer is negative, then this means that the BIOS is used on the computer.

To check if your computer supports UEFI, run the command:

ls -l /sys/firmware/efi

If a list of directories is displayed, for example this:

This means that this computer supports UEFI.

If an error message is shown:

ls: cannot access '/sys/firmware/efi': No such file or directory

This means that this computer is working with BIOS.

Also you can check for UEFI variables:

efivar -l

If a large list of variables is shown, then the computer was booted using UEFI.

If an error message is displayed

-bash: efivar: command not found

That means the computer is running on BIOS.

You can also use the efibootmgr utility to check:

efibootmgr

If it displays information about the UEFI Boot Manager, then UEFI is being used.

Please note that the latter method is not reliable, since the efibootmgr utility is not required even for UEFI computers. That is, if, when using UEFI, you receive a message that the command was not found, then the computer may support UEFI, but the efibootmgr package is not installed on it.

Another way is the bootctl utility:

sudo bootctl

Couldn't find EFI system partition. It is recommended to mount it to /boot or /efi.
Alternatively, use --esp-path= to specify path to mount point.
System:
    Not booted with EFI

Pay attention to the message “Not booted with EFI”, that is, the computer uses BIOS.

Finally, the presence of an EFI partition can be checked with fdisk:

sudo fdisk -l

If the boot disk has an “EFI System” partition, then this computer supports UEFI.

Since UEFI requires a separate “EFI System” partition, it can be argued that if this partition is not on the boot disk, then this computer does not support EFI, but works with BIOS.

How to find out if a computer is running GRUB or systemd-boot

To find out if the systemd-boot bootloader is being used, run the command:

sudo bootctl is-installed

The answer is rather concise: “yes” or “no”.

You will only get an answer if your computer uses UEFI. Otherwise, it will output:

Couldn't find EFI system partition. It is recommended to mount it to /boot or /efi.
Alternatively, use --esp-path= to specify path to mount point.

By exclusion, you can determine that if the systemd-boot bootloader is not used, then the GRUB bootloader is most likely used. But how to reliably confirm that it is the GRUB bootloader that is being used?

A system with GRUB installed must have a /boot/grub folder and a /boot/grub/grub.cfg file. To confirm that the GRUB bootloader is being used, you can check for their presence:

ls -l /boot/grub/grub.cfg

You can find other ways to identify GRUB, such as looking for the string “GRUB” in the boot area of the disk, but this method only applies to GRUB-PC! This method does not work with GRUB-EFI.

Since Debian currently has two different versions of GRUB-EFI and GRUB-PC, which are quite different, let's look at how to identify each of them.

How to know if GRUB-EFI or GRUB-PC is being used

As already mentioned, there are two versions of GRUB in Debian and derivatives:

  • grub-pc (BIOS version)
  • grub-efi (UEFI version)

They are quite different, and the methods for determining them also differ.

On Arch Linux and its derivatives, the GRUB-EFI and GRUB-PC versions are bundled into one package.

Using the previous information, you can logically determine whether GRUB-EFI or GRUB-PC is being used:

  1. If the computer uses EFI but does not use the systemd-boot bootloader, then the GRUB-EFI bootloader is used
  2. If the computer does not use EFI, then the GRUB-PC bootloader is probably used

There are also more reliable ways to check which version of the GRUB bootloader your computer is using.

First of all, check the contents of the /boot/grub directory:

ls -l /boot/grub

The presence in this directory of the subdirectory “x86_64-efi” indicates that this operating system uses GRUB-EFI:

The presence of the “i386-pc” directory says that GRUB-PC is being used:

If you receive an error message:

ls: cannot access '/boot/grub': No such file or directory

It means that this OS does not use GRUB.

In the Debian and derivatives repositories, the GRUB-EFI and GRUB-PC installation packages are marked as conflicting, meaning that only one of them can be installed. Therefore, we can check the installed packages to determine which version of GRUB is being used:

dpkg -l | grep grub | grep ii

The installed packages “grub-efi-amd64” and “grub-efi-amd64-bin” indicate that GRUB-EFI is being used:

The installed packages “grub-pc” and “grub-pc-bin” say that GRUB-PC is being used:

Another way to confirm that the operating system is using the GRUB-PC bootloader is the following command:

dd bs=512 count=1 if=/dev/sda 2>/dev/null | strings | grep GRUB

If any output is shown, GRUB-PC is being used.

In the previous command, you need to correctly specify the disk name, you can see the disk names with the command:

fdisk -l

An example command if the operating system is installed on the /dev/vda drive:

dd bs=512 count=1 if=/dev/vda 2>/dev/null | strings | grep GRUB

This screenshot shows that the OS uses GRUB-PC:

There is no similar command for GRUB-EFI.

How to find out if your computer is using an MBR or GPT partition table

Typically, EFI computers use the GPT partition table, and BIOS computers use the MBR, although exceptions are possible.

The following command will show the partition table type for a particular drive:

lsblk -dno PTTYPE /dev/DISK

For example:

lsblk -dno NAME,PTTYPE /dev/nvme0n1

And the following command will display the partition table types for all disks in the operating system:

lsblk -dno NAME,PTTYPE

To check which partition table is on the computer using fdisk, run the command:

sudo fdisk -l

Pay attention to the “Disklabel type” value:

  • gpt stands for GPT
  • dos stands for MBR

The same information can be obtained using the cfdisk utility:

cfdisk /dev/nvme0n1

Pay attention to the value of “Label”:

  • gpt stands for GPT
  • dos stands for MBR


2 observations on “How to check if a computer is using BIOS or UEFI; GRUB or systemd-boot bootloader; MBR or GPT partition table
  1. Shane

    About "How to know if GRUB-EFI or GRUB-PC is being used":

    It's not applicable to the new version(PVE 8.0.3 based on  Debian 12).

    Captured the following output from a PVE:

    (1) # ls -l /boot/grub
    total 2384
    drwxr-xr-x 2 root root    4096 Oct 29 12:09 fonts
    -rw------- 1 root root    7528 Nov  2 16:10 grub.cfg
    -rw-r--r-- 1 root root    1024 Oct 29 12:09 grubenv
    drwxr-xr-x 2 root root   12288 Oct 29 12:09 i386-pc
    drwxr-xr-x 2 root root    4096 Oct 29 12:09 locale
    -rw-r--r-- 1 root root 2392304 Jun 22 22:51 unicode.pf2
    drwxr-xr-x 2 root root   12288 Oct 29 12:09 x86_64-efi

    (2) # dpkg -l | grep grub | grep ii
    ii  grub-common                          2.06-13                        amd64        GRand Unified Bootloader (common files)
    ii  grub-efi-amd64-bin                   2.06-13                        amd64        GRand Unified Bootloader, version 2 (EFI-AMD64 modules)
    ii  grub-pc                              2.06-13                        amd64        GRand Unified Bootloader, version 2 (PC/BIOS version)

    ii  grub-pc-bin                          2.06-13                        amd64        GRand Unified Bootloader, version 2 (PC/BIOS modules)
    ii  grub2-common                         2.06-13                        amd64        GRand Unified Bootloader (common files for version 2)

    (3) # dd bs=512 count=1 if=/dev/nvme0n1 2>/dev/null | strings | grep GRUB
    GRUB

    So please update for the new version.

     
    Reply

Leave Your Observation

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