FAT32 File System

Source: Internet
Author: User
Tags reserved

First Sector

The first sector is 512 bytes, the MBR area is 446 bytes, the other 64 bytes are 4 partitioned tables, each partition table occupies 16 bytes, and the last two bytes are 55 and AA.
The number of reserved sectors that follow is determined by the four bytes of 0x1c6 that are started in the MBR table. DBR

BDR (Dos boot Recoder-dos boot record) sector, DBR records the file system starting position, size, fat table number and size, and other related information.
"1" 0x00~0x02:3 byte, jump instruction.
"2" 0x03~0x0a:8 Byte, File system flag and version number, here for MSDOC5.0.
"3" 0x0b~0x0c:2 byte, number of bytes per sector, 0X02 00.
"4" 0x0d~0x0d:1 bytes, number of sectors per cluster, 8 (0x08).
"5" 0x0e~0x0f:2 Byte, the number of reserved sectors, 0x00 26, in line with the FAT1 starting address is 38 sectors.
"6" 0x10~0x10:1 byte, Fat table number, 2.
"7" 0x11~0x12:2 byte, FAT32 must equal the number of 0,fat12/fat16 as the directory in the root directory;
"8" 0x13~0x14:2 byte, FAT32 must be equal to 0,fat12/fat16 total number of sectors.
"9" 0x15~0x15:1 byte, which storage medium, 0xf8 standard value, Removable Storage medium, commonly used 0xF0.
"10" 0x16~0x17:2 Byte, FAT32 must be 0,fat12/fat16 as the number of sectors that a fat table occupies.
"11" 0x18~0x19:2 byte, number of sectors per track, valid only for storage media with "special shape" (which is divided into several tracks by the head and cylinder) (0x00 3F).
"12" 0x1a~0x1b:2 byte, the number of heads, only for special media is valid, 255 (0x00 FF).
"13" 0x1c~0x1f:4 bytes, EBR the number of sectors hidden before the partition, 8192 (0x00 00 20 00), equal to the 4 byte values starting with address 0x1c6 in the MBR.
"14" 0x20~0x23:4 Byte, File system Total sector number, 7736320 (0x 0C 00), 7736320 * 512 = 3960995840≈3.67GB.
"15" 0x24~0x27:4 byte, each fat table occupies the number of sectors, 7541 (0x 1D 75).
"16" 0x28~0x29:2 byte, tag, this domain FAT32 unique.
"17" 0x2a~0x2b:2 Byte, FAT32 version number 0.0,fat32 unique.
"18" 0x2c~0x2f:4 byte, the cluster number of the first cluster in the root directory, 2. (Although the root directory can be located anywhere in the data area under the FAT32 file system, it usually starts at cluster 2nd)
"19" 0x30~0x31:2 Byte, fsinfo (file System Information sector) sector area code 1, which provides the operating system with information about the total number of empty clusters and the next available cluster.
"20" 0x32~0x33:2 Byte, back up the location of the boot sector. The backup boot sector is always located in the 6th sector of the file system.
"21" 0x34~0x3f:12 byte, used for later fat expansion.
"22" 0x40~0x40:1 Byte, same as FAT12/16 definition, except that both are in the boot sector
The same place.
"23" 0x41~0x41:1 Byte, same as FAT12/16 definition, except that both are in the boot sector
The same place.
"24" 0x42~0x42:1 byte, extended boot flag, 0x29. Same as the FAT12/16 definition, except that they are located in different locations in the boot sector.
"25" 0x43~0x46:4 Byte, Volume serial number. is usually a random value.
"26" 0x47~0x51:11 Byte, Volume label (ASCII code), if the file system is established when the label is specified, will be saved here.
"27" 0x52~0x59:8 Byte, file system format ASCII code, FAT32.
"28" 0x5a~0x1fd:90~509 a total of 410 bytes, not used. There is no clear use for this part.
"29" 0X1FE~0X1FF: Signature Sign "AA".FAT

Fat (file allocation table), a filesystem typically has two fat tables, and FAT2 is usually used as a backup.
FAT16 does not have a reserved sector, DBR followed by a fat table, and fsinfo after DBR in FAT32, the reserved sector before the fat table, and the number of reserved sectors is determined by DBR 0x0e~0x0f

A. FAT32 table entries, No. 0 and 1th table entries do not correspond to any of the clusters, the FAT32 No. 0 table entry is "f8ffff0f", and the 1th table entry may be used to record dirty flags to show that the file system is not properly unloaded or that there is an error on the disk surface, and normally the value of the 1th table entry is " Ffffffff "or" FFFFFFF0 ".
B. If a cluster is not assigned to use, his corresponding fat table entry content is 0
C. When a cluster has a bad sector, the entire 0XFFFFFFF7 flag is a bad cluster, and the bad cluster is recorded in the corresponding Fat table entry.
D. When you create a new file in the file system, if the new file occupies only one cluster, the FAT table entry for the cluster to which it is assigned will be written to the end flag, and if the new file occupies more than one cluster, write the cluster number of the next cluster in the corresponding FAT table entry for each cluster that it occupies. Writes a closing flag to the FAT table entry for the last cluster.
E. When you create a new directory, the space for which only a cluster is allocated, the corresponding FAT table entry is written to the end flag, and when the directory grows beyond a cluster, it will continue to be assigned a cluster in the free space, and a fat table is established for it in the fat tables to describe the cluster he occupies.
F. root directory immediately after the Fat table, save in the 2nd Fat table entries, "FFFFFFF0"
When looking for a file, first locate the file's starting cluster in a directory entry, and then find the starting cluster location in the Fat table, which in turn knows the location of the next cluster. root directory

The sector in which the directory is located is divided into 32 bytes in one unit, each unit referred to as a directory entry, and each directory entry has a length of 32 bytes. Reference Articles A quick introduction to FAT32 file format in SD card (detailed description)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.