Hi,
ThisMayWork wrote:I need to do my research, but before that, one more quick question. I believe an MBR looks something like this:
-Bootloader
-Partition 1
-Partition 2
.
.
.
-0x55
-0xAA
Definitely NOT.
An MBR looks like this:
-First sector of boot manager/chain loader code
-Partition 1
-Partition 2
-Partition 3
-Partition 4
-0x55
-0xAA
At an absolute minimum, the boot manager/chain loader code must:
- Relocate itself
- Find the active partition
- Load the first sector of that active partition at 0x7C00
- Set DL to the drive number, and (both) DS:SI and DS:BP to point to the active partition table entry
- Kump to 0x7C00
It may (optionally):
- Display a pretty "boot menu" thing (allowing the user to select which OS to boot), possibly with time-out, etc.
- Do strange shenanigans with partition tables (e.g. to work around the "max. 4 primary partitions" limitation, and for security - e.g. hiding DOS partitions from Linux, etc)
- Do sanity checks, like testing to make sure the first sector of the selected/active partition contains the 0x55,0xAA marker before jumping to it
- Include additional utilities; like tools to create/delete partitions, tools to backup/restore/clone partitions, tools to auto-detect installed OSs, tools to test RAM and/or other hardware, etc.
- Extended boot capabilities; like allowing you to boot completely different disk drives (e.g. able to boot an OS installed on the second hard disk, etc)
The important thing is
none of this has anything to do with any specific OS or any specific OS's boot loader.
An OS's boot sector (which is in the first sector of the OS's main partition, and NOT in the first sector of the a partitioned disk) looks like this:
-First sector of bootloader's code
-Partition table (optional, for "extended partitions")
-0x55
-0xAA
For un-partitioned devices (floppy), the entire device is treated like a partition. There is no MBR in this case.
For USB, when it was first introduced there was no standard for it (unlike CD, where "El Torito" was invented for it). To work around that; a lot of BIOSs try to auto-detect if the device should be treated as a floppy or a hard disk and then try to emulate either a floppy disk ("device 0x00") or a hard disk ("device 0x80"). If the BIOS sees a sane partition table then it assumes it should emulate a hard disk; and if the BIOS doesn't see a sane partition table but does see a sane [url=http://en.wikipedia.org/wiki/BIOS_parameter_block]BPB[url] then it assumes the device should emulate a floppy disk. If the BIOS doesn't see either, then you could end up with anything.
Of course some BIOSs have a "USB emulates floppy or hard disk" setting in their BIOS configuration. Other's don't support "USB emulates floppy" at all. Also, for floppy emulation, most BIOSs don't support "int 0x13 extensions" so you'd be limited to "tiny".
If you add all this up; there's only really one sane alternative that works in almost all the cases: make sure there is a sane partition table and make sure there isn't anything that looks like a BPB (to guarantee that any auto-detection results in the BIOS deciding to emulate a hard disk).
This means that you'd need an MBR and a boot sector (but you're going to need that for booting from hard disk anyway, so...).
Cheers,
Brendan