Page 1 of 1

why maximum number of files is 4,077 in fat12?

Posted: Thu May 06, 2010 7:15 am
by brainbarshan
In chapter 6 : Bootloaders 4
under the topic File system theory
Because of the limited cluster size, The maximum number of files possible is 4,077
why is this so? can you explain?

Re: why maximum number of files is 4,077 in fat12?

Posted: Thu May 06, 2010 11:53 am
by Neutron
It actually has nothing to do with cluster sizes but the maximum number of clusters. Microsoft has specified that any FAT12 filesystem must have less than 4085 clusters. Similarly the FAT16 system must have less than 65525 clusters (the FAT filesystem type is actually detected by these numbers and not by any other field present in the Bios Parameter Block or extended FAT infofields in the boot sector)

The maximum number of files on FAT12 is less than 4085 because every file whose size > 0 will require at least one cluster. If your files are bigger than one cluster (typically 512 B in floppies), the maximum number of files is (naturally) even less. Also, every directory requires at least one cluster too.

As a historical side note, when the original FAT12 didn't have directory support, maximum number of files was 224 (field 'root entry count' in bios parameter block) and still is for the root directory.

Re: why maximum number of files is 4,077 in fat12?

Posted: Thu May 06, 2010 2:14 pm
by Andyhhp
The reason that the total number of files is 4077 is that you have 12 bits to index clusters.

2^12 is 4096 but certain values are reserved (for example, 0xFFF means last cluster in file, 0xFF0 means bad cluster), leaving 4077 usable indicies.
As a historical side note, when the original FAT12 didn't have directory support, maximum number of files was 224 (field 'root entry count' in bios parameter block) and still is for the root directory.
Not quite. 224 is the default size for the root directory but it can be exanded if you need to fit more entries in. The only requirement is that:

root_dir_size*32 % bytes_per_sector = 0

or in other words, the total size of the root directory is an integer multiple of sectors

~Andrew

Re: why maximum number of files is 4,077 in fat12?

Posted: Thu May 06, 2010 9:05 pm
by brainbarshan
thank you.

Re: why maximum number of files is 4,077 in fat12?

Posted: Wed Aug 23, 2017 7:34 am
by BoydBun
How do we increase the max number of files?