1

I have been working with bootloaders and tiny kernels for some time. I found that when using real USB drive, if my bootloader overwrites the partition table and other data of the MBR on target drive, it is not bootable.

But if I use a chainloader and write my bootloader to a partition, it boots up alright. But I read that the drive is bootable if you have 55 and aa at byte 510 and 511, then the drive is bootable. But it is not. I've also heard about other requirements for modern hardware to detect bootable drives, but I don't know any specifics.

I would like to know more about it, and thanks in advance.

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
  • Legacy BIOSes that support USB booting are an unusual beast. Most legacy BIOSes on modern equipment usually support Floppy Disk Drive Emulation (FDD), and Hard Disk Emulation (HDD) to boot USB. Some of these BIOSes are finicky. In general if booting with HDD emulation to be most compatible you need to have a partition table with exactly one partition listed as active. This is on top of having 0xaa55 signature at the end. You won't find this documented in a specification, it is the result of observation by bootloader writers over the years. – Michael Petch May 18 '20 at 02:08
  • If using FDD emulation to boot USB it is generally a very good idea to have a BIOS Parameter Block to avoid some BIOSes blindly writing drive geometry data into memory on top of your bootloader (after being read into memory). This can cause bootloaders to run in aways one didn't expect. – Michael Petch May 18 '20 at 02:09
  • @Michael Petch My system lists the drive as USB Hard disk, and I think(I checked it long time ago) my 'dl' when using bios I/o interrupt is 0x80/81, so I think it's HDD emulation. –  May 18 '20 at 02:15
  • And can you explain 'Bios Parameter Block'? I've seen it a couple times but never understood it.. –  May 18 '20 at 02:16
  • If your BIOS is saying USB Hard Disk and your DL is 0x80 or above then that pretty much says it is HDD boot emulation. Some BIOSes allow you to change USB from FDD to HDD emulation, and I saw one that reads the boot sector to figure out if it sees a partition table. If it sees one it assumes it is HDD emulation. But many BIOSes may do something different. As for the BPB, I have an Answer on SO about FDD (Floppy) USB booting: https://stackoverflow.com/a/47320115/3857942 – Michael Petch May 18 '20 at 02:24
  • Wikipedia has a description of a BIOS Parameter Block here: https://en.wikipedia.org/wiki/BIOS_parameter_block – Michael Petch May 18 '20 at 02:30

0 Answers0