Why are FAT32 disks limited to 4GB files?
Asked Answered
P

3

17

I'm not looking for a workaround; I'd like an explanation. Most of the links I found through Google just tell me that the file limit is 4GB, but not why.

I am aware of the explanation by Wikipedia: http://en.wikipedia.org/wiki/File_Allocation_Table#FAT32

But this still does not go into detail about why. (What does SCANDISK have to do with it?)

Maybe then I will understand whether it's possible to overcome the 4GB file size limit.

Pitchblack answered 11/1, 2011 at 20:43 Comment(0)
P
9

To extend that answer, FAT32 is derived from FAT16 and FAT12. When FAT12 was introduced, PCs ran a 16-bit OS, and there were no drives larger than ten megabytes. I don't think anyone was expecting that anyone on a PC would ever need a file that was four hundred times the size of the largest available drive. Further, even if Microsoft had the foresight to allocate an extra byte for each directory entry to hold bits 32-39 of the file size (allowing files up to one terabyte each) it's doubtful any application programmers would have used it. No languages provided convenient support for integer math bigger than 32 bits; even 32-bit maths were considered pretty fancy.

A bigger question in my mind is why I'm unaware of any efforts to move toward a standard non-FAT32 storage interface that isn't based on sequentially-numbered sectors. Both flash drives and hard drives could benefit from knowing the logical significance of various sector writes (in the case of flash, because it would remove the need to copy deleted sectors when performing wear management; in the case of hard drives, because it would allow writes to be resequenced in ways that would not violate data consistency requirements).

Photojournalism answered 11/1, 2011 at 23:58 Comment(0)
A
32

Because FAT32 stores 32-bit file sizes and the maximum you can store in 32 bits is 2^32-1 ~= 4.29e9. 2^32-1 bytes = 4GB - 1 byte.

(This is, in fact, explained in the Wikipedia article.)

Anaconda answered 11/1, 2011 at 20:46 Comment(4)
Yes, I know that, but why does it do that? By some random convention? Surely the people who designed the filesystem knew that that would be the limit, so why settle for that limit? Was it because of the hardware available at the time?Pitchblack
FAT32 was implemented on 32-bit hardware for a 32-bit operating system with a 32-bit compiler, so it's an obvious choice and anything beyond 32 bits would have cost precious processor cycles, disk space and programming time. (In those days, we thought 4GB was pretty large for an HD, let alone for a single file.)Anaconda
Ah, very interesting. That's exactly what I was wondering. Thanks!Pitchblack
i thought fat32 is about having the file allocation table addresing (clusters counts where the values in the fat fields is addres to the next chain in the file (32 bits), but since 1 cluster is about 4KB i dont understand why 4GB)Lalia
P
9

To extend that answer, FAT32 is derived from FAT16 and FAT12. When FAT12 was introduced, PCs ran a 16-bit OS, and there were no drives larger than ten megabytes. I don't think anyone was expecting that anyone on a PC would ever need a file that was four hundred times the size of the largest available drive. Further, even if Microsoft had the foresight to allocate an extra byte for each directory entry to hold bits 32-39 of the file size (allowing files up to one terabyte each) it's doubtful any application programmers would have used it. No languages provided convenient support for integer math bigger than 32 bits; even 32-bit maths were considered pretty fancy.

A bigger question in my mind is why I'm unaware of any efforts to move toward a standard non-FAT32 storage interface that isn't based on sequentially-numbered sectors. Both flash drives and hard drives could benefit from knowing the logical significance of various sector writes (in the case of flash, because it would remove the need to copy deleted sectors when performing wear management; in the case of hard drives, because it would allow writes to be resequenced in ways that would not violate data consistency requirements).

Photojournalism answered 11/1, 2011 at 23:58 Comment(0)
O
0

I have the same doubt, and finally realized that every file has its own meta data contains 4 bytes for the file size. So, the max file size is 4G - 1 bytes.

Originality answered 15/2, 2015 at 9:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.