From what I understand, FAT32 uses a 32 bit number for each file to store its file size (and thus FAT32 is limited at ~4GiB files). In FAT each file has a root directory entry, and these entries are what store the value for the file size. This page shows the directory entry's structure for FAT32. This resource suggests that FAT12 uses a 25 bit value for file size, and FAT16 a 31 bit value.

Is the information in the second linked resource correct? If not, what is the true maximum file size for FAT12 and FAT16? If it is true, then why is an irregular number of bits used to store file size for these file systems?

EDIT: Why is it that they are restricted by volume size, whereas FAT32 has a set size? Is it because the file size that it stores is bigger than any supported volume size, or do FAT12 and FAT16 not use a file size as a field in the directory entry?

  • 1
    did you check the values on wikipedia? – phuclv Jun 13 at 16:57
  • Thanks for your comment, I've added information to my question. – VortixDev Jun 13 at 17:01
  • Understand that FAT12, FAT16, and FAT32 were designed at different times by different individuals and with differing conflicting requirements which had changed considerably over the years. FAT32 was designed more than 20 years ago while FAT12 and FAT16 are older still. There was a desire to maximize the capabilities of the file systems while at the same time maintaining efficiency with the limited technology of the day. Compromises had to be made. The result was some apparently odd values and inconsistencies between file systems. – LMiller7 Jun 13 at 19:24
  • FAT32 is limited to "4GB minus 2 Bytes" not 4GB. – DavidPostill Jun 13 at 19:42
  • @DavidPostill Thanks for your correction, I've amended the question. How come it's -2 bytes instead of -1 byte? – VortixDev Jun 13 at 19:57

File size on FAT is stored in a 32-bit field.

On FAT32 the field is treated as unsigned allowing for files up to 4294967294 bytes (apparently 4294967295 is not allowed for some reason, possiblly "-1" was used as a flag somewhere).

On FAT16 the field is limited to the range of a signed 32-bit number. I expect the reason for this is legacy code that was written back when 2GB would have been considered an insane size for a file. FAT16 filesystems beyond 2GB were an oddity anyway*.

AIUI on FAT12 the file size is limited to 32MB (not 32KB!) not because of any limitation specific to file size, but simply because that is the maximum size of the volume and you can't have a file bigger than the volume. The same would apply to early versions of FAT16.

* The version of FAT16 used by DOS 4 through windows 95 was limited to 64 sectors per cluster which on typical 512 byte sectors meant a roughly 2GiB volume size. NT doubled the maximum sectors per cluster allowing ~4GiB volumes with 512 byte sectors and 98 added support for reading/writing but not creating or repairing such volulems. Bigger volumes were theoretically possible if the underlying device had bigger sectors but I have seen no evidence that this actually happend in practice.

Part of this would depend on the size of the cluster.

While the disk has (for most implementations) 512 byte sectors, the sectors were arranged in clusters to allow for larger files as larger storage capacity.

For FAT12 the maximum capacity and file size was 16 MB (with 4 KB clusters) and 32 MB (with 8 KB clusters).

For FAT16, the initial version did not change the capacity, but as it developed, the file size was allowed to expand to 2Gb, 4Gb and finally limited by volume, with the volume maximums ranging from 2Gb to 16Gb, depending on the version of FAT16 that was implemented by the operating system

  • The volume size was increased, but afaict the maximum filesize remained limited to 2GB. – plugwash Jun 13 at 17:03

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.