Skip to content

Linux Foundations / Understand the system underneath ยท Step 27 of 38

Lesson: Boot Process: BIOSSwitch
โ† Linux Foundations

System administration

Boot Process: BIOS

Learn what BIOS and UEFI firmware do before Linux starts, and how to tell which one you have.

The first code that runs on a PC is firmware stored on the motherboard. Older machines use the BIOS. Newer ones use UEFI, although people often still call its setup screen "the BIOS".

Power-on self-test

The firmware first runs a power-on self-test, called POST. It checks that essential parts such as memory and the processor respond, and initialises basic devices. If something vital is broken, you may hear beep codes or see an error before any disk is touched. The meaning of the beeps depends on the manufacturer.

How BIOS finds a bootloader

BIOS has a boot order, for example USB first and then the internal disk. On the chosen disk it reads the very first sector, the Master Boot Record (MBR). The sector is traditionally 512 bytes and holds:

  • a very small piece of boot code
  • the partition table
  • a two-byte signature that marks it as bootable

There is not enough room there for a whole bootloader, so that first code loads a larger second part from elsewhere on the disk.

How UEFI differs

UEFI can read filesystems. It looks on a special partition called the EFI System Partition (ESP), which uses a FAT filesystem, and runs a boot program stored there as a file ending in .efi. On Linux the ESP is often mounted at /boot/efi, but this varies.

UEFI keeps a list of boot entries in the motherboard's non-volatile memory. It is usually paired with GPT partitioned disks. It can also offer Secure Boot, which only runs boot programs it trusts, usually ones signed with an approved key.

Which one do you have?

On a running Linux system, test for this directory:

$ [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
UEFI

A UEFI machine that boots in legacy compatibility mode will report BIOS, because the test shows how this boot happened.

On UEFI systems, efibootmgr lists the boot entries. It may need to be installed first.

$ efibootmgr
BootCurrent: 0001
BootOrder: 0001,0000
Boot0000* UEFI: USB Drive
Boot0001* ubuntu

BootCurrent is the entry used this time. BootOrder is the order the firmware will try next time. The exact output varies with version and hardware. Be careful with options that change entries, since a wrong change can leave the machine unable to boot.

Changing settings

To enter firmware setup, press the setup key just after power on. Which key it is depends on the maker, and it is often shown on screen or in the manual. There you can change the boot order, for instance to start an installer from USB.

Try it

Run the directory test on your machine. If it prints UEFI, run efibootmgr and find which entry matches BootCurrent. Then run lsblk -f and look for a vfat partition that could be your ESP.

Check your understanding

Boot Process: BIOS

All 4 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.