Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

When many hard disks exist how does BIOS choose which one to boot

45 views
Skip to first unread message

James Harris

unread,
Mar 3, 2012, 3:28:11 AM3/3/12
to
When a machine has multiple hard disks which could be booted is there
a standard way that a BIOS will chose which one to start the OS from?

Will it do things like keeping a note of which one it booted last time
and use that?

Is there anything that an OS writer can do to influence the choice?

James

Rod Pemberton

unread,
Mar 3, 2012, 10:38:37 AM3/3/12
to
"James Harris" <james.h...@googlemail.com> wrote in message
news:b7cf9e4d-59b4-4194...@t15g2000yqi.googlegroups.com...
Didn't you ask this before? ... I'll hold off to let someone else reply.
No, still not an F ...



Are you having a certain problem that you're attempting to solve?

E.g., you're coding a boot loader which can select the boot device.

E.g., you want to lock out a device from booting or you want to
block BBS on a newer PC.



See, at the very bottom, you asked this previously ...
http://groups.google.com/group/alt.os.development/msg/112284f377fa29f2

In the mean time, you can enter "bios boot order" into Google Groups
advanced search. You can always limit it to alt.os.development posts, but
maybe the non-a.o.d. posts have some info:
http://groups.google.com/advanced_search?hl=en

E.g., you could limit it to alt.comp.bios (although it's very quiet),
where you'd find these:
http://groups.google.com/group/alt.comp.bios/msg/9010a5dd1f8dc90f
http://groups.google.com/group/alt.comp.bios/msg/abfb4166dd0bb3a9

Two alt.os.development threads which may be of use:

"an attempt in writing an OS" thread Dec 11,2009
"good or bad ides for use in bootloader?" Dec 16,2009

Use GG advanced search to find them ...


Rod Pemberton


Rod Pemberton

unread,
Mar 3, 2012, 10:40:34 AM3/3/12
to
"Rod Pemberton" <do_no...@noavailemail.cmm> wrote in message
news:jitdv7$238$1...@speranza.aioe.org...
> "James Harris" <james.h...@googlemail.com> wrote in message
> news:b7cf9e4d-59b4-4194...@t15g2000yqi.googlegroups.com...
> > When a machine has multiple hard disks which could be booted is there
> > a standard way that a BIOS will chose which one to start the OS from?
> >
> > Will it do things like keeping a note of which one it booted last time
> > and use that?
> >
> > Is there anything that an OS writer can do to influence the choice?
> >
>
> Didn't you ask this before? ... I'll hold off to let someone else reply.
> No, still not an F ...

Sorry, clarify: F was referring to my MBTI type, not letter grade or
swearword ..


Rod Pemberton


Marven Lee

unread,
Mar 3, 2012, 4:50:52 PM3/3/12
to
James Harris wrote:
> When a machine has multiple hard disks which could be booted is there
> a standard way that a BIOS will chose which one to start the OS from?

I assumed the BIOS would scan for all drive controllers that it supports
booting from, including add on cards that have drivers in ROM and
search for the first partition it finds that is marked as active in the
MBR. That's assuming that hoot from hard drive was chosen in the
BIOS setup.

I don't recall how the bootloader or OS gets the device number from
the BIOS, I just Googled and I'm guessing in register DL. I've no idea
how you convert from these device numbers to determining the boot
partition.

IIRC all I did in my kernel was to search for the the first partition
marked as active and assumed that was the boot partition. I'm not
sure what I did for the kernel booting off CD-ROM, I either modified
the kernel to assume first CD drive booted or added a command line
opttion in GRUB's menu.lst file which was then passed to the kernel
to indicate it was booting from a CD-ROM and left it to the kernel
to guess which one.

I feel like I'm a bit behind the times regarding all this BIOS, EFI
booting lark. Isn't there some new partition table standard for EFI
and isn't there some 32 character GUID/UUID for hard drive
partitions in this scheme?

I understand there is a 4-byte signature at offset 440 in the current
MBR and is used as a unique ID, it's a pity GRUB doesn't pass that
on to the kernel, it may have made it a bit easier to determine the
boot partition.


--
Marv


Rod Pemberton

unread,
Mar 3, 2012, 6:40:35 PM3/3/12
to
"Rod Pemberton" <do_no...@noavailemail.cmm> wrote in message
news:jitdv7$238$1...@speranza.aioe.org...
> "James Harris" <james.h...@googlemail.com> wrote in message
> news:b7cf9e4d-59b4-4194...@t15g2000yqi.googlegroups.com...
> > When a machine has multiple hard disks which could be booted is there
> > a standard way that a BIOS will chose which one to start the OS from?
> >
> > Will it do things like keeping a note of which one it booted last time
> > and use that?
> >
> > Is there anything that an OS writer can do to influence the choice?
> >
>
> Didn't you ask this before? ...
> [...]
> See, at the very bottom, you asked this previously ...
> http://groups.google.com/group/alt.os.development/msg/112284f377fa29f2
>

Hey, don't worry about it. Ben Lunt asks the same question repeatedly about
how the boot loader DL value maps to ports:
http://groups.google.com/group/alt.os.development/msg/65888d000eded327
http://groups.google.com/group/alt.os.development/msg/d447a12ebdb04a78


Rod Pemberton



Rod Pemberton

unread,
Mar 3, 2012, 6:41:27 PM3/3/12
to
"Marven Lee" <marv...@gmail.com> wrote in message
news:9rfi24...@mid.individual.net...
> [...]
> I don't recall how the bootloader or OS gets the device number from
> the BIOS, I just Googled and I'm guessing in register DL.

Supposedly, DL should have the drive: 0, 1, ... for floppy, 80, 81, ... for
hard disk.

Supposedly, ES:DI passes a pointer to a PnP structure for PnP BIOSes.

I've not used them, so said "supposedly".

Both of these describe DL and ES:DI:
(Thanks for these references goes to a post by Steve Dubrovich.)

Section 2.3 "Transferring Control to the Operating System" in "Plug and Play
BIOS Specification" PNPBIOSSpecification-v1.0a.pdf

Section 6.5.1 "" in "BIOS Boot Specification" specsbbs101.pdf

Also, "Appendix D" of the "BIOS Boot Specification" is interesting ...

> I understand there is a 4-byte signature at offset 440 in the current
> MBR and is used as a unique ID, it's a pity GRUB doesn't pass that
> on to the kernel, it may have made it a bit easier to determine the
> boot partition.

Uh, what disk signature in the MBR? Everything upto 446 is boot loader
code.


Hmm, Wikipedia mentions that field also ... What is going on?
http://en.wikipedia.org/wiki/Master_boot_record

Ok. Apparently, there was an editing error back in May 2006. Prior to
that, Wikipedia mentioned it that the fields below 446 are only for Windows
2000 or later.

So, I don't expect the Linux guys to code that into Grub ... :-)


Rod Pemberton





Rod Pemberton

unread,
Mar 3, 2012, 6:44:16 PM3/3/12
to

"Rod Pemberton" <do_no...@noavailemail.cmm> wrote in message
news:jiua8k$ch7$1...@speranza.aioe.org...
> "Marven Lee" <marv...@gmail.com> wrote in message
> news:9rfi24...@mid.individual.net...
> > [...]
> > I don't recall how the bootloader or OS gets the device number from
> > the BIOS, I just Googled and I'm guessing in register DL.
>
> Supposedly, DL should have the drive: 0, 1, ... for floppy, 80, 81, ...
for
> hard disk.
>
> Supposedly, ES:DI passes a pointer to a PnP structure for PnP BIOSes.
>
> I've not used them, so said "supposedly".
>
> Both of these describe DL and ES:DI:
> (Thanks for these references goes to a post by Steve Dubrovich.)
>
> Section 2.3 "Transferring Control to the Operating System" in "Plug and
Play
> BIOS Specification" PNPBIOSSpecification-v1.0a.pdf
>
> Section 6.5.1 "" in "BIOS Boot Specification" specsbbs101.pdf
>

Section 6.5.1 "Booting from BAIDs"

Benjamin David Lunt

unread,
Mar 3, 2012, 10:07:03 PM3/3/12
to
"James Harris" <james.h...@googlemail.com> wrote in message
news:b7cf9e4d-59b4-4194...@t15g2000yqi.googlegroups.com...
Hi guys,

Was reading through this thread and stopped to study a minute.
There has been a few people asking when I was going to start my
next book. Already started and this subject happens to be a part
of that book :-)

Anyway, I took James' question as "How can I manipulate the BIOS
to boot a different device (not partition) next time?"

In other words, this time the BIOS booted the first physical
PATA/SATA/etc. platter disk and I want it to boot the second
one next time.

Imagine what the "Trojan" and "Hacker" communities have
done with this exact question? :-) Boot another physical disk,
load a virtual system, then boot the "normal" disk letting the
Guest think it has full control. :-)

Anyway, Rod gave some good pointers, especially Appendix D in
the specs he mentioned.

My question, which includes the 4-byte signature at offset 440
in the MBR, is how to identify the booted partition?

For example, this machine I happen to be on has three physical
platter style disks, with 6 total partitions among them.
The first is a smaller roughly 30 Gig divided into three 10 Gig
partitions. The second is roughly 127 Gig divided into two
unequal partitions. The third is roughly 230 Gig with only
one partition.

I know that I have the first partition on the second physical
disk as the active partition which is booted (almost) every time.

Therefore, when the system is loaded, it knows to set the default
drive (partition) to this partition. (It being WinXP).

Now, how does one do this before the chicken? i.e.: after the
egg you can simply read from the registry and know which one
is the default partition. However, what about before the chicken?

For example, what if I have two WinXP partitions and I boot
one of them for one purpose and one of them for a different
purpose. They will both have a registry with an entry for
the default drive, which is not the same partition for both
entries.

So, even using a signature DWORD at offset 440 in the MBR,
how does your OS find this partition?

My conclusion is that if you have a signature in the MBR, which
will always be the first sector of the device, no matter the
count of partitions, your loader/kernel can read that signature
and store it for later when you start to decide the booted partition.

However, this has some draw backs:
1. What if the device has only one partition and that partition
starts at LBA 0. i.e.: there is no MBR. It is more common
than you think.
2. CDROM media does not have a MBR.
3. I am sure there are others.

I guess there are always drawbacks to every rule. However, most
of the time, this will work. And most of the time is good enough
for the girls I use to go with. :-)

Ben

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Forever Young Software
http://www.fysnet.net/index.htm
http://www.fysnet.net/The_Universal_Serial_Bus.htm
To reply by email, please remove the zzzzzz's

Batteries not included, some assembly required.


Bernhard Schornak

unread,
Mar 4, 2012, 2:23:15 AM3/4/12
to
Benjamin David Lunt wrote:


<snip>

> For example, what if I have two WinXP partitions and I boot
> one of them for one purpose and one of them for a different
> purpose. They will both have a registry with an entry for
> the default drive, which is not the same partition for both
> entries.
>
> So, even using a signature DWORD at offset 440 in the MBR,
> how does your OS find this partition?


No OS finds any partition on boot-up. There is only one MBR
record with set boot flag (on all bootable devices attached
to a PC!). The BIOS reads all MBRs on all devices and loads
sector 0 of the (only!) partition with set boot flag.

What happens next depends on the code stored in that loaded
sector. Either it is a boot manager or an OS. An OS sets up
the machine and starts to interact with the user, while the
boot manager either loads a default OS or shows a selection
of operating systems it can boot.

In the case of your two WinXP installations - there must be
a way how you select which one to start the next time, or a
boot manager pops up while booting. If you can select which
one should boot the next time, Windows resets the boot flag
of the current partition and sets it for the other. (Surely
more comfortable than to open the PC and pull some cables.)

Automated booting from CD or USB is a BIOS option. The BIOS
first checks if any removable device is bootable, before it
scans MBRs of the attached harddrives for a set boot flag.


Greetings from Augsburg

Bernhard Schornak

Nomen Nescio

unread,
Mar 4, 2012, 4:12:09 AM3/4/12
to
Bernhard Schornak <scho...@web.de> wrote:

> Benjamin David Lunt wrote:
>
> > For example, what if I have two WinXP partitions and I boot
> > one of them for one purpose and one of them for a different
> > purpose. They will both have a registry with an entry for
> > the default drive, which is not the same partition for both
> > entries.

By the time the OS sees anything is already after the BIOS reads MBR.\

> No OS finds any partition on boot-up. There is only one MBR
> record with set boot flag (on all bootable devices attached
> to a PC!).

No there is not. Nothing enforces this and I can set all or no partitions
bootable. Now you are back to the original question.

> The BIOS reads all MBRs on all devices and loads sector 0 of the (only!)
> partition with set boot flag.

No, it reads the MBRs on devices in order and boots the first bootable
partition it finds.

Benjamin David Lunt

unread,
Mar 4, 2012, 2:39:31 PM3/4/12
to
"Bernhard Schornak" <scho...@web.de> wrote in message
news:jiv58l$tg9$1...@dont-email.me...
> Benjamin David Lunt wrote:

Hi Bernhard,

I am sorry, but I have to disagree with you.

>> For example, what if I have two WinXP partitions and I boot
>> one of them for one purpose and one of them for a different
>> purpose. They will both have a registry with an entry for
>> the default drive, which is not the same partition for both
>> entries.
>>
>> So, even using a signature DWORD at offset 440 in the MBR,
>> how does your OS find this partition?
>
>
> No OS finds any partition on boot-up. There is only one MBR
> record with set boot flag (on all bootable devices attached
> to a PC!). The BIOS reads all MBRs on all devices and loads
> sector 0 of the (only!) partition with set boot flag.

The BIOS *does not* read all MBR's on all devices. It starts
with the first pointed to device, and will go until it finds
a device and partition that qualifies for the bootable device.
It will not continue to search once it finds that one. That
is like still searching for something you lost after you have
found it.

> What happens next depends on the code stored in that loaded
> sector. Either it is a boot manager or an OS. An OS sets up
> the machine and starts to interact with the user, while the
> boot manager either loads a default OS or shows a selection
> of operating systems it can boot.

Agreed. However, my question/comment was, how does the OS
know which partition on which device was booted.

> In the case of your two WinXP installations - there must be
> a way how you select which one to start the next time, or a
> boot manager pops up while booting. If you can select which
> one should boot the next time, Windows resets the boot flag
> of the current partition and sets it for the other. (Surely
> more comfortable than to open the PC and pull some cables.)

Not true at all. Windows never resets the boot flag of a current
partition unless you specifically ask it to. For the example
above, lets say that I only have two options to boot from,
two platter disk devices. The list that the BIOS allows me to
pick from only has these two options. Each device has a
partition table with one partition and it is marked active/
bootable. Again, *each* device has a partition marked bootable.

Now, when I select in the BIOS boot sequence which device
to boot, the first device for example, the BIOS will boot the
first device's active partition. Then later, let's say that
I pick the second option (second device) in the BIOS boot
options. The BIOS will start looking at the partitions
on that device, find an active partition and boot that partition.
Note that *both* devices still have an active partition marked.
Neither have, nor need one of them cleared. As far as the BIOS
is concerned, it never saw the second device's MBR nor any of
its partitions marked active.

I do not, nor does the BIOS, nor does Windows, mark any of the
partitions inactive. They are *both* still marked active.

> Automated booting from CD or USB is a BIOS option. The BIOS
> first checks if any removable device is bootable, before it
> scans MBRs of the attached harddrives for a set boot flag.

However, only if you have chosen this option.

s_dub...@yahoo.com

unread,
Mar 4, 2012, 8:25:19 PM3/4/12
to
On Mar 3, 2:28 am, James Harris <james.harri...@googlemail.com> wrote:
> When a machine has multiple hard disks which could be booted is there
> a standard way that a BIOS will chose which one to start the OS from?
>

It used to be a convention: boot fd_0 .if error. boot hd_0 .if eror.
complain!

It became a standard for a time when everyone else adopted that. You
need a historical record to define when that time period was tho,
perhaps Ben can address that in his next book! But I think it was
from about the PC/XT up until the EISA buss, on the eve of PnP Bios's
or perhaps the PS2.

Prior to that, there was no convention, but we are in the 8-bit days
of CP/M, and dealings with the hard drive controller, ST-506 spec.,
was done by the system implementor, the systems programmer spoke to
the HD thru command ports and data ports, and a prom was burnt with
the code to bootstrap that. - no MBR. If you added a HD to a system
without a prom with support for a HD boot, then the system had to be
booted from FD_0, but the system was a modified one which recognized
the HD. There was 'partitions' on the HD but that was because CP/M
had address limit of 8mb, and all that intailed was a bias at a track
boundry to divide the HD into C: and D: logical drives.

With the PC/XT came the IBM convention of a MBR with the 4 possible
partitions. The bootstrap code of the MBR was supplied by whichever
OS fdisk'ed the HD. OS/2, for example, provided a multi-boot MBR
which allowed the console operator to choose a bootable one of a
maximum of four. DRI's MBR tested for more than one partition entry
marked bootable, and balked if so. IBM's MBR booted the first one
found marked as bootable. Compaq's did something funky, I don't
recall what, maybe checked for a magic number first. Msft introduced
the 'extended - partitions' but there was still a limit of 4 primary
partitions in the MBR.

AFAIK, compaq was the first to use a second partition for diagnostics/
recovery/restore functions. Msft followed suit, at least by XP. My
dell XP system also used a third for dell's diagnostics on hardware/
recovery/restore. That is about the time I quit paying close
attention. I knew from that point on it would be too dangerous to
muck with resizing the HD for space for a hobby OS, also the RomBios's
had become sophisticated regarding boot options, so the simpler path
was to get a cheap 2nd HD.

The EISA buss computers had a utility you ran to enumerate added
hardware, it kept that info in a small amount of non-volatile memory.

Similarly PnP (and later) used some nvm so who knows what about your
next question..

> Will it do things like keeping a note of which one it booted last time
> and use that?
>
It must for the Dell I have, D8250. A few years ago I added a second
large HD and cloned the OS to it, and kept the original as
supplimental storage, drive F:. I pulled that original recently and
put a virgin drive in for linux, the idea was to swap the ide data
cable back and forth between XP, and Linux. However, the post code
now stalls for 30 seconds and then reports that the Primary Drive is
not found, press F1 to continue. Pressing F1 will then boot whichever
HD is cabled.

There's alot of NVS non-volatile storage on modern computers, who
knows what is there. Imagine Bios Data Area, Extended Bios Data Area,
>> NVS Bios Data Area. Additionally firmware stored in nvm can be
updated with patches. I'm pretty sure the behavior I describe in the
preceding paragragh wasn't always so. If I were to look for a culprit
I'd look first to xp sp2.

> Is there anything that an OS writer can do to influence the choice?

Yeah, probably only work on a open bios:

http://www.coreboot.org/Welcome_to_coreboot

Steve
>
> James

s_dub...@yahoo.com

unread,
Mar 4, 2012, 9:25:58 PM3/4/12
to
On Mar 4, 7:25 pm, "s_dubrov...@yahoo.com" <s_dubrov...@yahoo.com>
wrote:
Well, if slick SLIC ain't it...

Good read on the Bios's:

https://secure.wikimedia.org/wikipedia/en/wiki/BIOS

> > Is there anything that an OS writer can do to influence the choice?
>
> Yeah, probably only work on a open bios:
>
>  http://www.coreboot.org/Welcome_to_coreboot
>
> Steve
>
>
>
>
>
> > James- Hide quoted text -
>
> - Show quoted text -

Bernhard Schornak

unread,
Mar 5, 2012, 12:15:04 AM3/5/12
to
Nomen Nescio wrote:


> Bernhard Schornak<scho...@web.de> wrote:

<snip>

>> No OS finds any partition on boot-up. There is only one MBR
>> record with set boot flag (on all bootable devices attached
>> to a PC!).
>
> No there is not. Nothing enforces this and I can set all or no partitions
> bootable. Now you are back to the original question.


http://gparted.sourceforge.net/display-doc.php?name=help-manual#gparted-manage-partition-flags


>> The BIOS reads all MBRs on all devices and loads sector 0 of the (only!)
>> partition with set boot flag.
>
> No, it reads the MBRs on devices in order and boots the first bootable
> partition it finds.


Yes.

Does it make sense to set never evaluated flags just
because it is not forbidden?

Bernhard Schornak

unread,
Mar 5, 2012, 12:15:11 AM3/5/12
to
Benjamin David Lunt wrote:


> "Bernhard Schornak"<scho...@web.de> wrote in message
> news:jiv58l$tg9$1...@dont-email.me...
>> Benjamin David Lunt wrote:
>
> Hi Bernhard,
>
> I am sorry, but I have to disagree with you.


If I post nonsense, you should. ;)


>>> For example, what if I have two WinXP partitions and I boot
>>> one of them for one purpose and one of them for a different
>>> purpose. They will both have a registry with an entry for
>>> the default drive, which is not the same partition for both
>>> entries.
>>>
>>> So, even using a signature DWORD at offset 440 in the MBR,
>>> how does your OS find this partition?
>>
>>
>> No OS finds any partition on boot-up. There is only one MBR
>> record with set boot flag (on all bootable devices attached
>> to a PC!). The BIOS reads all MBRs on all devices and loads
>> sector 0 of the (only!) partition with set boot flag.
>
> The BIOS *does not* read all MBR's on all devices. It starts
> with the first pointed to device, and will go until it finds
> a device and partition that qualifies for the bootable device.
> It will not continue to search once it finds that one. That
> is like still searching for something you lost after you have
> found it.


Well, I think the BIOS has to set up a lot of tables and
other structures. I assume that a copy of each found MBR
is stored somewhere during boot up, so the BIOS does not
need to access found devices more than once. (A mem->mem
copy requires less code than reading a sector from HD or
other media).


>> What happens next depends on the code stored in that loaded
>> sector. Either it is a boot manager or an OS. An OS sets up
>> the machine and starts to interact with the user, while the
>> boot manager either loads a default OS or shows a selection
>> of operating systems it can boot.
>
> Agreed. However, my question/comment was, how does the OS
> know which partition on which device was booted.


Sorry if I misunderstood your question. The executed MBR
always can read the partition table residing in the same
512 byte just on top of its code, and it can call INT 13
function 08 to retrieve the current drive.
So you invoke BIOS settings to select which harddrive is
the boot device.

Well, I never booted this way. Using OS/2's Boot Manager
more than 15 years saved me from low level manipulations
like that. Probably my knowledge is a little bit behind.
About five years ago I wrote a repair tool for OS/2 LVM,
but most of the details are forgotten, meanwhile. What I
can remember is that only one active partition (the Boot
Manager itself) is allowed on OS/2 systems.


>> Automated booting from CD or USB is a BIOS option. The BIOS
>> first checks if any removable device is bootable, before it
>> scans MBRs of the attached harddrives for a set boot flag.
>
> However, only if you have chosen this option.


Of course.

Rod Pemberton

unread,
Mar 5, 2012, 3:13:05 AM3/5/12
to
"Benjamin David Lunt" <zf...@fysnet.net> wrote in message
news:jj0gde$crb$1...@speranza.aioe.org...
> [...] lets say that I only have two options to boot from,
> two platter disk devices. The list that the BIOS allows me to
> pick from only has these two options. Each device has a
> partition table with one partition and it is marked active/
> bootable. Again, *each* device has a partition marked bootable.
>

... re-ordered the text ...

> [..] However, my question/comment was, how does the OS
> know which partition on which device was booted.

0) can we assume that a partitioned device was booted?

1) if so, can we establish that only one partition per device can be marked
bootable?

2) if not, can we establish that only the first bootable partition on a
device will be booted by BIOS?

3) if not, what is causing one of the other bootable partitions on a device
to boot? ... software or BIOS selection or BBS menu ...

I believe the answer to the first few is "yes" from my personal PC usage,
but can't completely confirm. I wasn't exactly trying every possible
configuration, except when things didn't work correctly. And, I definately
wasn't recording the outcomes. If correct about "yes", then I'd think you'd
only need to save the device and reread the partition table.

IIRC, you wanted to know about a registry key or somesuch in WinXP ...
Well, I don't have XP. For Win98, it permanently saves the device info in
the registry even if the device has been removed or uninstalled. With
Win98, you can see all of them when you boot into safe mode. There is one
key per device buried somewhere else that tells if that device is present.
There are some other custom keys which disable things like IDE devices. So,
to identify which registry keys are being set, you'll probably have to
unplug the device so it's not found, boot into safe mode and remove the
device, manually delete all other associated registry keys, dump the "clean"
registry, reconnect the device, dump the registry with the new keys, compare
a huge number of changes ... I'd probably do both devices at once. Or, you
could ask somewhere like the MSFN forums:

http://www.msfn.org/board/index.php?app=forums


Rod Pemberton


Rod Pemberton

unread,
Mar 5, 2012, 3:16:20 AM3/5/12
to
"Bernhard Schornak" <scho...@web.de> wrote in message
news:jiv58l$tg9$1...@dont-email.me...
> [...]
> No OS finds any partition on boot-up. There is only one MBR
> record with set boot flag (on all bootable devices attached
> to a PC!). The BIOS reads all MBRs on all devices and loads
> sector 0 of the (only!) partition with set boot flag.
>

Well, I have multiple drives with bootable partitions, but only one bootable
per device. If you install a second hard disk that was bootable on another
machine, now you've got two bootable. If you unplug your primary drive and
install Linux from CD to an external USB hard disk and then re-plug your
primary drive, now you've got multiple bootable devices also. Windows
formatting utilities, especially for DOS, attempt to limit you to only one
bootable partition total. I've experienced that problem multiple times with
DOS and Windows, e.g., seting up a new hard disk from the only one. You
format the new drive and copy or install everything to it, but not set the
boot flag. Generally, I end up booting from floppy or USB stick, pull the
old drive, then set the boot flag on the new drive.

> [...]
> In the case of [Ben's] two WinXP installations - there must be
> a way how you select which one to start the next time, or a
> boot manager pops up while booting. If you can select which
> one should boot the next time, Windows resets the boot flag
> of the current partition and sets it for the other. (Surely
> more comfortable than to open the PC and pull some cables.)

I'm not sure how dual WinXP would work ...

With older machines, boot device selection was device jumper and/or cable
select. With newer machines, boot device selection is either BIOS select or
BBS menu select.

I normally boot one OS, this is setup via the BIOS boot list. Sometimes, I
use the BBS pop-up menu to boot other devices. You don't have to redo the
BIOS boot list. Alternately, I boot my primary OS and through software boot
another OS, e.g., Linux started from DOS. This can be useful if the device
is not recognized by Linux during a boot from it. BIOS emulation allows the
device to boot.


Rod Pemberton


Fritz Wuehler

unread,
Mar 5, 2012, 4:33:36 PM3/5/12
to
Hello Bernhard

> Does it make sense to set never evaluated flags just
> because it is not forbidden?

It would be nice if the tools (various OS fdisk) enforced this but somebody
could probably think of a situation where more than one partition needs to
have the bootable flag on. In my use I never set the partition bootable,
because LILO and GRUB both boot from control files and don't need any
partition flag.

Bernhard Schornak

unread,
Mar 6, 2012, 12:49:49 AM3/6/12
to
Rod Pemberton wrote:


> "Bernhard Schornak" wrote:
>
>> [...]
>> No OS finds any partition on boot-up. There is only one MBR
>> record with set boot flag (on all bootable devices attached
>> to a PC!). The BIOS reads all MBRs on all devices and loads
>> sector 0 of the (only!) partition with set boot flag.
>>
>
> Well, I have multiple drives with bootable partitions, but only one bootable
> per device. If you install a second hard disk that was bootable on another
> machine, now you've got two bootable. If you unplug your primary drive and
> install Linux from CD to an external USB hard disk and then re-plug your
> primary drive, now you've got multiple bootable devices also. Windows
> formatting utilities, especially for DOS, attempt to limit you to only one
> bootable partition total. I've experienced that problem multiple times with
> DOS and Windows, e.g., seting up a new hard disk from the only one. You
> format the new drive and copy or install everything to it, but not set the
> boot flag. Generally, I end up booting from floppy or USB stick, pull the
> old drive, then set the boot flag on the new drive.


I understand that more than one drive can have a bootable
partition. Nevertheless, having more than one bootable HD
is inconsistent and might confuse the one or other OS. It
surely has a reason why OS/2 starts the partitioning tool
on boot-up if any other than the Boot Manager (or system)
partition has its bootable flag set.

However, such problems become history with a growing base
of (U)EFI boards. Mainboard manufacturers save much money
for programmers, Intel gets a little bit richer and users
wonder why their state of the art 4.6 THz Gigantium needs
5 minutes until the BIOS shows any sign of life when they
switch their machine on... ;)


>> [...]
>> In the case of [Ben's] two WinXP installations - there must be
>> a way how you select which one to start the next time, or a
>> boot manager pops up while booting. If you can select which
>> one should boot the next time, Windows resets the boot flag
>> of the current partition and sets it for the other. (Surely
>> more comfortable than to open the PC and pull some cables.)
>
> I'm not sure how dual WinXP would work ...
>
> With older machines, boot device selection was device jumper and/or cable
> select. With newer machines, boot device selection is either BIOS select or
> BBS menu select.
>
> I normally boot one OS, this is setup via the BIOS boot list. Sometimes, I
> use the BBS pop-up menu to boot other devices. You don't have to redo the
> BIOS boot list. Alternately, I boot my primary OS and through software boot
> another OS, e.g., Linux started from DOS. This can be useful if the device
> is not recognized by Linux during a boot from it. BIOS emulation allows the
> device to boot.


The good old times where a PC machinist had to set master
/slave jumpers on the back of each harddisk are gone for-
ever (one eye wet). I'm curious how PCs will look like in
ten or twenty years.

Rod Pemberton

unread,
Mar 6, 2012, 5:59:16 PM3/6/12
to
"Bernhard Schornak" <scho...@web.de> wrote in message
news:jj48hq$r8b$1...@dont-email.me...
> [...]
> I'm curious how PCs will look like in ten or twenty years.
>

Smaller, thinner, maybe more square, perhaps optical cables, likely fewer
wires - more wireless...

A small portable device might be as powerful as PC today. Overall, I think
the technology will shift from people having to pay alot for "luxury"
performance PCs to a large abundance of "for the masses" but fully capable
PCs. I.e., you only need so much processing power or graphics capability
for what we use them for: movies, TV, internet, gaming, word processing,
etc. PCs have finally reached the performance point where they can do what
people want to use them for without needing any more power. So, any
capability beyond what most people will do with a PC becomes unecessary, but
the development of technology doesn't stop. So, we will be in an era where
there will be two classes of PCs: adequate for everything and extra
performance for those who can pay for it. Since there will be fewer people
buying performance, it will likely become far more expensive for those who
do.


Rod Pemberton



wolfgang kern

unread,
Mar 8, 2012, 9:21:16 AM3/8/12
to

James Harris asked:

> When a machine has multiple hard disks which could be booted is there
> a standard way that a BIOS will chose which one to start the OS from?

> Will it do things like keeping a note of which one it booted last time
> and use that?

AFAIK yet... the BIOS remembers the last choosen boot-device somewhere
in the CMOS-RAM. But if this was removeable and not present anymore, it
defaults to try 1.FDs 2.HDs, 3.CD/DVD, 4.else..
the default boot order for several HDs reflect their physical address:
first is (port 01f0) IDE 01 mr ... followed by SATA0..4
CD/DVD may reside inbetween but are checked for boot after HDs failed.

> Is there anything that an OS writer can do to influence the choice?

If we could figure where and how this info is stored in the CMOS-RAM
then this would be easy. I'm afraid for there is no defined standard.

Mike may know more about it ;)


for the discussion on booting from partitions:

my experience told me that the BIOS wont do anything else than load
the first 512 bytes of any device to 0x7c000 and execute this after
55-AA found at the end (FDs may not need this), regardless if there
is a partition-table present at all or if there is just ASCII-text.

Booting from partitions is the job of the code found on LBA_0 (1.MBR).

I hope this recent rumoured BIOS-features for partition-selected boot by
BIOS are just optional, because this would need some changes on my OS.


for the disput about how many bootable partitions one drive can have:

as long no windoze nor loonix nor grub/lilo come in the way, we can mark
all executable partitions as bootable even this need a certain bootloader
then.

JFI: I use all four partition-entries in LBA0 on my first HD:

512 MB DOS600 ;wont work if not first
1 GB KESYS-DEMO ;old but handy for visitors
8 GB winXP
~400 GB extended ;mainly used for games

but of course XP installed as the last which overwrote LBA_0
so there is actually "only one" active (NTLDR) partition there.

the XP-boot selector allow me to boot just DOS or XP, and if I chose
DOS then the original (IOsys)MBR (saved away by XP-installer) become
executed by the loader and so I get a true RM-DOS beside windoze.

By any luck, windoze cant see nor ever touch "the unknown" KESYS-part,
so I can boot DOS and replace it by starting my OS-DEMO from there.

My workstation with a bootable KESYS reside on another machine w/o
windoze anyway.
__
wolfgang


James Harris

unread,
Mar 25, 2012, 2:29:47 PM3/25/12
to
On Mar 3, 4:38 pm, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
wrote:

...

> > When a machine has multiple hard disks which could be booted is there
> > a standard way that a BIOS will chose which one to start the OS from?
>
> > Will it do things like keeping a note of which one it booted last time
> > and use that?
>
> > Is there anything that an OS writer can do to influence the choice?
>
> Didn't you ask this before?

That's the thing about getting old.... starting to repeat oneself. :-)

In fact, the earlier question was limited. I was intending with this
thread to ask you guys a series of questions about the hard disk boot
process but the replies to this thread went straight into the
subsequent issues.

...

> Are you having a certain problem that you're attempting to solve?

No, but there are some things I am not sure about and, bearing in mind
this newsgroups status as a resource, thought it would be a good idea
to ask them here one at a time. At least, that was the intention.

James

James Harris

unread,
Mar 25, 2012, 2:37:23 PM3/25/12
to
On Mar 3, 10:50 pm, "Marven Lee" <marve...@gmail.com> wrote:
> James Harris wrote:
> > When a machine has multiple hard disks which could be booted is there
> > a standard way that a BIOS will chose which one to start the OS from?
>
> I assumed the BIOS would scan for all drive controllers that it supports
> booting from, including add on cards that have drivers in ROM and
> search for the first partition it finds that is marked as active in the
> MBR.  That's assuming that hoot from hard drive was chosen in the
> BIOS setup.

Ah, but doesn't each disk potentially have its own MBR? Perhaps a
better question is: which MBR will the BIOS try to boot?

James

James Harris

unread,
Mar 25, 2012, 2:47:16 PM3/25/12
to
On Mar 5, 6:15 am, Bernhard Schornak <schor...@web.de> wrote:

...

> The executed MBR
> always can read the partition table residing in the same
> 512 byte just on top of its code, and it can call INT 13
> function 08 to retrieve the current drive.

I don't understand this. According to RBIL the BIOS interrupt call you
mention returns disk parameters but has to be passed the disk drive id
as an input. So rather than returning the drive id it seems to require
it.

James

James Harris

unread,
Mar 25, 2012, 2:53:43 PM3/25/12
to
On Mar 6, 6:49 am, Bernhard Schornak <schor...@web.de> wrote:

...

> I understand that more than one drive can have a bootable
> partition. Nevertheless, having more than one bootable HD
> is inconsistent and might confuse the one or other OS.

This is the question that started the thread. Having multiple bootable
MBRs might even confuse the BIOS. (Not really confuse it as the BIOS
will probably use the first one that passes its tests, whatever they
are, but you know what I mean.)

> It
> surely has a reason why OS/2 starts the partitioning tool
> on boot-up if any other than the Boot Manager (or system)
> partition has its bootable flag set.

Interesting. I hadn't heard about that.

> However, such problems become history with a growing base
> of (U)EFI boards.

I was carefully asking nothing about EFI yet as I don't properly
understand even the earlier MBR form!

James

James Harris

unread,
Mar 25, 2012, 3:03:38 PM3/25/12
to
On Mar 5, 2:25 am, "s_dubrov...@yahoo.com" <s_dubrov...@yahoo.com>
wrote:

...

> With the PC/XT came the IBM convention of a MBR with the 4 possible
> partitions.  The bootstrap code of the MBR was supplied by whichever
> OS fdisk'ed the HD.  OS/2, for example, provided a multi-boot MBR
> which allowed the console operator to choose a bootable one of a
> maximum of four.  DRI's MBR tested for more than one partition entry
> marked bootable, and balked if so.  IBM's MBR booted the first one
> found marked as bootable.  Compaq's did something funky, I don't
> recall what, maybe checked for a magic number first.  Msft introduced
> the 'extended - partitions' but there was still a limit of 4 primary
> partitions in the MBR.

And are the extended partitions bootable? If they are then I guess
that they are not booted by the BIOS but by the MBR code. Am I right?

...

> > Will it do things like keeping a note of which one it booted last time
> > and use that?
>
> It must for the Dell I have, D8250.  A few years ago I added a second
> large HD and cloned the OS to it, and kept the original as
> supplimental storage, drive F:.  I pulled that original recently and
> put a virgin drive in for linux, the idea was to swap the ide data
> cable back and forth between XP, and Linux.  However, the post code
> now stalls for 30 seconds and then reports that the Primary Drive is
> not found, press F1 to continue.  Pressing F1 will then boot whichever
> HD is cabled.

If the BIOS is trying to find the original disk then presumably, once
you have told it to boot from a new disk, the delay will go away?

> There's alot of NVS non-volatile storage on modern computers, who
> knows what is there.  Imagine Bios Data Area, Extended Bios Data Area,>> NVS Bios Data Area.  Additionally firmware stored in nvm can be
>
> updated with patches.  I'm pretty sure the behavior I describe in the
> preceding paragragh wasn't always so.  If I were to look for a culprit
> I'd look first to xp sp2.

Yes, there could well be different standards now.

I'm interested in the idea of the BIOS keeping a record of what it
booted last time. As you say, it could store it in non-volatile memory
which the OS writer normally has no meaningful access to.

I suppose it could also write something to the hard disks - e.g. a
timestamp of when booted. But I doubt this is done.

James

James Harris

unread,
Mar 25, 2012, 3:21:41 PM3/25/12
to
On Mar 8, 3:21 pm, "wolfgang kern" <nowh...@never.at> wrote:
> James Harris asked:
>
> > When a machine has multiple hard disks which could be booted is there
> > a standard way that a BIOS will chose which one to start the OS from?
> > Will it do things like keeping a note of which one it booted last time
> > and use that?
>
> AFAIK yet... the BIOS remembers the last choosen boot-device somewhere
> in the CMOS-RAM.

In that case I wonder how it identifies the disk. If it identified it
by controller and master/slave, for example, and the user moved the
disks around, the BIOS would find a different disk where it expected
the last boot disk to be.

If the BIOS stored some disk id then, 1) that ID could be lengthy and
the CMOS RAM is not always too large (EISA excepted); 2) There would
need to be some consistent way of identifying disks (not partitions)
by signature.

...

> > Is there anything that an OS writer can do to influence the choice?
>
> If we could figure where and how this info is stored in the CMOS-RAM
> then this would be easy. I'm afraid for there is no defined standard.

Yes, it may vary too.

...

> for the discussion on booting from partitions:
>
> my experience told me that the BIOS wont do anything else than load
> the first 512 bytes of any device to 0x7c000 and execute this after
> 55-AA found at the end (FDs may not need this), regardless if there
> is a partition-table present at all or if there is just ASCII-text.
>
> Booting from partitions is the job of the code found on LBA_0 (1.MBR).

This is the picture I was hoping was the case but feared it was too
simplistic. If it is right then is the full story that:

1. The BIOS chooses a sector to load to 0x7c00. (The point of this
thread is how to determine which sector it loads to that location.)

2. The code in the loaded sector chooses what to do next. For an MBR
it could go one of two ways:

2(i). Move itself out of the way (ideally?) and load the first sector
of one partition to 0x7c00 and start it.

2(ii). Execute a more extensive "boot manager" which would normally
not sit in a partition. Perhaps the bulk of the boot manager would sit
between the MBR sector and the first partition.

Anyone know if the above is feasible? There is nearly always space
before the first partition as partitions used to start on the
boundaries of cylinders (whether real cylinders or virtual ones).
However, I guess that there no longer has to be space before the first
partition.

James

James Harris

unread,
Mar 25, 2012, 3:44:35 PM3/25/12
to
On Mar 4, 4:07 am, "Benjamin David Lunt" <zf...@fysnet.net> wrote:

...

> Anyway, I took James' question as "How can I manipulate the BIOS
> to boot a different device (not partition) next time?"

Yes, it was about choosing the disk to boot rather than choosing a
partition.

I found something interesting about that. I have a server which has a
number of hard disks and which the OS does not always give the same
names to. I think the names depend mainly on both where the disks are
connected and which disks are connected at bootup.

Although the disks get moved around the BIOS on the server seems to
consistently locate the right disk to boot from.

The first sectors on the disks (and here is where it starts to get
interesting)! seem to consistently have 0x55, 0xaa at the end. So from
what I had heard they should be seen by the BIOS as bootable. I
haven't played around with lots of boot experiments but from looking
at the boot sectors a pattern emerges. Using the command

sudo dd bs=512 count=1 2>/dev/null if=/dev/sda | hd

and replacing sda with each disk name gives the following. The lines
with just an asterisk at the beginning indicate a block of lines which
are identical to the one above so in these cases most of the boot
sectors are predominantly zeroes.

sda
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
*
000001b0 00 00 00 00 00 00 00 00 e2 84 c8 90 00 00 00 01
|................|
000001c0 01 00 83 fe ff ff 3f 00 00 00 02 4c 38 3a 00 00
|......?....L8:..|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
*
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
|..............U.|

sdc
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
*
000001b0 00 00 00 00 00 00 00 00 68 1d 90 68 00 00 00 00
|........h..h....|
000001c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
000001d0 01 01 83 fe ff ff c1 3e 00 00 80 28 a8 ae 00 00
|.......>...(....|
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
|..............U.|

sdd
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
*
000001b0 00 00 00 00 00 00 00 00 11 6c 66 1e 00 00 00 01
|.........lf.....|
000001c0 01 00 05 fe ff ff 3f 00 00 00 82 59 70 74 00 00
|......?....Ypt..|
000001d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
*
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
|..............U.|

etc. And eventually we get to the boot disk, sdg, which looks like
this:

sdg
00000000 eb 48 90 10 8e d0 bc 00 b0 b8 00 00 8e d8 8e c0
|.H..............|
00000010 fb be 00 7c bf 00 06 b9 00 02 f3 a4 ea 21 06 00
|...|.........!..|
00000020 00 be be 07 38 04 75 0b 83 c6 10 81 fe fe 07 75 |....
8.u........u|
00000030 f3 eb 16 b4 02 b0 01 bb 00 7c b2 80 8a 74 03 02
|.........|...t..|
00000040 ff 00 00 20 01 00 00 00 00 02 fa 90 90 f6 c2 80
|... ............|
00000050 75 02 b2 80 ea 59 7c 00 00 31 c0 8e d8 8e d0 bc |u....Y|..
1......|
00000060 00 20 fb a0 40 7c 3c ff 74 02 88 c2 52 be 7f 7d |. ..@|
<.t...R..}|
00000070 e8 34 01 f6 c2 80 74 54 b4 41 bb aa 55 cd 13 5a |.
4....tT.A..U..Z|
00000080 52 72 49 81 fb 55 aa 75 43 a0 41 7c 84 c0 75 05 |
RrI..U.uC.A|..u.|
00000090 83 e1 01 74 37 66 8b 4c 10 be 05 7c c6 44 ff 01
|...t7f.L...|.D..|
000000a0 66 8b 1e 44 7c c7 04 10 00 c7 44 02 01 00 66 89 |
f..D|.....D...f.|
000000b0 5c 08 c7 44 06 00 70 66 31 c0 89 44 04 66 89 44 |
\..D..pf1..D.f.D|
000000c0 0c b4 42 cd 13 72 05 bb 00 70 eb 7d b4 08 cd 13
|..B..r...p.}....|
000000d0 73 0a f6 c2 80 0f 84 ea 00 e9 8d 00 be 05 7c c6 |
s.............|.|
000000e0 44 ff 00 66 31 c0 88 f0 40 66 89 44 04 31 d2 88 |
D..f1...@f.D.1..|
000000f0 ca c1 e2 02 88 e8 88 f4 40 89 44 08 31 c0 88 d0
|........@.D.1...|
00000100 c0 e8 02 66 89 04 66 a1 44 7c 66 31 d2 66 f7 34 |...f..f.D|
f1.f.4|
00000110 88 54 0a 66 31 d2 66 f7 74 04 88 54 0b 89 44 0c
|.T.f1.f.t..T..D.|
00000120 3b 44 08 7d 3c 8a 54 0d c0 e2 06 8a 4c 0a fe c1 |;D.}
<.T.....L...|
00000130 08 d1 8a 6c 0c 5a 8a 74 0b bb 00 70 8e c3 31 db
|...l.Z.t...p..1.|
00000140 b8 01 02 cd 13 72 2a 8c c3 8e 06 48 7c 60 1e b9
|.....r*....H|`..|
00000150 00 01 8e db 31 f6 31 ff fc f3 a5 1f 61 ff 26 42 |....
1.1.....a.&B|
00000160 7c be 85 7d e8 40 00 eb 0e be 8a 7d e8 38 00 eb
||..}.@.....}.8..|
00000170 06 be 94 7d e8 30 00 be 99 7d e8 2a 00 eb fe 47 |...}.
0...}.*...G|
00000180 52 55 42 20 00 47 65 6f 6d 00 48 61 72 64 20 44 |
RUB .Geom.Hard D|
00000190 69 73 6b 00 52 65 61 64 00 20 45 72 72 6f 72 00 |isk.Read.
Error.|
000001a0 bb 01 00 b4 0e cd 10 ac 3c 00 75 f4 c3 00 00 00
|........<.u.....|
000001b0 00 00 00 00 00 00 00 00 a6 90 0a 00 00 00 80 01
|................|
000001c0 01 00 83 fe ff ff 3f 00 00 00 b6 53 43 73 00 fe
|......?....SCs..|
000001d0 ff ff 05 fe ff ff f5 53 43 73 cc 05 2d 01 00 00
|.......SCs..-...|
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
|................|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
|..............U.|

So, does anyone know how the BIOS identifies that only the last disk
should be booted? I can guess but it would only be a guess....

James

James Harris

unread,
Mar 25, 2012, 3:57:53 PM3/25/12
to
On Mar 25, 8:44 pm, James Harris <james.harri...@googlemail.com>
wrote:
> On Mar 4, 4:07 am, "Benjamin David Lunt" <zf...@fysnet.net> wrote:
>
> ...
>
> > Anyway, I took James' question as "How can I manipulate the BIOS
> > to boot a different device (not partition) next time?"
>
> Yes, it was about choosing the disk to boot rather than choosing a
> partition.
>
> I found something interesting about that. I have a server which has a
> number of hard disks and which the OS does not always give the same
> names to. I think the names depend mainly on both where the disks are
> connected and which disks are connected at bootup.
>
> Although the disks get moved around the BIOS on the server seems to
> consistently locate the right disk to boot from.
>
> The first sectors on the disks (and here is where it starts to get
> interesting)! seem to consistently have 0x55, 0xaa at the end. So from
> what I had heard they should be seen by the BIOS as bootable. I
> haven't played around with lots of boot experiments but from looking
> at the boot sectors a pattern emerges. Using the command
>
>   sudo dd bs=512 count=1 2>/dev/null if=/dev/sda | hd
>
> and replacing sda with each disk name gives the following. The lines
> with just an asterisk at the beginning indicate a block of lines which
> are identical to the one above so in these cases most of the boot
> sectors are predominantly zeroes.

...

Ugh. Line wrapping make the earlier post look hard to read. I'll try
again with shorter lines. This time the offsets are just two bytes,
there is no ASCII section and blank lines indicate duplicates of the
one above.

sda (most are like this)
0000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

01b0 00 00 00 00 00 00 00 00 e2 84 c8 90 00 00 00 01
01c0 01 00 83 fe ff ff 3f 00 00 00 02 4c 38 3a 00 00
01d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

01f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa

sdg (boot disk)
0000 eb 48 90 10 8e d0 bc 00 b0 b8 00 00 8e d8 8e c0
0010 fb be 00 7c bf 00 06 b9 00 02 f3 a4 ea 21 06 00
0020 00 be be 07 38 04 75 0b 83 c6 10 81 fe fe 07 75
0030 f3 eb 16 b4 02 b0 01 bb 00 7c b2 80 8a 74 03 02
0040 ff 00 00 20 01 00 00 00 00 02 fa 90 90 f6 c2 80
0050 75 02 b2 80 ea 59 7c 00 00 31 c0 8e d8 8e d0 bc
0060 00 20 fb a0 40 7c 3c ff 74 02 88 c2 52 be 7f 7d
0070 e8 34 01 f6 c2 80 74 54 b4 41 bb aa 55 cd 13 5a
0080 52 72 49 81 fb 55 aa 75 43 a0 41 7c 84 c0 75 05
0090 83 e1 01 74 37 66 8b 4c 10 be 05 7c c6 44 ff 01
00a0 66 8b 1e 44 7c c7 04 10 00 c7 44 02 01 00 66 89
00b0 5c 08 c7 44 06 00 70 66 31 c0 89 44 04 66 89 44
00c0 0c b4 42 cd 13 72 05 bb 00 70 eb 7d b4 08 cd 13
00d0 73 0a f6 c2 80 0f 84 ea 00 e9 8d 00 be 05 7c c6
00e0 44 ff 00 66 31 c0 88 f0 40 66 89 44 04 31 d2 88
00f0 ca c1 e2 02 88 e8 88 f4 40 89 44 08 31 c0 88 d0
0100 c0 e8 02 66 89 04 66 a1 44 7c 66 31 d2 66 f7 34
0110 88 54 0a 66 31 d2 66 f7 74 04 88 54 0b 89 44 0c
0120 3b 44 08 7d 3c 8a 54 0d c0 e2 06 8a 4c 0a fe c1
0130 08 d1 8a 6c 0c 5a 8a 74 0b bb 00 70 8e c3 31 db
0140 b8 01 02 cd 13 72 2a 8c c3 8e 06 48 7c 60 1e b9
0150 00 01 8e db 31 f6 31 ff fc f3 a5 1f 61 ff 26 42
0160 7c be 85 7d e8 40 00 eb 0e be 8a 7d e8 38 00 eb
0170 06 be 94 7d e8 30 00 be 99 7d e8 2a 00 eb fe 47
0180 52 55 42 20 00 47 65 6f 6d 00 48 61 72 64 20 44
0190 69 73 6b 00 52 65 61 64 00 20 45 72 72 6f 72 00
01a0 bb 01 00 b4 0e cd 10 ac 3c 00 75 f4 c3 00 00 00
01b0 00 00 00 00 00 00 00 00 a6 90 0a 00 00 00 80 01
01c0 01 00 83 fe ff ff 3f 00 00 00 b6 53 43 73 00 fe
01d0 ff ff 05 fe ff ff f5 53 43 73 cc 05 2d 01 00 00
01e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
01f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa

Bernhard Schornak

unread,
Mar 25, 2012, 4:26:39 PM3/25/12
to
Start with drive 00. Read MBR and compare its partition
table with the one you've got. Repeat until all entries
are equal. It is very unlikely that all drives have the
same partition table. At least the bootable flag should
differ if the remaining 65 byte of any other drive were
identical.

This seems to be the -only- way to determine from which
drive a machine was booted.

Most BIOS'es load the first detected bootable partition
and start it. Hence, a time consuming comparison can be
skipped by evaluating the bootable flags of all drives,
only. The first match -should- be the boot partition...

s_dub...@yahoo.com

unread,
Mar 25, 2012, 7:58:49 PM3/25/12
to
On Mar 25, 2:03 pm, James Harris <james.harri...@googlemail.com>
wrote:
> On Mar 5, 2:25 am, "s_dubrov...@yahoo.com" <s_dubrov...@yahoo.com>
> wrote:
>
> ...
>
> > With the PC/XT came the IBM convention of a MBR with the 4 possible
> > partitions.  The bootstrap code of the MBR was supplied by whichever
> > OS fdisk'ed the HD.  OS/2, for example, provided a multi-boot MBR
> > which allowed the console operator to choose a bootable one of a
> > maximum of four.  DRI's MBR tested for more than one partition entry
> > marked bootable, and balked if so.  IBM's MBR booted the first one
> > found marked as bootable.  Compaq's did something funky, I don't
> > recall what, maybe checked for a magic number first.  Msft introduced
> > the 'extended - partitions' but there was still a limit of 4 primary
> > partitions in the MBR.
>
> And are the extended partitions bootable? If they are then I guess
> that they are not booted by the BIOS but by the MBR code. Am I right?
>

No, they're not bootable, it is a msdos convention to add additional
drive letters (volumes).

Well, you know, msdos OS's that came pre-installed on a hard drive,
would naturally assume it was the only OS installed.

> ...
>
> > > Will it do things like keeping a note of which one it booted last time
> > > and use that?
>
> > It must for the Dell I have, D8250.  A few years ago I added a second
> > large HD and cloned the OS to it, and kept the original as
> > supplimental storage, drive F:.  I pulled that original recently and
> > put a virgin drive in for linux, the idea was to swap the ide data
> > cable back and forth between XP, and Linux.  However, the post code
> > now stalls for 30 seconds and then reports that the Primary Drive is
> > not found, press F1 to continue.  Pressing F1 will then boot whichever
> > HD is cabled.
>
> If the BIOS is trying to find the original disk then presumably, once
> you have told it to boot from a new disk, the delay will go away?
>

Hard to say, perhaps it's that I've used the bios 'setup' to change
the boot sequence to boot from cdrom as the first boot device, I've
been lazy about changing boot order back.

> > There's alot of NVS non-volatile storage on modern computers, who
> > knows what is there.  Imagine Bios Data Area, Extended Bios Data Area,
>> NVS Bios Data Area.  Additionally firmware stored in nvm can be
>
> > updated with patches.  I'm pretty sure the behavior I describe in the
> > preceding paragragh wasn't always so.  If I were to look for a culprit
> > I'd look first to xp sp2.
>
> Yes, there could well be different standards now.
>
> I'm interested in the idea of the BIOS keeping a record of what it
> booted last time. As you say, it could store it in non-volatile memory
> which the OS writer normally has no meaningful access to.
>
> I suppose it could also write something to the hard disks - e.g. a
> timestamp of when booted. But I doubt this is done.
>

I doubt it too. What is the meaning of that if the hard drive is
pulled and substituted? Besides, things are not as simple as they
once were. Modern drives have alot more features, they can warn of
impending failure, they can report back their unique ID, they can be
password protected on the internal hd circuitry, they have builtin
diagnostics in firmware on the drive itself. etc. I recommend you
research the drive you have on your development machine, go to the
manufacturers website and see what documents are available for it, its
feature set. Then you'll get an idea of what the bios would need to
support its features.

You know, we don't get to see the source code of modern bios's, but
how important is that for our hobby OS's really?

To get back to your original question.. I assume there is a primary
and secondary HD controller, each supporting a primary and secondary
drive, so there is a natural enumeration to begin with. I assume that
with modern 'setup' type post code, that enumeration can be
revectored.

By convention there is a MBR on each and a partition table describing
(up to) 4 partitions, but perhaps there is only one partition
described with some or all of the drive space allocated to it. All
the OS needs to know is its own partition. The OS can read the MBR,
look at the partition table fields, find the partition 'type' byte,
and know 'this is I'.

I don't know/don't think that that convention is followed by grub on
linux (someone who knows may say).

Steve

> James

Rod Pemberton

unread,
Mar 25, 2012, 11:21:40 PM3/25/12
to
"James Harris" <james.h...@googlemail.com> wrote in message
news:f788784c-01b1-49d5...@em9g2000vbb.googlegroups.com...
> [...]
> Yes, it was about choosing the disk to boot rather than choosing a
> partition.
>
> I found something interesting about that. I have a server which has a
> number of hard disks and which the OS does not always give the same
> names to. I think the names depend mainly on both where the disks are
> connected and which disks are connected at bootup.
>
> Although the disks get moved around the BIOS on the server seems to
> consistently locate the right disk to boot from.
>
> The first sectors on the disks (and here is where it starts to get
> interesting)! seem to consistently have 0x55, 0xaa at the end. So from
> what I had heard they should be seen by the BIOS as bootable. I
> haven't played around with lots of boot experiments but from looking
> at the boot sectors a pattern emerges. Using the command
>
> sudo dd bs=512 count=1 2>/dev/null if=/dev/sda | hd
>
> and replacing sda with each disk name gives the following. The lines
> with just an asterisk at the beginning indicate a block of lines which
> are identical to the one above so in these cases most of the boot
> sectors are predominantly zeroes.
>
> [parition regions of sda, sdb, sdc]

One 80h above for sdc [snipped] ...

> etc. And eventually we get to the boot disk, sdg, which looks like
> this:
>
> sdg
> 00000000 eb 48 90 10 8e d0 bc 00 b0 b8 00 00 8e d8 8e c0
> |.H..............|
> [... SNIP ...]
> 000001b0 00 00 00 00 00 00 00 00 a6 90 0a 00 00 00 80 01
> |................|
> 000001c0 01 00 83 fe ff ff 3f 00 00 00 b6 53 43 73 00 fe
> |......?....SCs..|
> 000001d0 ff ff 05 fe ff ff f5 53 43 73 cc 05 2d 01 00 00
> |.......SCs..-...|
> 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> |................|
> 000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa
> |..............U.|
>

Only one 80h there too ...

> So, does anyone know how the BIOS identifies that only the last disk
> should be booted? I can guess but it would only be a guess....

Each partition record starts with a single byte boot indicator, 80h for
bootable, 00h for not. The 80h boot flag should be at locations: 1BEh,
1CEh, 1DEh, or 1EEh. See these:

http://www.delorie.com/djgpp/doc/rbinter/it/51/6.html
http://www.delorie.com/djgpp/doc/rbinter/it/51/6.html
http://www.delorie.com/djgpp/doc/rbinter/it/51/6.html

There are only two 80h's in the partition table regions, one for sdg and one
for sdc. So, you only have two potentially bootable partitions. The 80h
for sdc is not in the correct location (1DAh). It's not a boot flag. The
80h for sdg is in the correct location (1BEh). It is a boot flag. 1BEh
location is for partition #1. So, partition #1 of sdc is bootable. It's
probably called sdc1. So, of all the partitions you posted, it seems there
is only one partition marked bootable. Confused. Did I miss something?

This appears to be for Linux. The BIOS probably has a boot list. It'll
attempt to boot those devices. After that, you probably have Grub or LILO
installed which should have a script to specify which partition to boot.

Do you have Linux fdisk installed? If so, there is an option, perhaps -l,
to fdisk that lists all found partitions. I'm not sure if the other
partition programs like cfdisk do so.


Rod Pemberton




wolfgang kern

unread,
Mar 26, 2012, 7:06:46 AM3/26/12
to

James Harris asked why BIOS boots only sdg:
...
> So, does anyone know how the BIOS identifies that only the last disk
> should be booted? I can guess but it would only be a guess....

I think it got really nothing to do with partition-entries,
perhaps because your MBRs in sda,sdc,sdd contain zeros at start ?

I remember to once read that the first (two or 3) bytes of MBR0 were checked
to be in a certain range (IIRC F6>0 >5 ?) in addition to 55-AA.

My variant KESYS-MBRs start with code (without a jump over data) and for
sure not all of them got a partition table, this last bytes from 1BE..1FD
may contain text or other data and I haven't any problem to boot HDs.

Thanks for posting a detailed image of a GRUB-MBR, looks like it put
garbage into the initial data-fields, ... to fool other tools ? :)

Just for fun and as a distraction from daily stress, I analysed what
and how it does. And if my interpretation isn't totally wrong then
your Linux-part is almost 1 TB large while the remaining space is
just ~9.4 GB ?


__
wolfgang

> etc. And eventually we get to the boot disk, sdg, which looks like
> this:

> sdg:
> 0000 eb 48 90 10 8e d0 bc 00 b0 b8 00 00 8e d8 8e c0
> 0010 fb be 00 7c bf 00 06 b9 00 02 f3 a4 ea 21 06 00
> 0020 00 be be 07 38 04 75 0b 83 c6 10 81 fe fe 07 75
> 0030 f3 eb 16 b4 02 b0 01 bb 00 7c b2 80 8a 74 03 02
> 0040 ff 00 00 20 01 00 00 00 00 02 fa 90 90 f6 c2 80

000 eb 48 90 JMP 04a |nop
003 ... 049 ;data block (maybe modified by code in here)
04a FA 90 90 CLI |nop|nop
04d F6 C2 80 TEST DL,080
> 0050 75 02 b2 80 ea 59 7c 00 00 31 c0 8e d8 8e d0 bc
050 75 02 JNZ 054
052 B2 80 MOV DL,080
054 EA 59 7C 00 00 JMP FAR 0000:7c59 ;which mean next line here
059 31 C0 XOR ax,ax
05b 8E D8 MOV DS,ax
05d 8E D0 MOV SS,ax
05f BC 00 20 MOV SP,2000 ;stack top at 0000:2000
> 0060 00 20 fb a0 40 7c 3c ff 74 02 88 c2 52 be 7f 7d
062 FB STI
063 A0 40 7C MOV AL,[7C40] ;offset 040 = FF here
066 3C FF CMP AL,FF
068 74 02 JZ 06c
06a 88 C2 MOV DL,AL ; ?
06c 52 PUSH DX
06d BE 7F 7D MOV SI,7d7f ;offset 017f="GRUB"0
> 0070 e8 34 01 f6 c2 80 74 54 b4 41 bb aa 55 cd 13 5a
070 E8 34 01 CALL 01A7 ;show it
073 F6 C2 80 TEST DL,80
076 74 54 JZ 0cc
078 B4 41 MOV AH,41
07a BB AA 55 MOV BX,55AA
07d CD 13 INT 13
07f 5A POP DX
> 0080 52 72 49 81 fb 55 aa 75 43 a0 41 7c 84 c0 75 05
080 52 PUSH DX
081 72 49 JC 0cc
083 81 fb 55 aa CMP BX,AA55
087 75 43 JNZ 0cc
089 A0 41 7C MOV AL,[7c41] ; 041 = 00
08c 84 C0 TEST AL,AL
08e 75 05 JNZ 095
> 0090 83 e1 01 74 37 66 8b 4c 10 be 05 7c c6 44 ff 01
090 83 E1 01 AND CX,+1
093 74 37 JZ 0cc
095 66 8B 4C 10 MOV ECX,[SI+010]
099 BE 05 7C MOV SI,7C05
09c C6 44 ff 01 MOV byte [SI-1],01 ; 004 b
> 00a0 66 8b 1e 44 7c c7 04 10 00 c7 44 02 01 00 66 89
0a0 66 8B 1E 44 7C MOV EBX,[7c44] ; 044 = 0000_0001
0a5 C7 04 10 00 MOV word [SI],0010 ; 005 w
0a9 C7 44 02 01 00 MOV word [SI+2],0001 ; 007 w
0ae 66 89 5c 08 MOV [SI+8],EBX ; 00D q
> 00b0 5c 08 c7 44 06 00 70 66 31 c0 89 44 04 66 89 44
0b2 C7 44 06 00 70 MOV word [SI+6],7000 ; 00B w
0b7 66 31 c0 XOR eax,eax
0ba 89 44 04 MOV [SI+4],ax ; 009 w
0bd 66 89 44 0C MOV [SI+0C],eax 011 q
> 00c0 0c b4 42 cd 13 72 05 bb 00 70 eb 7d b4 08 cd 13
0c1 B4 42 MOV AH,42
0c3 CD 13 INT 13
0c5 72 05 JC 0cc
0c7 BB 00 70 MOV BX,7000
0ca EB 7D JMP 0149
:
0cc B4 08 MOV AH,08
0ce CD 13 INT 13
> 00d0 73 0a f6 c2 80 0f 84 ea 00 e9 8d 00 be 05 7c c6
0d0 73 0a JNC 0dc
0d2 f6 d2 NOT DL
0d4 80 0f 84 OR byte[BX],084 ;set bit7+2 [???]
0d7 ea 00 e9 8d 00 JMP FAR 008d:e900 ;what's at 09_b900 ??
0dc be 05 7c MOV SI,7C05
0df c6 44 ff 00 MOV byte[SI-1],0 ;004 b
> 00e0 44 ff 00 66 31 c0 88 f0 40 66 89 44 04 31 d2 88
0e3 66 31 C0 XOR eax,eax
0e6 88 f0 MOV AL,DH
0e8 40 INC AX
0e9 66 89 44 04 MOV [SI+4],eax
0ed 31 D2 XOR DX,DX
0ef 88 CA MOV DL,CL
> 00f0 ca c1 e2 02 88 e8 88 f4 40 89 44 08 31 c0 88 d0
0f1 C1 E2 02 SHL DX,2
0f4 88 E8 MOV AL,CH
0f6 88 F4 MOV AH,DH
0f8 40 INC AX
0f9 89 44 08 MOV [SI+8],AX ; 00D w
0fc 31 C0 XOR ax,ax
0fe 88 D0 MOV AL,DL
> 0100 c0 e8 02 66 89 04 66 a1 44 7c 66 31 d2 66 f7 34
100 C0 E8 02 SHR AL,2
103 66 89 04 MOV [SI],eax ; 005 q
106 66 A1 44 7C MOV eax,[7C44] ; = 0000_0001
10a 66 31 D2 XOR edx,edx
10d 66 F7 34 DIV dword[SI]
> 0110 88 54 0a 66 31 d2 66 f7 74 04 88 54 0b 89 44 0c
110 88 54 0A MOV [SI+0a],DL ; 00f b
113 66 31 D2 XOR edx,edx
116 66 F7 74 04 DIV dword[SI+04] ; 009 q
11a 88 54 0B MOV [SI+0b],DL ; 010 b
11d 89 44 0C MOV [SI+0c],AX ; 011 w
> 0120 3b 44 08 7d 3c 8a 54 0d c0 e2 06 8a 4c 0a fe c1
120 3B 44 08 CMP AX,[SI+08]
123 7D 3C JNL 0161 ;if >=
125 8A 54 0D MOV DL,[SI+0d] ; 012 b (is an AH as well)
128 C0 E2 06 SHL DL,6
12b 8A 4C 0A MOV CL,[SI+0a] ; 00f b
12e FE C1 INC CL
> 0130 08 d1 8a 6c 0c 5a 8a 74 0b bb 00 70 8e c3 31 db
130 08 D1 OR CL,DL
132 8A 6C 0C MOV CH,[SI+0c] ;011 b
135 5A POP DX
136 8A 74 0B MOV DH,[SI+0b] ;010 b
139 BB 00 70 MOV BX,7000
13c 8E C3 MOV ES,BX
13e 31 DB XOR BX,BX
> 0140 b8 01 02 cd 13 72 2a 8c c3 8e 06 48 7c 60 1e b9
140 B8 01 02 MOV AX,0201
143 CD 13 INT 13
145 72 2A JC 171
147 8C C3 MOV BX,ES
:
149 8E 06 48 7C MOV ES,[7C48] ; = 0200
14d 60 PUSHA
14e 1E PUSH DS
14f b9 00 01 MOV CX,0100
> 0150 00 01 8e db 31 f6 31 ff fc f3 a5 1f 61 ff 26 42
152 8E DB MOV DS,BX
154 31 F6 XOR SI,SI
156 31 FF XOR DI,DI
158 FC CLD
159 F3 A5 REP MOVSW ;512 byte from 70000 to 2000
15b 1F POP DS
15c 61 POPA
15d ff 26 42 7c JMP[7C42] ; this read as 2000
> 0160 7c be 85 7d e8 40 00 eb 0e be 8a 7d e8 38 00 eb
:
161 BE 85 7D MOV SI,7D85 ;"Geom"
164 E8 40 00 CALL 01A7
167 EB 0E JMP 177
:
169 BE 8A 7D MOV SI,7D8A ;"Hard Disk"
16c E8 38 00 CALL 01A7
16f EB 06 JMP 177
> 0170 06 be 94 7d e8 30 00 be 99 7d e8 2a 00 eb fe 47
:
171 BE 94 7D MOV SI,7D94 ;"Read"
174 E8 30 00 CALL 01A7
177 BE 99 7D MOV SI,7D99 ;" Error"
17a E8 2A 00 CALL 01A7
17d EB FE jmp self

> 0180 52 55 42 20 00 47 65 6f 6d 00 48 61 72 64 20 44
> 0190 69 73 6b 00 52 65 61 64 00 20 45 72 72 6f 72 00
> 01a0 bb 01 00 b4 0e cd 10 ac 3c 00 75 f4 c3 00 00 00

17f "GRUB",0
185 "Geom",0
18a "Hard Disk",0
194 "Read",0
199 " Error",0

1a0 BB 01 00 MOV BX,0001 ;write msg to screen
1a3 B4 0E MOV AH,0E
1a5 CD 10 INT 10
1a7 AC LODSB ;call entry point
1a8 3C 00 CMP AL,0
1aa 75 f4 JNZ 1a0
1ac c3 RET

1ad ...1b7 ;all 00
1b8 a6 98 0a 00 00 00 ;dunno what's this.

partition-entries:
1be 80 01 01 00 83 fe ff ff(0000003f)(734353b6) ;Loonix
1ce 00 fe ff ff 05 fe ff ff(734353f5)(012d05cc) ;extension
> 000001b0 00 00 00 00 00 00 00 00 a6 90 0a 00 00 00 80 01
> 000001c0 01 00 83 fe ff ff 3f 00 00 00 b6 53 43 73 00 fe
> 000001d0 ff ff 05 fe ff ff f5 53 43 73 cc 05 2d 01 00 00
> 000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

wolfgang kern

unread,
Mar 26, 2012, 7:58:25 AM3/26/12
to

James Harris wrote:


>> When a machine has multiple hard disks which could be booted is there
>> a standard way that a BIOS will chose which one to start the OS from?
>> Will it do things like keeping a note of which one it booted last time
>> and use that?

> AFAIK yet... the BIOS remembers the last choosen boot-device somewhere
> in the CMOS-RAM.

|In that case I wonder how it identifies the disk. If it identified it
|by controller and master/slave, for example, and the user moved the
|disks around, the BIOS would find a different disk where it expected
|the last boot disk to be.

I dont think it's that complicated ;)
If the user really swap cables then the BIOS may try to boot from
what it was told before, and uses default if this failed.

|If the BIOS stored some disk id then, 1) that ID could be lengthy and
|the CMOS RAM is not always too large (EISA excepted); 2) There would
|need to be some consistent way of identifying disks (not partitions)
|by signature.

We got +128 byte in newer RTCL-chips and +256 byte CMOS on a second page
but I'd say the BIOS shouldn't be too smart on this matter :)


>> Is there anything that an OS writer can do to influence the choice?
> If we could figure where and how this info is stored in the CMOS-RAM
> then this would be easy. I'm afraid for there is no defined standard.
|Yes, it may vary too.

> for the discussion on booting from partitions:
>
> my experience told me that the BIOS wont do anything else than load
> the first 512 bytes of any device to 0x7c000 and execute this after
> 55-AA found at the end (FDs may not need this), regardless if there
> is a partition-table present at all or if there is just ASCII-text.
>
> Booting from partitions is the job of the code found on LBA_0 (1.MBR).

|This is the picture I was hoping was the case but feared it was too
|simplistic. If it is right then is the full story that:

|1. The BIOS chooses a sector to load to 0x7c00. (The point of this
|thread is how to determine which sector it loads to that location.)

I may repeat myself yet: BIOS loads and execute only "the first sector
of a physical drive/device", because it can't do any else as long not
recently rumored EFI/UEFI features are present and enabled in a BIOS.

|2. The code in the loaded sector chooses what to do next. For an MBR
|it could go one of two ways:

|2(i). Move itself out of the way (ideally?) and load the first sector
|of one partition to 0x7c00 and start it.

Yes, I'd call this a bootloader.

|2(ii). Execute a more extensive "boot manager" which would normally
|not sit in a partition. Perhaps the bulk of the boot manager would sit
|between the MBR sector and the first partition.

Also possible, but the code found at LBA-sector 000 need to know about.
OTOH, there is no space inbetween LBA0 and 'my' first partition :)

|Anyone know if the above is feasible?

Yes, it already works that way for both variants.

|There is nearly always spacebefore the first partition as partitions
|used to start on the boundaries of cylinders (whether real cylinders
|or virtual ones).
|However, I guess that there no longer has to be space before the first
|partition.

If you mean this wasted 63 sectors inserted by many formatting-tools
then youre right, this is only needed for windoze to hide some data.
Don't know if Linux need this too. My OS in the standalone version
use the full capacty of an HD and have code-modules stored beginning
at LBA1. LBA0 got the job to initial load them.

I see the 'first partition' (can be the only one) already as a contigues
packet of sectors starting with LBA0.

__
wolfgang


Bernhard Schornak

unread,
Mar 26, 2012, 2:44:38 PM3/26/12
to
Nowadays, sectors 01... might be occupied by a GPT.
OS/2's LVM uses sectors 62 and 63 for its partition
structures. (Some older GRUB's had the bad attitude
to overwrite these two sectors. Forced me to create
a LVM repair tool...)

wolfgang kern

unread,
Mar 27, 2012, 6:31:39 PM3/27/12
to

Bernhard Schornak replied:

...
>> I see the 'first partition' (can be the only one) already as a contigues
>> packet of sectors starting with LBA0.

> Nowadays, sectors 01... might be occupied by a GPT.
> OS/2's LVM uses sectors 62 and 63 for its partition
> structures. (Some older GRUB's had the bad attitude
> to overwrite these two sectors. Forced me to create
> a LVM repair tool...)


Ok, but I mentioned opportunities which arent common at all.
Sure, windoze, loonix and a few more (ab)use this 63 wasted sectors
for some purpose like bad-cluster listing and paranoid security.
But we who write our own OS arent bound to this at all.
BIOS wont ever touch neither by read nor write LBA>0, this area seem
to be a playground for hidden M$-activities (Fact: windoze == trojan).

__
wolfgang


Bernhard Schornak

unread,
Mar 28, 2012, 6:45:53 AM3/28/12
to
Partially agreed. It surely depends on your OS -
if it is a stand-alone OS (no other OS's exist),
it was a waste of available space not to use the
first sectors. If there is more than one OS, all
installed OS's -should- act cooperative to avoid
foreseeable conflicts.

Looking at the threads regarding filesystems and
partitions... is anyone aware of the change from
512 to 4,096 byte sectors?

James Harris

unread,
Mar 31, 2012, 3:16:39 AM3/31/12
to
On Mar 25, 9:26 pm, Bernhard Schornak <schor...@web.de> wrote:
> James Harris wrote:
> > On Mar 5, 6:15 am, Bernhard Schornak<schor...@web.de>  wrote:
>
> > ...
>
> >> The executed MBR
> >> always can read the partition table residing in the same
> >> 512 byte just on top of its code, and it can call INT 13
> >> function 08 to retrieve the current drive.
>
> > I don't understand this. According to RBIL the BIOS interrupt call you
> > mention returns disk parameters but has to be passed the disk drive id
> > as an input. So rather than returning the drive id it seems to require
> > it.
>
> Start with drive 00. Read MBR and compare its partition
> table with the one you've got. Repeat until all entries
> are equal. It is very unlikely that all drives have the
> same partition table. At least the bootable flag should
> differ if the remaining 65 byte of any other drive were
> identical.

That's not the same as using int 0x13-08 and I don't think it is
necessary. See below.

> This seems to be the -only- way to determine from which
> drive a machine was booted.

Why not use DL? From the early IBM BIOS I think this was set to
identify the drive that the boot sector was loaded from. Initially it
was 0x80 for the hard disk and 0x00 for the floppy. Later it was
extended to support more than one disk of each type. The value passed
in that register should be the disk number that the BIOS uses so the
MBR code (or that on a floppy) can use int 0x13 calls using that
number.

> Most BIOS'es load the first detected bootable partition
> and start it.

Well, they load the first bootable *bootsector* and start it (though
how they identify whether an initial sector is bootable or not is the
principal subject of this thread). With a normally partitioned disk I
don't think BIOSes load anything from any partition.

> Hence, a time consuming comparison can be
> skipped by evaluating the bootable flags of all drives,
> only.

*Drives* don't have bootable flags. Maybe you mean the partitions on
the drives.

> The first match -should- be the boot partition...

If you mean to scan drives in order and the first one with a bootable
partition should be the one chosen, maybe. I don't know if we can
depend on the BIOS using the same order for numbering as it does for
booting, though, so this may not work in all cases.

This may be a moot point anyway. If DL can be used to identify to MBR
code which disk it was loaded from none of the complex identification
options are necessary.

James

James Harris

unread,
Mar 31, 2012, 3:46:46 AM3/31/12
to
On Mar 26, 4:21 am, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
wrote:
> "James Harris" <james.harri...@googlemail.com> wrote in message

...

> > So, does anyone know how the BIOS identifies that only the last disk
> > should be booted? I can guess but it would only be a guess....
>
> Each partition record starts with a single byte boot indicator, 80h for
> bootable, 00h for not.  The 80h boot flag should be at locations: 1BEh,
> 1CEh, 1DEh, or 1EEh.

This is interesting as it seems to be different from Wolfgang's
opinion on what the BIOS looks for.

...

> There are only two 80h's in the partition table regions, one for sdg and one
> for sdc.  So, you only have two potentially bootable partitions.  The 80h
> for sdc is not in the correct location (1DAh).  It's not a boot flag.  The
> 80h for sdg is in the correct location (1BEh). It is a boot flag.  1BEh
> location is for partition #1.  So, partition #1 of sdc is bootable.  It's
> probably called sdc1.  So, of all the partitions you posted, it seems there
> is only one partition marked bootable.  Confused.  Did I miss something?

An 0x80 anywhere in the boot sector apart from at the start of a
partition table entry has to be completely irrelevant. The bootable
one is sdg. Other than that, I fully agree.

>
> This appears to be for Linux.  The BIOS probably has a boot list.  It'll
> attempt to boot those devices.  After that, you probably have Grub or LILO
> installed which should have a script to specify which partition to boot.

Yes. In fact, if I just show the partition table it is easier to read.

$ sudo dd 2>/dev/null bs=1 skip=446 count=66 if=/dev/sdg | hd -v
0000 80 01 01 00 83 fe ff ff 3f 00 00 00 b6 53 43 73
0010 00 fe ff ff 05 fe ff ff f5 53 43 73 cc 05 2d 01
0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


> Do you have Linux fdisk installed?  If so, there is an option, perhaps -l,
> to fdisk that lists all found partitions.

Good suggestion.

James

James Harris

unread,
Mar 31, 2012, 4:02:49 AM3/31/12
to
On Mar 26, 12:06 pm, "wolfgang kern" <nowh...@never.at> wrote:
> James Harris asked why BIOS boots only sdg:
> ...
>
> > So, does anyone know how the BIOS identifies that only the last disk
> > should be booted? I can guess but it would only be a guess....
>
> I think it got really nothing to do with partition-entries,
> perhaps because your MBRs in sda,sdc,sdd contain zeros at start ?

Interesting. Rod suggested that it was partition entries. That was my
guess too: to boot from a hard disk BIOS looks for the first boot
sector which has 0x55, 0xaa at the end and a partition with the boot
flag set. But it was just a guess. I cannot find any doc to confirm.

The zeroes at the start issue could also be right but are you thinking
of the FAT specification? IIRC it stipulates that the boot sector of a
FAT volume should start with one of two forms or jump instruction. A
FAT volume is very different from a partitioned disk even though the
initial sectors should both end in 0x55, 0xaa.

> I remember to once read that the first (two or 3) bytes of MBR0 were checked
> to be in a certain range (IIRC F6>0  >5 ?) in addition to 55-AA.

It may apply to the MBR too but could you be thinking of the FAT
layout spec?

...

> Thanks for posting a detailed image of a GRUB-MBR, looks like it put
> garbage into the initial data-fields, ... to fool other tools ? :)
>
> Just for fun and as a distraction from daily stress, I analysed what
> and how it does. And if my interpretation isn't totally wrong then
> your Linux-part is almost 1 TB large while the remaining space is
> just ~9.4 GB ?

Yes, it's a 1Tbyte drive. You posted an impressively-detailed
breakdown (mainly snipped). I think there are various disassemblies of
Grub boot sectors out there on the internet.

...

> 1be 80 01 01 00 83 fe ff ff(0000003f)(734353b6) ;Loonix
> 1ce 00 fe ff ff 05 fe ff ff(734353f5)(012d05cc) ;extension

Right. The extension (partition type 0x05) holds a swap partition.

James

James Harris

unread,
Mar 31, 2012, 4:26:53 AM3/31/12
to
On Mar 4, 4:07 am, "Benjamin David Lunt" <zf...@fysnet.net> wrote:

...

> Imagine what the "Trojan" and "Hacker" communities have
> done with this exact question? :-)  Boot another physical disk,
> load a virtual system, then boot the "normal" disk letting the
> Guest think it has full control. :-)

As the OS startup runs in privileged mode it can and should clear out
and initialise everything so anything else which has already loaded
itself into memory or hooked interrupt vectors or stored values in the
BDA becomes irrelevant.

Running in a full VM environment is harder to reliably detect but
there must be some ways, possibly involving timing if nothing else.

In any case, an OS can be run in a full VM within an existing
operating system. It doesn't need manipulation of the boot process
such as you mention above. If it is important not to run in a VM for
some reason then the code to detect the VM is necessary whether the OS
is booted as you suggest or is booted in a VM which runs under an
existing OS.

> Anyway, Rod gave some good pointers, especially Appendix D in
> the specs he mentioned.
>
> My question, which includes the 4-byte signature at offset 440
> in the MBR, is how to identify the booted partition?

Why not do the following?

1. In the MBR code use DL to identify the boot disk.
2. Pass this value to the partition's boot sector also in DL.
3. In the partition's boot sector use DL and look for the first
partition on that disk which is marked as bootable.

James

James Harris

unread,
Mar 31, 2012, 4:57:44 AM3/31/12
to
On Mar 5, 9:13 am, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
wrote:
> "Benjamin David Lunt" <zf...@fysnet.net> wrote in messagenews:jj0gde$crb$1...@speranza.aioe.org...
>
> > [...] lets say that I only have two options to boot from,
> > two platter disk devices.  The list that the BIOS allows me to
> > pick from only has these two options.  Each device has a
> > partition table with one partition and it is marked active/
> > bootable.  Again, *each* device has a partition marked bootable.
>
> ... re-ordered the text ...
>
> > [..] However, my question/comment was, how does the OS
> > know which partition on which device was booted.
>
> 0) can we assume that a partitioned device was booted?

AIUI, No. The code that is booted is one sector long and has to
contain within itself most of the info it needs. One of the few things
that is passed in is the id of the drive it came from. It receives
this in DL.

For a hard disk the boot sector traditionally contains a partition
table but that is only a convention. It does not have to be a
partitioned disk at all. Once it has verified that the disk is
bootable BIOS just loads the first sector. Period. While standard
tools work with the standard partition scheme different/custom tools
could be used and the disk could be laid out in any way. The only
issue, ISTM, is how to persuade the BIOS that the first sector of a
given hard disk is bootable.

I remember a post by Mike Gonta where he showed that for most media
(floppies, flash, CD etc) the BIOS will boot it.... In fact, here it
is:

http://groups.google.com/group/alt.os.assembly/msg/7c47c42013f6696d

The one thing that is missing is the hard disk. From what I have seen
the BIOS is more selective when choosing which hard disk to boot from,
using some means to identify whether the initial sector is bootable or
not.

> 1) if so, can we establish that only one partition per device can be marked
> bootable?

Again, only by convention. There's nothing to stop a utility marking
more than one partition as bootable.

> 2) if not, can we establish that only the first bootable partition on a
> device will be booted by BIOS?

I don't believe the BIOS will boot any partition. AIUI it only loads
the first sector of the disk and hands over responsibility to the
loaded sector assuming that the sector starts with executable code. If
that sector is an MBR with an embedded partition table it is then the
responsibility of the MBR code to carry out the next step such as
booting the appropriate partition.

> 3) if not, what is causing one of the other bootable partitions on a device
> to boot?  ... software or BIOS selection or BBS menu ...

You mean if more than one partition is marked bootable? I've never
seen any rules for which one is chosen but ISTM it must be the choice
of the boot sector what to do next, not the BIOS.

I've been putting off trying to work out how hard disk boot differs
from floppy boot for some time. Thanks to this discussion the picture
is getting clearer.

James

James Harris

unread,
Apr 1, 2012, 5:37:16 PM4/1/12
to
On Mar 26, 12:06 pm, "wolfgang kern" <nowh...@never.at> wrote:
> James Harris asked why BIOS boots only sdg:
> ...
>
> > So, does anyone know how the BIOS identifies that only the last disk
> > should be booted? I can guess but it would only be a guess....
>
> I think it got really nothing to do with partition-entries,
> perhaps because your MBRs in sda,sdc,sdd contain zeros at start ?
>
> I remember to once read that the first (two or 3) bytes of MBR0 were checked
> to be in a certain range (IIRC F6>0  >5 ?) in addition to 55-AA.

Good call - it seems that at least one BIOS checks pretty much as you
mention except that the first byte of the sector can be any value
other than zero. I've posted the info in another thread.

James

Bernhard Schornak

unread,
Apr 3, 2012, 4:16:45 AM4/3/12
to
Lack of knowledge... Might be of interest while creating my
boot manager. Thanks for the information!


>> Most BIOS'es load the first detected bootable partition
>> and start it.
>
> Well, they load the first bootable *bootsector* and start it (though
> how they identify whether an initial sector is bootable or not is the
> principal subject of this thread). With a normally partitioned disk I
> don't think BIOSes load anything from any partition.


Why should the BIOS read data from a partition?


>> Hence, a time consuming comparison can be
>> skipped by evaluating the bootable flags of all drives,
>> only.
>
> *Drives* don't have bootable flags. Maybe you mean the partitions on
> the drives.


Drives -should- have a partition table at sector 1, head 0,
cylinder 0...


>> The first match -should- be the boot partition...
>
> If you mean to scan drives in order and the first one with a bootable
> partition should be the one chosen, maybe. I don't know if we can
> depend on the BIOS using the same order for numbering as it does for
> booting, though, so this may not work in all cases.


Then you probably misunderstood. What I really meant was to
read all partition tables, then scan the retrieved data for
a match with the started partition table in memory. This is
superfluous if the BIOS passes the drive number in DL at no
cost.


> This may be a moot point anyway. If DL can be used to identify to MBR
> code which disk it was loaded from none of the complex identification
> options are necessary.


Agreed. If something is for free - take it! ;)

Rod Pemberton

unread,
Apr 3, 2012, 4:39:28 AM4/3/12
to
"James Harris" <james.h...@gmail.com> wrote in message
news:20a3a338-d7c3-4a18...@o4g2000yqb.googlegroups.com...
> On Mar 26, 4:21 am, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
> wrote:
> > "James Harris" <james.harri...@googlemail.com> wrote in message
...

> > There are only two 80h's in the partition table regions, one for sdg and
> > one for sdc. So, you only have two potentially bootable partitions. The
> > 80h for sdc is not in the correct location (1DAh). It's not a boot flag.
> > The 80h for sdg is in the correct location (1BEh). It is a boot flag.
> > 1BEh location is for partition #1. So, partition #1 of sdc is bootable.
> > It's probably called sdc1. So, of all the partitions you posted, it
> > seems there is only one partition marked bootable.
> > Confused. Did I miss something?
>
> An 0x80 anywhere in the boot sector apart from at the start of a
> partition table entry has to be completely irrelevant.

We were looking at an unprocessed hex dump of multiple devices that you
posted. So, we had no choice but to either a) consider all 80h's as
possible boot flags or b) undump the data and pass it to a program that
could explain what it means ...

> The bootable one is sdg. Other than that, I fully agree.

Other than "the bootable one being sdg", you fully agree ... ? I said sdg
was bootable ... Sorry, the latter "sdc" (and "sdc1") should've been "sdg"
(and "sdg1") as in the first part of my response.

Your recent confusing reply aside, my original confusion of you asking
remains. What was the point of you posting about multiple bootable
partitions and the server always finding the correct one to boot from if
only one partition was actually bootable? Shouldn't you have set at least
one bootable partition on each of the drives in the system and then checked
if that server finds the correct one everytime?


Rod Pemberton





Rod Pemberton

unread,
Apr 3, 2012, 4:39:51 AM4/3/12
to
"James Harris" <james.h...@gmail.com> wrote in message
news:f02bfd7a-7e27-44b3...@v1g2000yqm.googlegroups.com...
> On Mar 5, 9:13 am, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
> wrote:
> > "Benjamin David Lunt" <zf...@fysnet.net> wrote in
> messagenews:jj0gde$crb$1...@speranza.aioe.org...
>
> > [...] lets say that I only have two options to boot from,
> > two platter disk devices. The list that the BIOS allows me to
> > pick from only has these two options. Each device has a
> > partition table with one partition and it is marked active/
> > bootable. Again, *each* device has a partition marked bootable.
...

> > > [..] However, my question/comment was, how does the OS
> > > know which partition on which device was booted.
>
> > 0) can we assume that a partitioned device was booted?
>
> AIUI, No.

No? Then, why did you ask the question about "which partition on which
device was booted"? You explicitly stated that "each device has a partition
table with one partition and it is marked active/bootable."

> The code that is booted is one sector long and has to
> contain within itself most of the info it needs. One of the few things
> that is passed in is the id of the drive it came from. It receives
> this in DL.

This is the master boot code. A partition has it's own boot code.

> For a hard disk the boot sector traditionally contains a partition
> table but that is only a convention. It does not have to be a
> partitioned disk at all.

> Once it has verified that the disk is bootable BIOS just loads the
> first sector. Period.

Yes, the BIOS transfers execution to a valid boot sector.

> The only issue, ISTM, is how to persuade the BIOS that the first
> sector of a given hard disk is bootable.

Huh ... ?

It needs to have an 0xAA55 signature in order for the BIOS POST to validate
the sector as bootable for fixed media. The IBM PS/2 tech. ref. documents
require that signature for fixed media, video BIOS, etc. but not for
floppies. This is also in one of the links I posted which apparently were
to your clone and not you ... ;-)

> I remember a post by Mike Gonta where he showed that for most media
> (floppies, flash, CD etc) the BIOS will boot it....

Those are all removable media. Removable media only needs valid code at the
start, like a floppy, but they can have 0xAA55 signature and partitions too.

> The one thing that is missing is the hard disk. From what I have seen
> the BIOS is more selective when choosing which hard disk to boot from,
> using some means to identify whether the initial sector is bootable or
> not.
...

> > 2) if not, can we establish that only the first bootable partition on a
> > device will be booted by BIOS?
>
> I don't believe the BIOS will boot any partition.

True. "by BIOS" shouldn't have been placed there by me. Sorry.

But, you seem to be going around in circles. You asked which partition was
booted by the OS, implying that the filesystem in question uses partitions
and previously stating that it had them marked as active, and then you fall
back to pedantic literal understanding of what the BIOS does when issues of
booting a partition come up.

> AIUI it only loads the first sector of the disk and hands over
> responsibility to the loaded sector assuming that the sector
> starts with executable code. If that sector is an MBR with an
> embedded partition table it is then the responsibility of the
> MBR code to carry out the next step such as booting the
> appropriate partition.

Yes.


Rod Pemberton




Rod Pemberton

unread,
Apr 3, 2012, 4:41:23 AM4/3/12
to
"James Harris" <james.h...@gmail.com> wrote in message
news:8c64f688-5f55-4258...@p13g2000yqd.googlegroups.com...
On Mar 26, 12:06 pm, "wolfgang kern" <nowh...@never.at> wrote:
> > James Harris asked why BIOS boots only sdg:
>
> Interesting. Rod suggested that it was partition entries.

If there are no active partition entries, the MBR code won't or shouldn't
attempt to boot a partition. If there is an active partition, the MBR code
should attempt to boot the PBR code. The MBR probably selects the first
bootable partition entry it finds. It should only succeed in booting if
there is a partition for that partition entry and that partition has been
made bootable via installing PBR code. If you set a partition entry to
bootable for a invalid partition, then the MBR shouldn't boot it. If you
set a partition entry to bootable for a valid partition but that partition
doesn't have PBR code, the MBR shouldn't boot it.

So, for a normal setup using a partition table, to boot your OS - which was
what your original question was about and not what the BIOS does - you need:

a) an MBR with 0xAA55, supposedly, only on devices 80h or 0h
b) partition table with one partition marked active
c) the active partition must be a valid partition, e.g., valid partition
entry and formatted
d) PBR code installed to boot the partition

> That was my guess too: to boot from a hard disk BIOS
> looks for the first boot sector which has 0x55, 0xaa at
> the end and a partition with the boot flag set. But it was just
> a guess. I cannot find any doc to confirm.

As you've learned, the booting the MBR and booting the PBR are done together
and yet are separate.

Now, let's get to your core questions:

Does an MBR need to have partitions? I don't know. That's probably still a
solid: "No, it doesn't." Why? It's not something under control of the BIOS
once the BIOS loads and executes the MBR. Technically, that just needs
device 80h/0h and 0xAA55 signature. However, some BIOS could check for a
valid partition prior to accepting an MBR as bootable whether it should or
not. It's just about as easy as checking for 0xAA55.

Is there a standard which specifies partitions as part of the MBR as we're
accustomed to them? I don't know. It's probably de-facto IBM or MS-DOS
based or maybe even de-facto CP/M ...


I've only found two references to a "partition" in the standards documents
that I've got as pdf's:

1) ATA spec. #1 refers to the partition table as the "operating system
partition table".

2) ATA/ATAPI spec. #8 says it's standard for the first partition to start at
LBA 63, and provides a diagram of a "typical" legacy MBR and partition
setup which happen to be FAT based.


If information on partitions is in the IBM PS/2 tech. ref., I haven't
stumbled across it yet, but it's a image scan ...


Rod Pemberton




James Harris

unread,
Apr 4, 2012, 1:18:35 PM4/4/12
to
On Apr 3, 9:16 am, Bernhard Schornak <schor...@web.de> wrote:
> James Harris wrote:
> > On Mar 25, 9:26 pm, Bernhard Schornak<schor...@web.de>  wrote:

...

> Lack of knowledge... Might be of interest while creating my
> boot manager. Thanks for the information!

You're welcome. This thread has been a big help to me too.

> >> Most BIOS'es load the first detected bootable partition
> >> and start it.
>
> > Well, they load the first bootable *bootsector* and start it (though
> > how they identify whether an initial sector is bootable or not is the
> > principal subject of this thread). With a normally partitioned disk I
> > don't think BIOSes load anything from any partition.
>
> Why should the BIOS read data from a partition?

You tell me. It was your comment! :-)

James

James Harris

unread,
Apr 4, 2012, 1:59:00 PM4/4/12
to
On Apr 3, 9:39 am, "Rod Pemberton" <do_not_h...@notemailnot.cmm>
wrote:
> "James Harris" <james.harri...@gmail.com> wrote in message
> On Mar 5, 9:13 am, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
> > > "Benjamin David Lunt" <zf...@fysnet.net> wrote in

...

> > > > [..] However, my question/comment was, how does the OS
> > > > know which partition on which device was booted.
>
> > > 0) can we assume that a partitioned device was booted?
>
> > AIUI, No.
>
> No?  Then, why did you ask the question about "which partition on which
> device was booted"?  You explicitly stated that "each device has a partition
> table with one partition and it is marked active/bootable."

I don't think I did. Are you mixing me up with Ben?

> > The code that is booted is one sector long and has to
> > contain within itself most of the info it needs. One of the few things
> > that is passed in is the id of the drive it came from. It receives
> > this in DL.
>
> This is the master boot code.  A partition has it's own boot code.

Yes.

> > For a hard disk the boot sector traditionally contains a partition
> > table but that is only a convention. It does not have to be a
> > partitioned disk at all.
> > Once it has verified that the disk is bootable BIOS just loads the
> > first sector. Period.
>
> Yes, the BIOS transfers execution to a valid boot sector.
>
> > The only issue, ISTM, is how to persuade the BIOS that the first
> > sector of a given hard disk is bootable.
>
> Huh ... ?
>
> It needs to have an 0xAA55 signature in order for the BIOS POST to validate
> the sector as bootable for fixed media.  The IBM PS/2 tech. ref. documents
> require that signature for fixed media, video BIOS, etc. but not for
> floppies.  This is also in one of the links I posted which apparently were
> to your clone and not you ...  ;-)

As I wrote recently in a separate thread, 0x55, 0xaa at the end of the
MBR is NOT always enough for BIOSes to boot an MBR. It was at one
time, I know, but that does not appear to have remained the case.

...

> > > 2) if not, can we establish that only the first bootable partition on a
> > > device will be booted by BIOS?
>
> > I don't believe the BIOS will boot any partition.
>
> True.  "by BIOS" shouldn't have been placed there by me.  Sorry.
>
> But, you seem to be going around in circles.  You asked which partition was
> booted by the OS, implying that the filesystem in question uses partitions
> and previously stating that it had them marked as active, and then you fall
> back to pedantic literal understanding of what the BIOS does when issues of
> booting a partition come up.

Me pedantic? Phrases involving the pot calling the kettle come to
mind. :-)

Again, are you mixing me up with someone else?

James

James Harris

unread,
Apr 4, 2012, 2:16:19 PM4/4/12
to
On Apr 3, 9:39 am, "Rod Pemberton" <do_not_h...@notemailnot.cmm>
wrote:
> "James Harris" <james.harri...@gmail.com> wrote in message
> On Mar 26, 4:21 am, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
> > > "James Harris" <james.harri...@googlemail.com> wrote in message
>
> ...
>
> > > There are only two 80h's in the partition table regions, one for sdg and
> > > one for sdc. So, you only have two potentially bootable partitions. The
> > > 80h for sdc is not in the correct location (1DAh). It's not a boot flag.
> > > The 80h for sdg is in the correct location (1BEh). It is a boot flag.
> > > 1BEh location is for partition #1. So, partition #1 of sdc is bootable.
> > > It's probably called sdc1. So, of all the partitions you posted, it
> > > seems there is only one partition marked bootable.
> > > Confused. Did I miss something?
>
> > An 0x80 anywhere in the boot sector apart from at the start of a
> > partition table entry has to be completely irrelevant.
>
> We were looking at an unprocessed hex dump of multiple devices that you
> posted.  So, we had no choice but to either a) consider all 80h's as
> possible boot flags or b) undump the data and pass it to a program that
> could explain what it means ...

Byte offsets were included.

> > The bootable one is sdg. Other than that, I fully agree.
>
> Other than "the bootable one being sdg", you fully agree ... ?  I said sdg
> was bootable ...  Sorry, the latter "sdc" (and "sdc1") should've been "sdg"
> (and "sdg1") as in the first part of my response.

No worries.

> Your recent confusing reply aside, my original confusion of you asking
> remains.  What was the point of you posting about multiple bootable
> partitions and the server always finding the correct one to boot from if
> only one partition was actually bootable?  Shouldn't you have set at least
> one bootable partition on each of the drives in the system and then checked
> if that server finds the correct one everytime?

Well, this was a live server, not a test box and I wasn't too keen on
changing hard disk boot sectors unless I knew what I was doing.
Nevertheless, having worked out enough to be confident of doing just
that it turned out to be nothing to do with the boot flag. As
subsequently posted in the thread "Info on which initial sectors a
BIOS will boot" in addition to checking for 0x55 and 0xaa at the end
the BIOS in that machine did not depend on the partition table or boot
flag at all but on whether the first byte was zero or nonzero.

James

James Harris

unread,
Apr 4, 2012, 2:48:32 PM4/4/12
to
On Apr 3, 9:41 am, "Rod Pemberton" <do_not_h...@notemailnot.cmm>
wrote:

...

> So, for a normal setup using a partition table, to boot your OS - which was
> what your original question was about and not what the BIOS does - you need:

This is simply untrue, Rod. The original question was purely and
simply about the BIOS and which disk it would boot, nothing at all
about partitions. The entire original question was:

JH> When a machine has multiple hard disks which could be booted is
there
JH> a standard way that a BIOS will chose which one to start the OS
from?
JH> Will it do things like keeping a note of which one it booted last
time
JH> and use that?
JH> Is there anything that an OS writer can do to influence the
choice?

Also, I wasn't asking for help in booting my OS. The question was a
more general request for information.

...

> As you've learned, the booting the MBR and booting the PBR are done together
> and yet are separate.

I've learned that the BIOS boots the MBR. After that everything is in
the control of the MBR.

James

Rod Pemberton

unread,
Apr 5, 2012, 8:49:48 AM4/5/12
to
"James Harris" <james.h...@gmail.com> wrote in message
news:7d63c253-9505-427f...@f37g2000yqc.googlegroups.com...
...

> > No? Then, why did you ask the question about "which partition on which
> > device was booted"? You explicitly stated that "each device has a
> > partition table with one partition and it is marked active/bootable."
>
> I don't think I did. Are you mixing me up with Ben?

Yes, I did. Sorry, not sure why.


RP


0 new messages