What firmware does at power-on

Video 064 of 140 in Virtualization Foundations, in the unit “The boot sequence, end to end”. 3:32, with English and Hindi audio.

Before any operating system runs, a small program called firmware is already running. It is stored on a chip on the motherboard, and its code stays there when the power is off. Its job is to prepare the hardware, find a disk that can boot, and pass control to a boot loader. This article explains those steps in order, the two kinds of firmware you will meet, and how to check which kind a Linux machine uses.

What you will learn

Why firmware has to run first

The operating system lives on a disk. When the power comes on, memory is empty, and nothing in memory is ready to load the operating system from that disk. Something must run first, and that something is firmware.

Firmware is kept on a chip on the motherboard, so its code is there even when the power is off. Its job has a few clear parts, which are listed below.

What firmware does, in order

Suppose the first disk in the boot order holds no program that can start. Firmware then moves on to the next disk. When it finds a boot loader there, it starts it. From that point on, the boot loader is in charge.

Legacy BIOS and UEFI

Older PCs use legacy BIOS. It reads the first sector of the disk, the master boot record, and runs the code it finds there.

Modern machines use UEFI. It reads a file from a small FAT partition, which is a simple format for storing files. UEFI can also handle much bigger disks, and it can use Secure Boot, which can check a program before it runs.

The main difference is where each kind looks for the boot program. BIOS looks in one sector of the disk, while UEFI looks for a program file on its own partition.

Checking which firmware a Linux machine uses

You can check the firmware type from the shell. The first test looks for a folder that exists only on UEFI machines. The second command lists the UEFI boot entries. Each entry names a program and says where it lives on the disk.

Note: Run these commands only to read. Do not change the boot order unless you know which entry you are changing.

Try it yourself

You need a shell on a Linux machine. The first command prints the firmware type. The second lists the UEFI boot entries.

  1. Check the firmware type. The test looks for a folder that exists only on UEFI machines.

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

    What you should see: It prints UEFI when the machine booted with UEFI, and BIOS otherwise.

  2. List the UEFI boot entries. Each entry names a program and where it lives on the disk.

    sudo efibootmgr

    What you should see: The list of UEFI boot entries, each with a program name and its place on the disk.

Terms

Firmware
A small program stored on a chip on the motherboard. It runs first, when the machine powers on.
POST
The power-on self-test, a check of the memory, processor and devices when the machine starts.
Boot order
The list in the firmware settings that says which device the firmware tries first.
BIOS
The older kind of firmware, which reads the first sector of the disk, the master boot record.
UEFI
The newer kind of firmware, which reads a program file from a small partition in the simple FAT format.

Check yourself

Why must firmware run before the operating system?

The operating system lives on a disk, and memory is empty, with no program ready to load it.

What does legacy BIOS read to find a boot program?

The first sector of the disk, the master boot record. It runs the code it finds there.

What does firmware do after it starts the boot loader?

It steps aside, and the boot loader is in charge from then on.

Previous: From power-on to login. Next: What the boot loader does.