Does a fresh MBR contain generic code?

OK, I can imagine another scenario In which the bios “calls” something in an MBR. I will read the info.
I did say that I could be totally wrong.

Dang, Meek again

The BIOS will read only the MBR … and then what ?!
My post was about “generic boot code”, not about bootmanager and not about other bootable devices that the BIOS will check in the order defined in the BIOS setup.

So the BIOS will not only read the MBR, it will look for byte 0X80 (the active flag) in the offset of each of the 16 bytes entries describing each primary partition. Once it finds that active flag, it will passe the execution to the code contained in the boot sector of the active partition. If that partition is not bootable for whatever reason, it will check other boot devices.

All this can be performed in the total absence of Grub or any other bootmanager. Of course a bootmanager is convenient, and nobody wants to edit the MBR and set the active flag with an Hex editor in a multiboot situation.

Grub (as well as LiLO) is both a bootmanager and a bootloader for Linux kernels. You pretty much need one or the other. In the ‘good old time’ though, we used to boot Linux from DOS with a DOS program called ‘loadlin’. I don’t think people does that anymore. But it’s a way of booting Linux without Grub (or with a broken Grub or LiLO). It might not be the simplest way since it requires a running DOS.

it will look for byte 0X80 (the active flag) in the offset of each of the 16 bytes entries describing each primary partition. Once it finds that active flag, it will passe the execution to the code contained in the boot sector of the active partition

That is the job of the MBR boot code not the bios.

The basic job of the generic boot code in the MBR:
1)check for the last 2 bytes of sector for correct signature of 55AA.
2)check for 1 and only 1 active partition.
If a test fails ,a error will be sent to the bios and MBR boot code will terminate.
If both tests pass the MBR code will read into memory the first sector of active partition (volume boot record) and turn control over to it.

If the bios receives an error code from the MBR boot code or there is not boot code, it will determine if it should search for a different boot device or give up with an error to the display.

Some bios’s ( not most)do seem to have a small routine that will pre check for a active partition and may do a basic test of the master partition table and if passes will then read into memory the MBR and turn control over to it. No bios will jump over the MBR boot code and directly boot a partition. Note: I’m not talking about some specially programed bios computer system.

You’re right. That’s a very clear explanation of what the generic bootcode in MBR exactly does. I should have written “in absence of a bootmanager” rather than in “absence of a bootloader”. That’s actually what I meant: ‘generic boot code in MBR’ as opposed to Grub or anything else.

You can call it generic if you want.

In the early days of the PC back in the 80s IBM and Microsoft talked about how to boot different operating systems from hard disk.

They came with the solution that you can create partitions and set an activ flag as a kind of “what to boot next time” switch.

Therefor they designed the MBR and in each partition the BR that should contain the bootloader of the specific operating system.

The switch was intended to be done by fdisk. fdisk was required to rewrite the MBR with ‘generic code’ each time and to switch the active flag.

(At least Microsoft never was the bad guy by rewriting the MBR, Lilo or Grub never should be written into it … :wink:

If you want, have a look at OS/2. That’s why the OS/2 bootmanager requires an own, active partition. It was even able to “hide” different partition. As it was not the bootloader of OS/2 itself it was not alowed in the BR or in the MBR. (The OS/2 bootmanager was really cool.)

LostFarmer wrote:

> 2)check for 1 and only 1 active partition.

Of course, I had to be the one who found the exception here :wink:

On my Toshiba laptop, I had OS/2 Boot Manager installed as the active
primary. When I installed 11.2, the ACTIVE flag for that partition was
killed in the MBR (MSB of the type code in the partition table). As a
result, the BIOS defaults to the Grub loader on the 3rd defined partition
table entry. Don’t ask me how or why, but this was a bullet dodged so I
can’t complain.

There are some strange possibilities but this is the first time I’ve seen
any exceptions to the sequence you give.

Will Honea

Yep but the OS/2 bootmanager partition often confused Windows NT (or was it Windows 2000?) which (deliberately) destroyed it. By that time there was a very cool bootmanager called “xfdisk”. It was too big to be contained in MBR and had to use 2 extra sectors. It was able to boot OS/2 if installed in a logical partition and didn’t even require its own partition. It could also chainload everything, like BeOS and QNX from (DOS) logical drives, BSD and Solaris on primaries, of course Linux (on primaries or logicals), basically eveything (except Netware which needed to be started from a DOS partition).

You could have unchecked “set active flag to boot partition” in openSUSE Setup, somewhere in the Grub advanced options. Unfortunately this is enabled by default.

The openSUSE 11.2 new strategy is to not install Grub in MBR but activate the Linux partition by default. I guess they didn’t even consider the possibility that you could install Linux entirely in logical drives … or somebody has to explain to me how it does make sense to set the active flag on a logical partition. It’s probably different on GPT based systems… but I don’t know enough about those.

This is going back and forth.
How do “we” find the real answer?


Had to read the first question.

To put it another way; does the process of creating a partition table using Linux tools put generic code in the MBR?
NO, creating partitions will not write any boot code. I think a generic boot code can be selected in the grub install menu during Suse install, not sure as I only have a old SuSe cd.

If I low level formatted a drive
would have to know just what you call low level format and with what program. If it zeroed out the MBR then some program would need to be ran to write the boot code. “see above” With out a boot code the hdd will not be a boot-able device.

that should answer the question!!! Just give advice and not test people. Is there some kind of “linux bar exam”