MBR: How does BIOS decide if a drive is bootable or not?

While trying to answer this question on askubuntu: How do I Uninstall GRUB I read the Wikipedia article on MBR and also the perfect answer on a somewhat related question here on Superuser, however, one thing is still not clear to me:

What exactly makes BIOS decide if a drive is bootable or not? How does the boot sequence skip from drive #1 and proceed trying to boot from drive #2 if more than one drive is installed in the system?

My understanding is that the only thing BIOS normally checks on an MBR is its signature at the very end of the 512-byte sector, and then it just transfers control to the initial bootloader situated in the first 446 bytes of the boot sector.

Does it imply that the first 446 bytes of the boot sector MUST contain some meaningful bootloader code even if the disk is not bootable?

After BIOS transferred control to the bootloader on drive #1 which happened to have no "bootable" partitions - how exactly is the bootloader on the second drive invoked?

Sorry if this is too technical :) Short question is: "How exactly does BIOS skip a drive and proceed to try to boot from the next one?"


What exactly makes BIOS decide if a drive is bootable or not?

The BIOS decides if a drive is bootable based on the 16-byte partition record, present after the MBR code area (held in a table starting at the 446th byte). The first byte in each partition record represents the drive's bootable status (and is set to 0x80 if bootable, or 0x00 if not). Some BIOSes may check other parts of the MBR (e.g. partition types, checksums), but the basic requirement is the bootable flag.

How does the boot sequence skip from drive #1 and proceed trying to boot from drive #2 if more than one drive is installed in the system?

This is implementation dependent, and is why you need to properly select a boot order. In most cases, the BIOS will look through each storage medium in the order you set, and determine whether it can boot from that device (via the MBR data). If it can, it does - if not, it continues looping through the other devices (again, in the order you selected).

After BIOS transferred control to the bootloader on drive #1 which happened to have no "bootable" partitions - how exactly is the bootloader on the second drive invoked?

Once a valid boot device is found (i.e. the bootable flag is set, and other additional checks pass), the BIOS copies the MBR sector into RAM. The BIOS then relocates the instruction pointer to the beginning of this location (using a JUMP instruction), where the MBR code segment is located, and the computer then starts.

If the BIOS supports the BIOS Boot Specification, MBR code can return control to BIOS with a certain instruction, signaling it of boot failure and prompting it to try the next device. Older BIOSes just print an error message though. A good tell if you BIOS supports it is whether you can boot from USB.

My understanding is that the only thing BIOS normally checks on an MBR is its signature at the very end of the 512-byte sector, and then it just transfers control to the initial bootloader situated in the first 446 bytes of the boot sector.

This is correct, although it should be noted that most modern BIOSes will also look for a GUID Partition Table as well as the older, conventional MBR-style table.

Does it imply that the first 446 bytes of the boot sector MUST contain some meaningful bootloader code even if the disk is not bootable?

No, but the drive must have a valid MBR or GUID partition table - otherwise, it won't be detected by the computer. While the code part of the MBR can indeed be empty, the first sector of the drive must have a well-formed MBR/GPT.