Boot Signature – BIOS


I understand that the BIOS is in ROM, and the manufacturer "typically" designs it to point to the first sector of the "active" storage device's first sector or CHS (0,0,1)*physical and CHS (0,0,0)*logical which is either an MBR or VBR based on your preference of partitioning.


The presence of an IBM PC compatible boot loader for x86-CPUs in the boot sector is by convention indicated by a two-byte hexadecimal sequence 0x55 0xAA (called the boot sector signature) at the end of the boot sector (offsets 0x1FE and 0x1FF). This signature indicates the presence of at least a dummy boot loader which is safe to be executed, even if it may not be able to actually load an operating system.

The boot signature identifies the boot loader using a two-byte hexadecimal sequence, so I'm guessing the signature has to be an offset in the same sector? Therefore then assuming the boot loader must be in this same sector?

Best Answer

The basic order of operations that happens while a BIOS is trying to find something to boot is:

  1. Load first sector (512 bytes) of the device you're trying to boot from (HDD, SSD, Floppy Disk, Optical Disc, etc) into memory
  2. Check if the 511th and 512th bytes are 0x55 and 0xAA, respectively.
    • If not, go back to step 1 and try the next device, or give up if there aren't any more.
    • If yes, start executing code at the beginning of this sector, thus passing control to (hopefully) a boot loader/manager.

You might find the OSDev wiki page on the Boot Sequence useful. The MBR page also has a useful table explaining the layout of that first sector. I've recreated it here with some simplification:

Offset | Size (bytes) | Description
    0  | 436          | MBR Bootstrap (flat binary executable code) 
0x1b4  |  10          | Optional "unique" disk ID
0x1be  |  64          | MBR Partition Table, with 4 entries
0x1fe  |   2          | (0x55, 0xAA) "Valid bootsector" signature bytes

Note that the BIOS doesn't necessarily pay any attention to or even know about the disk ID or the partition table.

enter image description here