Strange FAT32 curiosity.

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
ATXcs1372
Member
Member
Posts: 30
Joined: Wed Jun 01, 2011 7:14 pm

Strange FAT32 curiosity.

Post by ATXcs1372 »

Whenever I make a new FAT32 image on my system, the geometry seems to be 1119 reserved sectors.... is this normal? The code references the BPB (which my image making utility doesn't fill in, hdiutil for mac) so everything should work on every drive, but that just seems like a high number of reserved sectors to me in this one case.

Any information?
MihailB
Posts: 17
Joined: Thu Sep 08, 2011 7:32 am
Location: Romania
Contact:

Re: Strange FAT32 curiosity.

Post by MihailB »

ATXcs1372 wrote:Whenever I make a new FAT32 image on my system, the geometry seems to be 1119 reserved sectors.... is this normal? The code references the BPB (which my image making utility doesn't fill in, hdiutil for mac) so everything should work on every drive, but that just seems like a high number of reserved sectors to me in this one case.

Any information?
A) Did you mean "whenever I add a new partition to exsiting partitions the number of reserved sectors .... 1119" ?
B) Or you ment "when I'm creating a new image file with a single FAT32 partition the number of reserved sectors is 1119 " ?

If it's B [which is the most probable] then maybe the utility that you've been using is set to do that ... generally there are 32+31 reserved sectors {reserved+hidden} but this is not a rule ...

Code: Select all

Type partition_table Field =1 
   Boot_indicator As ubyte
   Beginning_head_number As ubyte
   Beginning_sector_and_high_cylinder_number As UByte 
   Beginning_low_cylinder_number As UByte 
   System_indicator As UByte 
   Ending_head_number As ubyte 
   Ending_sector_and_high_cylinder_number As ubyte 
   Ending_low_cylinder_number As ubyte
   Number_of_sectors_preceding_the_partition As UInteger 'or LBA start 
   Number_of_sectors_in_the_partition  As UInteger                      'or LBA length
End Type

Type boot_sector Field = 1
        OEM_Identifier(1 To 8) As ubyte 
        BytesPerSector As ushort 
        SectorsPerCluster As UByte
        ReservedSectors As ushort
        NumberOfFATs As ubyte
        RootEntries As ushort
        NumberOfSectors As ushort
        MediaDescriptor As ubyte
        SectorsPerFAT As ushort
        SectorsPerHead As ushort
        HeadsPerCylinder As ushort
        HiddenSectors As UInteger
        BigNumberOfSectors As UInteger
        BigSectorsPerFAT As UInteger
        ExtFlags As UShort
        FSVersion As ushort
        RootDirectoryStart As UInteger
        FSInfoSector As UShort
        BackupBootSector As UShort
End Type

'note : uinteger is DWORD; ushort is WORD; Ubyte is UNSIGNED BYTE
so,
IF the MBR is at sector 0 THEN
partion boot sector [first sector inside the partition] (NOT the mbr boot sector) is @

partition_start = bootsector_sector= partition_table[index].Number_of_sectors_preceding_the_partition + MBR_sector_location
(in our case is MBR is @ absolute 0)
(index is from 0 to 3 : maximum 4 partition)
(MBR boot sector is different then the PARTITION boot sector)

and the FAT starts at absolute sector:
fat_start=partition_start+ boot_sector.ReservedSectors + boot_sector.HiddenSectors
fat2_start=fat_start+boot_sector.BigSectorsPerFat

and the ROOTDIR starts at absolute sector : [for FAT32 partitions only]
rootdir_sector= partition_start+boot_sector.NumberOfFATs*boot_sector.BigSectorsPerFAT


A partition tool is alowed to put setup your partition to what ever values it wishes
[any reserved_sector/hidden_sector ... number]

PS: for extended partition the partition_start reflects the start of the extended partition and the start of the partition inside the extended partition...
Post Reply