简体   繁体   中英

How large does the FAT structure and how large is the file?

Consider the following parameters of a FAT based lesystem: Blocks are 8KB (213 bytes) large FAT entries are 32 bits wide, of which 24 bits are used to store a block address A. How large does the FAT structure need to be accommodate a 1GB (2^30 bytes) disk? B. What is the largest theoretical le size supported by the FAT structure from part (A)?

A. How large does the FAT structure need to be accommodate a 1GB (2^30 bytes) disk?

The FAT file system splits the space into clusters, then has a table (the "cluster allocation table" or FAT) with an entry for each cluster (to say if it's free, faulty or which cluster is the next cluster in a chain of clusters). To work out size of the "cluster allocation table" divide the total size of the volume by the size of a cluster (to determine how many clusters and how many entries in the "cluster allocation table"), then multiply by the size of one entry, then maybe round up to a multiple of the cluster size or not (depending on which answer you want - actual size or space consumed).

B. What is the largest theoretical le size supported by the FAT structure from part (A)?

The largest file size supported is determined by either (whichever is smaller):

  • the size of "file size" field in the file's directory entry (which is 32-bit for FAT32 and would therefore be 4 GiB); or

  • the total size of the space minus the space consumed by the hidden/reserved/system area, cluster allocation table, directories and faulty clusters.

For a 1 GiB volume formatted with FAT32, the max. size of a file would be determined by the latter ("total space - sum of areas not usable by the file").

Note that if you have a 1 GiB disk, this might (eg) be split into 4 partitions and a FAT file system might be given a partition with a fraction of 1 GiB of space. Even if there is only one partition for the "whole" disk, typically (assuming "MBR partitions" and not the newer "GPT partitions" which takes more space for partition tables, etc) the partition begins on the second track (the first track is "reserved" for MBR, partition table and maybe "boot manager") or a later track (eg to align the start of the partition to a "4 KiB physical sector size" and avoid performance problems caused by "512 logical sector size").

In other words, the size of the disk has very little to do with the size of the volume used for FAT; and when questions only tell you the size of the disk and don't tell you the size of the partition/volume you can't provide accurate answers.

What you could do is state your assumptions clearly in your answer, for example:

" I assume that a "1 GB" disk is 1000000 KiB (1024000000 bytes, and not 1 GiB or 1073741824 bytes, and not 1 GB or 1000000000 bytes); and I assume that 1 MiB (1024 KiB) of disk space is consumed by the partition table and MBR and all remaining space is used for a single FAT partition; and therefore the FAT volume itself is 998976 KiB. "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM