skip to content

What is the practical difference between booting an x86-64 machine in legacy BIOS mode and booting it via UEFI, and what does the firmware load in each case?

level: middleimportance: should knowfreq 50%

answer

  1. raw sector code versus a real file
  2. the firmware's filesystem knowledge differs
  3. NVRAM entries versus 440 bytes
  4. a FAT partition holding .efi binaries
  5. install mode and boot mode must match

basics

~20 s

Legacy BIOS jumps into 440 bytes of boot code in the disk's first sector, which must chain to a larger bootloader stage. UEFI firmware understands partitions and FAT, reads boot entries from NVRAM, and loads a .efi application from the EFI System Partition.

solid answer

~50 s

BIOS knows nothing about partitions or filesystems: it reads the first 512-byte sector of the disk and executes the 440 bytes of boot code in it, which is only enough to chain to a later bootloader stage stored in a gap on disk or in a dedicated BIOS boot partition. UEFI firmware is far more capable — it contains a FAT driver and a boot manager, keeps ordered boot entries in NVRAM (which `efibootmgr` edits), and loads a real `.efi` executable from the EFI System Partition, conventionally mounted at `/boot/efi`. That makes multiple installed operating systems addressable without one overwriting another's boot code, allows Secure Boot verification of what is loaded, and lifts the MBR's four-primary-partition and 2 TiB limits by pairing with GPT. The consequence people hit in practice: a system installed in one mode will not boot with the firmware set to the other, because the artefact the firmware looks for simply is not there.

code

bash · 8 lines
bash
# which mode did this machine actually boot in?
if [ -d /sys/firmware/efi ]; then
  echo "UEFI boot"
  sudo efibootmgr -v      # NVRAM entries and their order
  findmnt /boot/efi       # the EFI System Partition, FAT-formatted
else
  echo "legacy BIOS boot"
fi

go deeper

for a junior

Know that BIOS runs boot code from the disk's first sector while UEFI loads a .efi file from a small FAT partition, and that the two modes are not interchangeable.

for a middle

Explain why 440 bytes forces GRUB2 to split itself, what NVRAM boot entries are, and how GPT lifts the four-partition and 2 TiB limits that MBR imposes.

for a senior

Diagnose a mode mismatch and repair a broken boot: identify the mode from a rescue shell, mount the ESP, reinstall the bootloader into the right place and recreate the firmware entry.

for a principal

Set the fleet standard: one boot mode across the estate, whether Secure Boot is in scope, and how imaging and disaster recovery stay consistent when hardware generations differ.

## Two entirely different contracts BIOS and UEFI are not two versions of the same thing; they are different agreements about *what the firmware will look for on a disk*. ## Legacy BIOS After power-on self-test, BIOS firmware picks a disk from its configured boot order, reads sector zero — the **Master Boot Record** — into memory, and jumps to the start of it. That sector is 512 bytes: 440 bytes of boot code, a disk signature, the four-entry partition table, and a signature. The firmware does not parse the partition table and has no filesystem drivers; it just executes code. 440 bytes is nowhere near enough to read ext4 or XFS, so GRUB2 splits itself. The MBR code loads `core.img`, which lives either in the unused gap between the MBR and the first partition (on MBR-partitioned disks) or, on GPT disks booted via BIOS, in a small dedicated **BIOS boot partition**. `core.img` contains the filesystem driver needed to reach `/boot/grub/` and continue. The whole arrangement is fragile: the bootstrap code lives outside any filesystem, so nothing protects it, and two operating systems installed on one disk simply overwrite each other's 440 bytes. ## UEFI UEFI firmware is a small operating system in its own right. It understands GPT partitioning and can read FAT, so instead of raw sector code the contract is: put a **normal file** on a **normal filesystem**. That filesystem is the **EFI System Partition** (ESP) — a FAT-formatted partition, on Linux conventionally mounted at `/boot/efi` — and it holds vendor directories such as `/boot/efi/EFI/<distro>/` containing `.efi` applications. Which one gets loaded is decided by boot entries stored in the firmware's own NVRAM, each pointing at a device and a file path, ordered by a boot order variable. On Linux `efibootmgr` reads and manipulates them: ```bash [ -d /sys/firmware/efi ] && echo "booted via UEFI" || echo "booted via legacy BIOS" sudo efibootmgr -v ``` Because each OS gets its own entry and its own directory, installing a second distribution does not clobber the first. There is also a fixed **removable-media fallback path** — `\EFI\BOOT\BOOTX64.EFI` on the ESP — used when no NVRAM entry matches, which is how installation media boots on a machine that has never seen it. UEFI can also load a kernel directly when the kernel is built with an EFI stub, skipping GRUB2 entirely; the kernel image is then itself a valid `.efi` application. ## What actually changes for you **Partitioning.** MBR's partition table has four primary entries and 32-bit sector addresses, capping usable disks at 2 TiB. GPT, which UEFI expects, has neither limit. You *can* boot GPT under BIOS, but only via the BIOS boot partition hack above. **Verification.** Secure Boot exists only under UEFI: the firmware checks the signature of the `.efi` it is about to load against keys it holds. There is no equivalent for MBR boot code, which is precisely why bootkits targeted it. **Recoverability.** A UEFI boot problem is usually a file or an NVRAM entry — both inspectable and fixable from a rescue shell. A BIOS boot problem may be damaged code in a sector with no filesystem around it. **Mode mismatch.** This is the failure people actually meet. Installing while the firmware is in UEFI mode writes an ESP and an NVRAM entry, and nothing useful into the MBR; switching the firmware to legacy afterwards produces "no bootable device". The reverse holds too. Some firmware exposes a Compatibility Support Module that emulates BIOS, and mixing the two during installation and later boots is a common self-inflicted outage. The check is one line: `/sys/firmware/efi` exists only on a UEFI boot. ## What stays identical Everything after the handoff. Once GRUB2 (or the EFI stub) has control, the kernel, the initramfs, the root pivot and PID 1 behave exactly the same. The firmware distinction is entirely about the first few hundred milliseconds and where the boot artefacts live.

  • How can you tell, from a running Linux system, which mode it booted in?
    Check whether `/sys/firmware/efi` exists — the kernel only creates that directory when it was started by UEFI firmware. On a UEFI system `efibootmgr -v` will also list the NVRAM boot entries and their order; on a legacy boot it fails because there are no EFI variables to read. Both are one-liners worth knowing before you plan any bootloader repair.
  • Why does the EFI System Partition have to be FAT?
    Because FAT is the one filesystem the UEFI specification requires every firmware implementation to understand. The whole point of the ESP is that firmware — not Linux — reads it before any OS is running, so the format has to be one the firmware can parse. That is also why it is small, contains only boot artefacts, and is mounted at `/boot/efi` rather than being used as general storage.
  • What is the removable-media fallback path, and when does the firmware use it?
    It is the fixed location `\EFI\BOOT\BOOTX64.EFI` on the EFI System Partition of an x86-64 device. Firmware falls back to it when no NVRAM boot entry matches a device it is trying to boot — most obviously for installation media and USB sticks, which cannot have pre-registered entries on a machine they have never been plugged into.

saying these in an interview costs you the question

  • Thinks UEFI is just a modern BIOS user interface
  • Says the BIOS reads the partition table to find the OS
  • Believes GPT requires UEFI in all cases
  • Assumes an OS installed under UEFI boots in legacy mode
  • Confuses the EFI System Partition with /boot

context