Tag: UEFI

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

UEFI does not see installed Linux (SOLVED)

How to add a new boot option to UEFI

UEFI usually automatically detects operating system loaders on media connected to a computer. But sometimes UEFI does not show all available options. Let's see how to add a new option to the UEFI boot menu.

For example, I plugged a flash drive with two operating systems – Windows 11 and Kali Linux – into my computer USB port, pressed ESC during boot to select boot options. The screenshot shows two options:

  • Linux OS on internal drive
  • Windows OS on a flash drive

If I select the first option, then it will boot from the internal disk, if the second, then Windows will boot. There is no way to boot Kali Linux from a flash drive.

Go to UEFI settings.

To come to the advanced UEFI settings, on my laptop I use the F7 key.

Go to the “Boot” tab.

As you can see, two boot options are selected and I can add additional ones – both from the drop-down list and new ones that are not in the list.

Among the options available in the drop-down list, there is no Kali Linux from a flash drive.

I select “Add New Boot Option”.

In the “Path for boot option” field, I need to specify the path to the /EFI/kali/grubx64.efi file.

I select a USB flash drive (there is a line “USB” in the path).

Select the “EFI” folder.

Select the “kali” folder.

Select the “grubx64.efi” file.

In the “Add boot option” field, I enter a name for this boot option and click the “Create” button.

The new boot option has been successfully created.

I add this option to the boot menu.

I save the settings made and restart the computer.

The option to boot “Kali” from a flash drive is now available.

The Linux bootloader is aware of the existence of Windows 11 installed and adds the ability to boot it into its menu.

When you select the “Windows Boot Manager” item, Windows 11 is booted from a USB flash drive.

When choosing to boot Kali Linux, you are required to enter a password for the encrypted partition on which the /home folder is located.

Further, work from a USB flash drive in Kali Linux continues as usual.

What to do if there are no settings for adding boot options in UEFI (BIOS)

UEFI varies from manufacturer to manufacturer: some have a lot of settings, some don't. It is possible that UEFI does not see the Linux bootloader and does not have the option to add a new item to the boot menu.

In this case, you can use a different approach. The essence of the method is that any UEFI by default tries to load the bootloader with the /EFI/BOOT/BOOTX64.EFI path. This is the so-called fallback path to the bootloader. Therefore, it is enough to rename the existing path to fallback for UEFI to start loading it.

For example, the path to the Kali Linux bootloader is /EFI/kali/grubx64.efi. In this case, you need to rename the “kali” folder to “BOOT” and the “grubx64.efi” file to “BOOTX64.EFI”.

These files are located on a hidden partition with the FAT32 file system.

Renaming files and folders on an EFI partition in Linux

To make these changes on Linux, mount the drive with read/write permissions and rename the directory and file.

Let's see the names of disks and partitions:

sudo fdisk -l

The partition with the EFI System on which we want to make changes is called /dev/sdb1, let’s mount it:

mkdir /tmp/efi
sudo mount /dev/sdb1 /tmp/efi

Now rename the folder and file sequentially.

sudo mv /tmp/efi/EFI/kali/ /tmp/efi/EFI/BOOT/
sudo mv /tmp/efi/EFI/BOOT/grubx64.efi /tmp/efi/EFI/BOOT/BOOTX64.EFI

When finished, unmount the /dev/sdb1 partition:

sudo umount /dev/sdb1

Renaming files and folders on an EFI partition in Windows

Open the Windows Command Prompt with administrator rights. To do this, press Win+x and select “Windows Terminal (Admin)”.

In the command line, run the program and wait for it to open:

diskpart

At the DISKPART prompt, type:

list disk

We need to find out what number the boot disk has. In my case it is 0.

Now enter the following command, replacing 0 with the number of your boot disk:

sel disk 0

Now the following command will list the volumes:

list vol

This is a very important step! We need to find out what number the partition with EFI has. The EFI partition has a FAT32 file system and does not have a letter.

In my screenshot, the EFI volume is number 2.

Run the following command, replacing 2 with your partition number:

sel vol 2

Now this volume needs to be assigned a letter. It can be any unoccupied letter.

assign letter=V:

Exit DISKPART:

exit

Close Command Prompt.

To edit the names of folders and files on the disk, administrator rights are required. To do this, for example, I run Double Commander with administrator rights.

See also: Free analogue of Total Commander

After that, you can edit the EFI partition like regular folders and files.

How to update the systemd-boot loader in /boot

Update /boot

During the installation of Arch Linux on modern computers with UEFI (BIOS replacement), we create a small partition on the disk with a mount point in /boot into which we install the boot loader using bootctl. This bootloader is systemd-boot, which is part of systemd. Over time, systemd can be updated like any other Arch Linux package. This does not automatically update the loader in /boot. For this reason, if you have been using the same Arch Linux installation for a long time, then your boot loader in /boot may be out of date.

This article will show you how to view version and supported features, and how to update systemd-boot in /boot on Arch Linux (as well as BlackArch and Manjaro).

What is systemd-boot

systemd-boot (short for sd-boot) is a simple UEFI boot manager. It provides a graphical menu for selecting an entry to boot and a kernel command line editor. Systemd-boot only supports systems with UEFI firmware.

systemd-boot loads boot record information from the EFI system partition (ESP), usually mounted in /efi/, /boot/, or /boot/efi/ during OS startup, and from an extended bootloader partition if it exists (usually mounted in /boot/). Fragments of the configuration file, kernels, initrds, and other EFI images to boot should usually reside on an ESP or extended boot loader partition. Linux kernels must be built with CONFIG_EFI_STUB so that they can be directly run as an EFI image. At boot time, systemd-boot automatically collects a list of boot records from the following sources:

  • Boot entries defined using the loader specification descriptor files located in /loader/entries/ on ESP and in the advanced loader section. They usually describe Linux kernel images with associated initrd images, but can also describe arbitrary other EFI binaries.
  • Unified kernel images as per bootloader specification as EFI executable binaries in /EFI/Linux/ on ESP and in the extended bootloader section.
  • Microsoft Windows EFI Boot Manager, if installed.
  • Apple MacOS X Boot Manager, if installed.
  • EFI Shell binary, if installed
  • Reboot to the option UEFI Firmware Configuration, if supported.

systemd-boot supports the following features:

  • Major changes to the boot manager configuration (such as setting a timeout, choosing a default boot record, etc.) can be made directly from the boot loader UI at boot time as well as at run time with EFI variables.
  • The boot manager integrates with the systemctl command to implement features such as systemctl reboot --boot-loader-entry=… (to reboot to a specific boot menu item, eg “reboot to Windows”) and systemctl reboot --boot-loader-menu=… (to reboot in the bootloader menu) by implementing the bootloader interface.
  • The EFI variable, set by the bootloader, tells the OS about the ESP used at boot time. It is then used to automatically mount the correct ESP partition in /efi/ or /boot/ while the OS is running.
  • The Boot Manager provides information about the boot time taken by the UEFI firmware using the Boot Loader Interface. This information can be displayed using systemd-analyze
  • Boot Manager implements load counting and automatic rollback to older workload records in case of failure.
  • The boot manager additionally reads a random seed from the ESP, concatenates it with the “system token” stored in the constant EFI variable, and extracts a random seed for the OS to use as an initialization of the entropy pool, providing a full pool of entropy during early boot.

How to update the bootloader in /boot

The bootctl program can check EFI firmware and bootloader status, list and manage available bootloaders and bootloader entries, and install, update, or remove systemd-boot on the current system.

To check if your system uses systemd-boot, run the command:

bootctl is-installed

To check the current version of the bootloader and see other information about it, run the following command:

bootctl

You will see something like the following:

Pay attention to the Product line - it contains the version, in the screenshot it is 249.5-3.

Also look at the Features list - if you installed your system a long time ago, then some features may be disabled - an update will fix this.

For example, the Features list in the screenshot:

               ✓ Boot counting
               ✓ Menu timeout control
               ✓ One-shot menu timeout control
               ✓ Default entry control
               ✓ One-shot entry control
               ✓ Support for XBOOTLDR partition
               ✓ Support for passing random seed to OS
               ✗ Load drop-in drivers
               ✓ Boot loader sets ESP information

Most of the list is marked with green checkmarks (), but one item (in your case, these may be other items) is marked with a red cross (). This means that systemd supports all of the listed functions, including those marked with a cross, but the currently installed bootloader does not support what is marked with a cross. In order for the bootloader to start supporting the entire list, it needs to be updated.

Using the command

pacman -Ss systemd

you can see the current version of the systemd package. In the screenshot, it is 250-1. That is, you can upgrade to a newer version.

To check the current version of systemd, you may prefer the following command:

pacman -Si systemd

Updating the systemd-boot loader in /boot is performed with the following command:

sudo bootctl update

You need to restart your computer for the changes to take effect.

How to check if your computer supports TPM 2.0 on Linux

One of the requirements for Windows 11 is the TPM 2.0 chip. I think it was thanks to Windows 11 that many users learned about the existence of the TPM.

This article will tell you how to find out in Linux if there is a TPM and what version is it.

TPM: Trusted Platform Module 2.0 – this chip is common on motherboards released after 2016.

TPM hardware provides a tamper-proof method for storing encryption keys on a computer. On Windows 11, 10, 8, and 7, TPM is usually required to enable and use encryption features such as BitLocker.

How to find out if there is TPM on a Linux computer

Relatively fresh (released after 2016) laptops and motherboards should already have a TPM chip soldered. To verify this for sure using sysfs, run the command:

[[ -d $(ls -d /sys/kernel/security/tpm* 2>/dev/null | head -1) ]] && echo "TPM available" || echo "TPM missing"

Starting with kernel 5.6, the version number can be viewed in the sysfs file:

cat /sys/class/tpm/tpm*/tpm_version_major

As you can see in the screenshot, the test machine has a second version of TPM (this laptop was released in 2018).

All TPM devices must have /dev/tpm0, so another way is to check /dev/tpm0 or /dev/tpmrm0.

/dev/tpmrm0 is only available for TPM 2.0, but it was added in v4.12-rc1. If you have the second version, then the following command will display the corresponding message:

[ -c /dev/tpmrm0 ] && echo "TPM 2.0"

This command will print a message if you have version 1.2 or 2.0:

[ -c /dev/tpm0 ] && echo "TPM 1.2 or 2.0"

TPM can be disabled

If the previous commands show that you are missing a TPM, then this does not necessarily mean that the TPM is missing at all – it may just be disabled. Go to BIOS and look for settings with TPM in the name. If you find them, turn them on.

TPM setting is missing in BIOS, UEFI

Does it mean that if the TPM setting is missing in the BIOS, then the TPM is not installed? No, this is not so – the examples above, from which it follows that TPM 2.0 is installed in the test machine, were made on a laptop that does not mention TPM at all in the BIOS.

TPM software for Linux

On Linux, install the TrouSerS package to work with TPM. It comes with the tcsd utility.

How to check if kernel modules are loaded to work with TPM

To verify that the TPM kernel modules are loaded, run the following command:

lsmod | grep tpm

Why does my laptop beep during operation or when shutting down?

Why is the motherboard beeping?

When the laptop is turned off, the “beeper”, “speaker” is triggered. Why is this happening?

Problems at the hardware level are sometimes so serious that the computer cannot start – for example, the RAM is faulty or the contacts of the central processor are loose – in this case, it will not be possible to turn on the computer so that you can analyze the causes of its problem.

Therefore, a self-diagnosis mechanism is built into the motherboards, and to inform the user about the causes of the problem, beeps are emitted – their number and duration encodes the cause of the problem.

We do not come across beeps (squeaks) when turning on the computer very often, since such serious hardware problems are rare.

But even less often, we encounter sound signals from the motherboard while the computer is running or when it is being turned off. This article will tell you about the possible reasons why the computer beeps already during operation.

There can be several reasons why the computer beeps during operation, usually these are notifications about which the user should be aware.

Low battery alarm

In BIOS, this setting may be called:

  • Battery low alarm beep
  • Low battery alarm

If you do not like that the laptop starts beeping when the battery is low, then go to BIOS and disable this setting.

Beep when power off

If, when you disconnect the power adapter, your laptop starts to beep, then you can disable this setting in the BIOS. To do this, look for options there:

  • Power control beep
  • Power beep

The reason for the squeak of the motherboard, which appears at random moments, may be a problem of loss/intermittent power connection. Many laptops beep when you plug in or unplug the power adapter (Lenovo is well known for this). This could indicate a problem with the power adapter cord, the power adapter itself, or a connector inside the computer. You can visually inspect the connector built into the laptop for problems.

As a quick test, you can wiggle the cord near where it connects to your laptop and listen for beeps. You can also look at your screen and see if it goes from plugging in and charging to battery mode. This is the most common cause of random beeps.

Squeak when opening or closing laptop lid

In BIOS, this setting is called Panel close alarm. You can turn it off if you want.

Beep when waking up from sleep or hibernation

Some laptop models beep when the computer wakes up. Again, you can disable this setting in the BIOS.

If none of the above applies to your case, then go to BIOS/EFI and look for settings there with the word Beep, for example, “Beep and Alarm”. Signals may have been set to other events.

Beep due to computer overheating or other malfunction

Also check that the temperature of the computer is far from critical. In this case, most motherboards start to squeak.

Check your computer for hardware problems.

How to change the default operating system in Arch Linux (for UEFI and systemd-boot)

This instruction applies to all boot loaders that implement the Boot Loader Specification and/or Boot Loader Interface, such as systemd-boot.

If you have a modern computer (no older than seven years at the time of writing), then it most likely uses UEFI instead of BIOS and, therefore, uses systemd-boot to boot, which is usually mentioned in the Arch Linux installation instructions (although there may be grub).

The bootctl program can check EFI firmware and bootloader status, list and manage available bootloaders and bootloader entries, and install, update, or remove systemd-boot on the current system.

To check if your system uses systemd-boot, run the command:

bootctl is-installed

The following command will show all available loader entries that implement the Boot Loader Specification, as well as any other entries found or automatically generated by a loader that implements the Boot Loader Interface.

bootctl list

  • title is an entry name. Note that the entry with the string “(default)” is selected as the default loaded
  • id is an identifier, it is needed in the commands described below to change the OS loaded by default
  • source is a path in the OS
  • linux is the Linux kernel
  • initrd is initial RAM filesystem. The purpose of initramfs is to boot the system to the point where it can access the root filesystem.
  • options are boot options

The following command sets the default bootloader entry. It takes one string of the bootloader entry ID as an argument.

sudo bootctl set-default ID

The set-oneshot command will set the default entry for the next boot only, set-default will set it permanently for all future bootings.

sudo bootctl set-oneshot ID

Optionally, the bootloader entry ID can be one of: @default, @oneshot, or @current, which corresponds to the current default bootloader entry for all future downloads, the current default bootloader entry for the next boot, and the currently loaded bootloader entry. These special identifiers are converted to the current values of the EFI variables LoaderEntryDefault, LoaderEntryOneShot, and LoaderEntrySelected. These special identifiers are primarily useful as a quick way to permanently make the currently loaded bootloader entry the default choice, or update the default bootloader entry for the next boot to the default bootloader entry for all future bootings, but they can be used for others operations as well. If an empty string ("") is specified as the identifier, the corresponding EFI variable will not be set.

The boot manager integrates with the systemctl command, so the following commands can be used:

systemctl reboot --boot-loader-entry=ID

This command will reboot the computer to the specified bootloader entry.

By the way, to get a very compact list containing only bootloader entries, run the command:

systemctl reboot --boot-loader-entry=help

The following command will immediately reload you into the EFI boot menu. This menu will have a timeout for the specified number of SECONDS:

systemctl reboot --boot-loader-menu=SECONDS
Loading...
X