FAT12 Reserved Sectors

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
poted
Posts: 3
Joined: Wed Aug 27, 2008 9:30 am

FAT12 Reserved Sectors

Post by poted »

Hi, I need to make some reserved sectors on a FAT12 formatted floppy to store my second stage bootloader but I can't find any description of how to actually make these reserved sectors. Does anyone know of any tools that can format a floppy leaving reserved sectors? Also I read in a thread on this forum that changing the reserved sectors in the BPB is the way to do it but how does that actually change the layout of the disk and reserve the sectors.
Thanks a lot, Poted.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: FAT12 Reserved Sectors

Post by egos »

In FAT12 the number of reserved sectors is equal to 1, i.e. boot sector only. You can store your second stage boot loader in the file or at the end of the volume excluding it from volume space.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: FAT12 Reserved Sectors

Post by Dex »

You can use this method, if other code plays ball eg: if other code add the [bpbReservedSectors] instead of just adding 1 etc.
You will need to write a formater or mod a format program or use a disk editor (eg: HxD) to move the sector on by the number you add in the bpbReservedSectors .
See here will help: http://dex4u.com/USBboot.htm
NOTE: its for usb, but will work for floppy too.

Also goto here http://home.comcast.net/~dexos/
and get the DexOS format program with source "ForDex.com with source", which you can mod to sute your needs.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: FAT12 Reserved Sectors

Post by AJ »

@OP: For your information, I have used this in the past my self and have also used the floppy disk on Windows without any problems.

Installing the system on to a blank image is simple - just stick your bootloader, along with BPB on to the first x sectors. The FAT and Root will then follow as usual. As dex says - if it's not a blank image, then the other structures need to be moved on manually.

The only word of caution I would give is that you will need to reformat each time your boot loader extends over the next 512b boundary and the first stage will need to know how many sectors to load. For this reason alone, I advocate the use of the file system to store a stage 1.5 boot loader.

Cheers,
Adam
poted
Posts: 3
Joined: Wed Aug 27, 2008 9:30 am

Re: FAT12 Reserved Sectors

Post by poted »

Thanks a lot everyone I managed to change Dex's ForDex formatting program to leave reserved sectors and it's all working great but one weird thing I noticed was that after formatting with it, windows claims that 340kb has been used when it hasn't (as I only made one reserved sector). All i changed in the code was the number which sets where the FATs and root directory are written to (made them one bigger so it leaves one reserved sector) how come windows is saying I have used so much of the disk?
Thanks a lot, Poted.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: FAT12 Reserved Sectors

Post by Dex »

Its possable that windows is just adding one and taking your code as fat ?.
Try do the same, but instead of your code put zero's then see what happens under windows.

PS: That code is by one of DexOS team member's called "roboman"
poted
Posts: 3
Joined: Wed Aug 27, 2008 9:30 am

Re: FAT12 Reserved Sectors

Post by poted »

Thanks for all the help, I've managed to fix it, it was a stupid mistake I'd forgotten to change bpbReservedSectors in my bootloader so as Dex said windows thought that my code was part of the FAT after changing bpbReseveredSectors it all works fine. Thanks you for your help and thank you roboman for writing the formatting utility in the first place.
roboman
Posts: 24
Joined: Fri Feb 27, 2009 9:41 am
Location: USA
Contact:

Re: FAT12 Reserved Sectors

Post by roboman »

Thanks for the comment and I'm glad some one found it of some use.
Post Reply