2

My understanding of the traditional BIOS booting process is the following:

  • Firmware (i.e. the BIOS) chooses a device to boot from and executes the boot code stored in the boot sector (MBR) of that device
  • The MBR code usually chooses a partition to boot from and executes the code stored in that partition's boot block (VBR)
  • The VBR code then starts the operating system

I believe the MBR code is the first-stage bootloader and the VBR code is the second-stage bootloader.

However, the Wikipedia article to "Bootloader" lists BIOS as an example of a first-stage boot loader. This contradicts my understanding that the BIOS is stored on the motherboard by the manufacturer and not on the MBR of a disk that I want to boot from.

Is the BIOS actually a first-stage boot loader? And if so, to which stage do the MBR and VBR code belong?

3
  • 1
    You forgot about the EFI NVRAM entry which points to a partition.
    – Ramhound
    Commented Jun 21, 2022 at 18:28
  • @Ramhound I think EFI NVRAM only applies to UEFI boot, not legacy BIOS boot, which is what I'm referring to
    – rewire
    Commented Jun 21, 2022 at 19:45
  • By "BIOS" you are presumably referring to x86 PC systems (and not CP/M). The number of boot stages can vary depending on the boot medium. For a floppy (which is not partitioned), the BIOS is 1st-stage, the MBR contains the 2nd-stage, which loads a 3rd-stage OS loader. For HDD (which is partitioned), the MBR contains the 2nd-stage which loads the 3rd-stage loader in the partition's boot record. It's this 3rd-stage that loads the 4th-stage OS loader.
    – sawdust
    Commented Jun 21, 2022 at 23:42

3 Answers 3

2

Keep in mind - I don't think there's a real standard for "Bootloader stages" so a system designer (or anyone) can call any step their platform takes to initialize anything they want without consequences.

Firmware (i.e. the BIOS) chooses a device to boot from and executes the boot code stored in the boot sector (MBR) of that device

This is the way traditional BIOS boots anything - traditional BIOS has no knowledge of file systems, so it can't load a file directly. So BIOS will ask the device for LBA 0, put it in RAM at 7C00:0000, and point the CPU there.

That is stage 1 - it's primitive, but it's a step nonetheless - so that's stage 1 (1BL).

LBAs are 512 bytes, and the last 64 bytes of LBA 0 are the partition table and boot signature, and that's not enough code to do very much, so usually there code that loads a bootloader with more capability. That would be your 2BL.

Of course, maybe you can fit enough code in 512 - 64 bytes to load your OS. I believe DOS was able to load the first part of itself through this method (DOS was in a couple files on a disk - IO.SYS and MSDOS.SYS - and I believe the 1BL will get IO.SYS into memory which then loads MSDOS.SYS, but IO.SYS is used by MSDOS.SYS for more than just 2BL.)

The MBR code usually chooses a partition to boot from and executes the code stored in that partition's boot block (VBR)

So a VBR is just MBR code that's not at LBA 0 of the disk, but the first LBA of a partition. I don't see the utility of splitting that into 2BL and 3BL, but someone could consider those separate steps if they really wanted to.

Any talk about more than 1BL/2BL that I've seen is usually to do with decrypting the next stage and verifying that it hasn't been tampered with, on platforms such as Microsoft's original XBox or other game consoles.

Windows Bitlocker could be said to add additional steps - but technically the Windows kernel is already running during that process - that's how you see the Bitlocker screens in the case your recovery key needs to be entered.

1
  • 1
    Usually there is a split between 2nd and 3rd stages, as most filesystems also reserve a very limited amount of space to the VBR – so the Windows VBR will load the rest of the code from the \BOOTMGR or \NTLDR file; the Syslinux VBR jumps to ldlinux.sys... (GRUB2 is one big exception to this overall design as its 2BL goes into a separate area rather than using any partition's VBR, so it's large enough to contain the entire GRUB core.) Commented Jun 22, 2022 at 4:36
2

The MBR simply provides a means for an already executing system (via BIOS) to continue executing.

The very first stages of computer booting executes code from ROM, i.e. the code stored in the BIOS.

The BIOS (on old computers) was typically mapped into physical memory at the first addresses accessed by the CPU as it boots. The CPU saw an instruction at the first address and executed it. That instruction leads to another instruction and so on. The result is a program that configures the CPU, initialises peripherals and is the very first "program" that a CPU runs.

That program understands some particular conventions for how it should continue to boot the system. It looks for a hard disk. The first block of that hard disk should be a Master Boot Record that tells the BIOS program how to find or look for the next boot stage the VBR is simply a different type of boot record that is stored at the start of a partition instead of the hard disk.

0

Your Wikipedia article defines a bootloader this way :

A bootloader, also spelled as boot loader or called boot manager and bootstrap loader, is a computer program that is responsible for booting a computer.

The BIOS is certainly a computer program, even if a simple one (EFI is no longer that simple), so that it also qualifies as a bootloader.

The definition does not specify that the bootloader needs to reside on the disk, so it can surely also reside on NVRAM (Non-Volatile RAM).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .