news:4acfa01c-2ccd-4dd4...@v1g2000yqm.googlegroups.com...
> On Apr 9, 2:12 am, "Rod Pemberton" <do_not_h...@notemailnot.cmm>
> wrote:
...
> > But, just whom is going to code a boot sector for an OS without
> > including the ability to partition the drive?
>
> I might be wrong but this sounds like you are mixing up two things
> when you talk of "a boot sector for an OS" or you might have just
> chosen not to specify.
No.
> On a hard disk there are at least two types of
> bootable sectors.
There can be one or two sectors (or many more) which get executed. The MBR
and PBR are typical. Due to size constraints, far more sectors are likely.
> As you know, the first is at the beginning of the
> disk, i.e. in LBA 0, and is what the BIOS starts for us.
Yes.
> Under a normal partitioning scheme the second, AIUI at the
> moment, is the first sector of a partition. Is that correct?
Yes.
> This latter sector is what ultimately gets started by an MBR.
Yes.
> If we designate the bootsector of the partition the VBR
> (volume boot record) using the term used in various
> articles on Wikipedia the traditional sequence is
>
> BIOS --> MBR --> VBR --> OS
Yes, that's how booting works. It boots an OS.
I was using PBR (partition boot record) as VBR, whatever the V is for ...
> Of the two the VBR sounds more like the your term
> "boot sector for an OS" as it starts the OS loading process
> but I can't see what that has to do with your comment.
No, I was referring to the MBR when used in the sequence "BIOS --> MBR -->
VBR --> OS" versus "BIOS --> MBR --> OS". The MBR in the sequence "BIOS -->
MBR --> OS" has no partition entries. The MBR in the sequence "BIOS -->
MBR --> VBR --> OS" is (most likely) a multiple partition entry boot sector.
The MBR for that sequence typically has four partition entries. I.e., there
can be four VBR boot sectors each of which could be startable. I was asking
why anyone would implement "BIOS --> MBR --> OS" instead of "BIOS -->
MBR --> VBR --> OS". As stated before, "BIOS --> MBR" is not booting. No
OS is started, although you can run code.
> What the MBR code does once booted is off the original topic. The
> first question had to be about what was needed in the first sector of
> a hard disk for the BIOS to consider it bootable (executable, if you
> like).
>
> An OS developer can control what is on the hard disk including what
> is in the bootsector.
No, whomever has access to the PC while unprotected can control what is in
the bootsector ... If you were to let me use your computers while
unprotected, I can overwrite them, from MS-DOS, from Linux, and probably
from at least a few Windows versions. :) I've not tried with newer
Windows. I seem to recall NTFS was a PIA some years ago though ...
If I can get the machine to boot what I want it to boot by any means (and I
was malicious), your bootsector is gone. The OS developer can only control
what *should be* written there from the OS developer's perspective of
booting their OS. They can't prohibit changes since they don't actually
*own* and *control* the machine.
> The same cannot be said of the BIOS settings.
Yes, I can. Whomever has access to the PC's BIOS while unprotected can
change said settings ... If you were to let me use your computers while
unprotected, I can change them too. :)
> If we don't use either a prebuilt MBR or a prebuilt boot manager
> the choices the BIOS makes here determine what is required to
> give us the initial control that is needed.
"choices the BIOS" ... "choices the BIOS and the user" ...
Don't forget that the user can change the BIOS if not locked, select an
alternate boot device via BBS pop-up if allowed and available, and can
change cabling if the case is not protected via mechanical means or BIOS
case open/closed switch.
> Hence, the boot sector is of interest and worth understanding.
AISI, almost no one is going to code an MBR via happenstance to start with
the few bytes that could be interpreted by the BIOS as blank or unformatted.
So, if you include the 0xAA55 signature for fixed media and valid opcodes at
the sector start, what is the issue? It seems nearly impossible to produce
an MBR that won't execute when attempting to make one that does.
> What happens next is another decision and one that is made
> by the code in the bootsector. Sure, I'd be interested in partitions
> at that point.
Ok.
> > AIUI, BIOS interrupts are not capable of accessing
> > the entire capacity of drives anymore, i.e., you need at least two
> > partitions: BIOS accessible for recovery, and the other.
>
> True, the traditional BIOS calls cannot access the entire capacity of
> all drives any more but you don't necessarily need two partitions. The
> key seems to be where a bootable partition starts and where the OS
> code is in that partition.
True, but usually, the only OS files guaranteed to be written to specific
disk locations are the MBR and PBR and filesystem control structures,
depending on the filesystem. Some filesystems, like MS-DOS with FAT, used
low tracks alot. However, other filesystems, like CBM with CBM-DOS (non-x86
PC), avoided low tracks. Because the low tracks were frequently bad on
removable media, like 5 1/4" floppies, MS-DOS had lots of problems with data
loss and non-bootable disks versus other OSes of that era. 3 1/2" disks
basically "saved" x86 PCs. I.e., while it's likely the OS was installed
"low" since it's the first thing installed to a partition, there is no
guarantee it will be installed in accessible sectors. DOS wrote
COMMAND.COM
and IO.SYS low via SYS.com, but AFAIK, Linux and Windows don't write OS code
to specific sectors ... Also, some OSes have utilities which attempt to
access the entire partitions, e.g., DOS' fdisk, Linux fsck, etc. They could
crash or corrupt (track wrap around). Who knows ... IMO, it's better to
terminate the initial partition within the boundaries (and make it a FAT
partition too - lots of DOS utilities.).
> If the MBR tries to load the volume boot record using CHS addressing
> the VBR and essential OS code must lie in the first 8Gby (33 bits of
> address: 24 in partition table entry and 9 from the size of a sector)
> as that is all that a 3-byte CHS value as stored in the partition
> table can reach to.
There is not just the 8GB limit but also the 528MB limit. The Phoenix EDD
specification and one of Hale Landis' webpages might be worth a look.
http://ata-atapi.com/hiwchs.html
> If the MBR tries to use LBA addressing it has a much larger limit but
> a limit nonetheless.
True, AIUI, there is a 28-bit LBA limit and a 48-bit LBA limit.
> It is restricted to the first 2Tby (32-bits from
> the partition table entry and 9 from the sector size
> making 41 in total).
I haven't looked into a partition entry's format, but that doesn't sound
correct to me. AIR, LBA is either 28-bit's (ATA-2 or later) or 48-bit's
(ATA/ATAPI-6 or later) total of 512KB sectors.
> So if you had a 3Tby disk and wanted to place the boot
> partition near the end then its start address could not be
> expressed in a partition table entry.
Yes.
> Both of these methods (CHS and LBA) should be OK, though, to load a
> volume boot record that starts at the beginning of the disk - and the
Well, you've skipped over quite a few other BIOS disk size limitations.
It's probably correct for recent machines.
> VBR can load an OS from the beginning of the partition - no matter how
> big the disk or the partition is.
As long as it's entirely at the beginning ... Disk optimizers, the file
system, file system verifiers, journaling, etc could move just one sector,
and it's all over, if you need to recover.
> Of course, the VBR has to use the BIOS to load at least enough of the
> OS to include the disk drivers so that/those would need to be within
> the range of BIOS calls.
"the VBR" ... "whatever code is executing after the BIOS transfers
execution" ...
You said yourself it could be the MBR. Whatever is executing, could use
BIOS to load alot of sectors from wherever it wants as long as the BIOS
supports it. If the MBR sector just went into a loop and did little else,
you could overload memory ...
At a minimum, you've got from just above 0x7C00 to 512KB that can be loaded
in RM, about 480KB. You've got from 512KB to 640KB on all but the earliest
x86 PCs, another 128KB for 608KB. You've also got 0x400 to 0x7C00, if
you're adventurous. You've got 0x0 to 0x400, if you relocate the IDT.
You've also got various blocks of video RAM from 0xA0000 to 0xE0000, if
you're still adventurous. You've also got from 0x100000 to 0x10FFEF, if you
enable A20. Once your OS is larger than 640KB or 1MB or 1MB+64KB, which is
"huge" for a basic OS, then you can worry about loading your OS above 1MB or
the A20 range.
Rod Pemberton