FAT32 file system locates FAT file allocation table and root directory

Source: Internet
Author: User

I,Fat1 start sector = fan ID of DBR + reserved fan ID

1.Obtain the fan ID of DBR

0x1c6 ~ of sector 0 of the Disk ~ 0x1c9 is the starting sector of the first partition, and this sector is DBR

It is the sector 0 of my disk. We can see that the fan area number of DBR is 0x00 00 3f (small-end format)


2.Get reserved slice

Open the DBR sector, offset 0x0e ~ 0x0f indicates that the slice is retained


The figure shows that the number of reserved sectors is 0x00 26.

Fat1 start sector = fan ID of DBR + reserved fan id = 0x3f + 0x26 = 0x65

Open the sector 0x65, which is the starting sector of fat1.


II.Starting sector of fat2

Fat2 is next to fat1, so the starting sector of fat2 = the starting sector of fat1 + the number of sectors of a fat

1. Start sector of fat1

According to the above method, this example is 0x65.

2.Number of sectors of a fat table

Offset from DBR 0x24 ~ 0x27 is obtained. The first graph can tell this example that it is 0x3a79.

Fat2's start sector = fat1's start sector + one fat sector = 0x65 + 0x3a79 = 0x3ade

Open the sector 0x3 Ade, and we can see that fat2 and fat1 are the same.


III,Root directory

In the FAT32 file system, the root directory is no longer hard-fixed and can be stored in any cluster that can be addressable in the partition, however, the root directory is usually the first (formatted to generate) Directory table.

Therefore, we can see that the first cluster in the root directory is close to fat2, which occupies 1st clusters in the cluster order (namely Cluster 2 ).

At the same time, the FAT32 file system regards the root directory as a normal data file. If there is no restriction on the number of directory items, an empty cluster can be allocated as needed to store more directory items.

Root directory start sector = number of reserved sectors + number of sectors for one fat × Number of fat tables + (Starting cluster number-2) X number of sectors for each cluster

1.Number of reserved sectors

Offset from DBR 0x0e ~ 0x65 in this example.

2.Number of sectors of a fat table

Offset from DBR 0x24 ~ 0x27 is obtained. The first graph can tell this example that it is 0x3a79.

3.Fat table count

It is obtained from the offset 0x10 of DBR. the first figure shows that this example is 0x02. Generally, there are two fat tables: fat1 and fat2.

4.Starting cluster number

Offset from DBR 0x2c ~ 0x2f is obtained. The first figure shows that this example is 0x00 00 02.

5.Number of sectors per cluster

The offset 0x0d of DBR is obtained. From the first figure, we can tell that this example is 0x08, and a cluster has eight sectors.

Therefore, the starting sector of the root directory = the number of reserved sectors + the number of fat sectors X 2 + (Starting cluster number-2) x the number of sectors per cluster

= 0x26 + 0x3a79*2 + (0x2-2) * 8 = 0xea0a

Open the slice with the slice number 0xea0a



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.