Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?"

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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.

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.

share|improve this answer
    
Thanks for the very detailed answer. So the criteria for a valid bootable device is the presence of a bootable partition in the partition table and some "other additional checks"? I'm just a bit confused because in the original question on AskUbuntu the author shows that all of the partitions on the drive are not bootable and still he sees the error caused by broken GRUB - which shouldn't have been invoked by BIOS at all because the drive does not meet "bootable" criteria, so BIOS should've just skipped the drive and go to the next one –  Sergey May 5 '12 at 9:43
    
@Sergey I looked at that question, and am unsure. It's possible that the MBR is corrupted, or the bootable flag is set to an invalid value (not sure how fdisk will handle those cases, although the original version did flag invalid MBR headers). I advised the OP to post the raw MBR header, but he/she may also want to "toggle" on/off the bootable flag (to set/reset the flag manually). –  Breakthrough May 5 '12 at 16:40
    
Keep in mind that BIOS code is not generic. It is rather specific to each mainboard, so it knows what kind of drives there might be attached to what ports. –  LatinSuD Jun 4 at 11:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.