Boot sector on a hard drive

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
nexos
Member
Member
Posts: 1078
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Boot sector on a hard drive

Post by nexos »

Hello,
I was wondering how you go about implementing a hard drive bootsector with FAT32. How would you put the BIOS parameter block on disk? How do you format it?
Thank you for your help
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Boot sector on a hard drive

Post by PeterX »

nexos wrote:Hello,
I was wondering how you go about implementing a hard drive bootsector with FAT32. How would you put the BIOS parameter block on disk? How do you format it?
Thank you for your help
Why not let your favorite tool (like parted etc.) format the partition. And when you write code to the partition's bootsector, skip the BPB.

Something like this:

Code: Select all

dd if=bb.bin of=/dev/sda1 bs=1 count=3
dd if=bb.bin of=/dev/sda1 bs=1 seek=96 skip=96
Note that I don't guarantee that 96 is correct, because there are several versions of BPB around (with different size).

Greetings
Peter
nexos
Member
Member
Posts: 1078
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Boot sector on a hard drive

Post by nexos »

Ok Thank you! That makes perfect sense.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply