Max files per directory on NTFS vol vs FAT32

What's the max number of files that can be present in a directory on a NTFS volume? Same question for a directory for FAT32 volume?


Solution 1:

After a quick search on google I found these:

FAT32

  • Maximum disk size: 2 terabytes
  • Maximum file size: 4 gigabytes
  • Maximum number of files on disk: 268,435,437
  • Maximum number of files in a single folder: 65,534

NTFS:

  • Maximum disk size: 256 terabytes
  • Maximum file size: 256 terabytes
  • Maximum number of files on disk: 4,294,967,295
  • Maximum number of files in a single folder: 4,294,967,295

References:

  • http://ask-leo.com/is_there_a_limit_to_what_a_single_folder_or_directory_can_hold.html
  • http://www.ntfs.com/ntfs_vs_fat.htm

Solution 2:

NTFS: There is no fixed limit. The maximum number of files is one upper limit. This limit is either 2^23-1 (according to many driver implementations) or 2^48 -1 (according to the MFT_REF structure). As you will have LARGE directories, you will see non-resident $BITMAP_ALLOCATION streams, a large INDEX stream. The index stream is essentially a B+ tree of file names.


FAT32: There is a difference between the root directory and sub-directories. The root has certain limitations.

Solution 3:

The maximum number of files within a directory of a FAT file system is 65,536 if all files have short filenames (8.3 format). Short filenames are stored in a single 32-byte entry.

That means the maximum size of a direcotry (file) is 65,536 * 32 bytes, i.e. 2,097,152 bytes.

Short filenames in 8.3 format consists of 8 characters plus optional a "." followed by maximum 3 characters. The character set is limited.

If the filename is longer (Long File Name), it is spread over multiple 32-byte long entries. Each entry contains 13 characters of the filename. If the length of the filename is not a multiple of 13, the last entry is padded. Additionally there is one short file name entry for each file with long name.

2 32-byte entries are already taken by the "." and ".." entries in each directory (except root).

1 32-byte entry is taken as end marker?

So the actual maximum number of files in a directory depends on the length of the filenames.