34

Is the "bootable flag" needed in today's distributions? If not, then why is it still in the installers? What is it exactly?

1

3 Answers 3

36

The boot flag is from ancient times, where you would indicate an MBR partition record as bootable, so you could indicate where the boot loader resided.

On modern OS'es this is widely unused, as the MBR consists of a minimal stage loader which bootstraps either into its own partition or jumps to another area on the disk where the boot loader code is kept. (An MBR can contain either executable code or the boot partition table among other things. See also this link to an article about the MBR).

As an example, GRUB is written into the MBR and boots whatever partition you choose.

See also this (quite small) Wikipedia page about the boot flag: en.wikipedia.org/wiki/Boot_flag

3
  • GRUB does not need to be written into the MBR though, and can be loaded by the legacy MBR. Oct 30, 2011 at 4:07
  • @IgnacioVazquez-Abrams Correct, all it needs is a boot sector loader of whatever partition. I didn't want to immerse into GRUB functionality too much, as this question was about boot flags and MBR, and not about GRUB per se.
    – polemon
    Oct 30, 2011 at 5:02
  • It is still needed by windows 7 (and probably more modern versions too) to boot, so "widely unused" is somewhat misleading. Though in unix/linux world this is probably true.
    – ars
    Mar 16 at 21:29
4

At first I thought it's a bug in grub2. Some BIOS seem to test if at least one partition is marked as bootable. After a long research I noticed that, because there was no way to boot from hdd or usb-stick at all. That means even if magic bytes at the end of mbr are correct and boot-code in mbr is valid, BIOS will ignore that device and skip it in boot-sequence until bootable flag for at least one partition was set. Tested on Fujitsu P772 and HP Probook 6570b.

2

Every operating system that uses some kind of PC-derived hardware needs to be booted.

This starts with an ancient, OS-independent bootstrap-search which is initiated by the BIOS (basic input output system) of the PC or server.

That BIOS-piece of code tries to load the MBR from the first suitable boot-device. The search order for the boot-device is configurable in the BIOS-setup: which (disk) device first, which next and so on.

The "legacy" MBR tries to find the first primary partition that is marked as bootable and checks whether there is a short magic hex-code on that partition.

If the hex-code is found the rest (the bootstrap loader) is executed by the bios. Here begins the booting of the operating system - may it be DOS, Windows, Linux, ...

3
  • 1
    -1. It is not the BIOS that checks to see if a partition is bootable. Oct 30, 2011 at 4:06
  • The BIOS attempts to load the MBR (displaying No Operating System if the proper magic number isn't found), and then the MBR takes it from there. The legacy MBR looks for the active primary partition, but other MBRs (grub, lilo, etc.) may choose to act differently. Nov 6, 2011 at 22:06
  • Thanks, I have a question, I understand when it's UEFI based, the first hex code should be 'MZ' in linux. By 'short magic hex-code' do you mean this 'MZ' value (0x4d,0x5a) ?
    – Chan Kim
    Oct 13, 2021 at 2:57

You must log in to answer this question.

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