FAT32 limit on total length of all filenames in a directory combined?

3

I've kind of a weird problem on one of our customer's backup harddrives: The harddrive is formatted in FAT32 and last night our backup jobs threw an error on a subdirectory, claiming that it couldn't copy the files that it had to copy.

I checked the disk size first of course, but there is plenty of space. The error given was 0x80070052, if I put that into a search engine I get results like this: http://www.quickonlinetips.com/archives/2007/09/how-to-fix-error-0x80070052-on-usb-flash-drives/

But there are just 8 files/directories in the root directory of that partition. So I went on and decided to test some stuff myself. Creating a single file (named 'test.txt' for example) did work. But creating a file with one of the filenames that the backupjob failed on, didn't work, instead I got the same error as above. I tested around a little bit and found out that I can create a file with 10 characters in that sub-directory, one character more and it fails.

After detecting that, I created a directory in that subdirectory (named 'test') and moved some files from the sub-directory into the new directory, after that finished, I tried to create a file with 11 characters (which didn't work before) and it worked.

Now, obviously from observation, there seems to be some kind of hardlimit on how many characters can be used for all filenames inside a single directory for FAT32, but I couldn't find anything about that hard limit or if other file systems (especially NTFS, which would be the alternative in this case, I guess) have similiar limits.

If someone could provide me with informations about the observed behaviour, that'd be great!

edit

a colleague told me to put the exact folder on another FAT32 drive, since he once had problems with the USB controller of a particular manufacturer. I tried two USB sticks from different manufacturers, both FAT32 formatted, both showed the exact same behaviour as described above.

To get you an idea of the amount of files involved: There are roughly 10200 files, each with a filename between 80 and 110 characters in length, excluding the filepath (that doesn't seem to be of any matter), so there are circa one million characters involved.

limits
fat32
asked on Server Fault Aug 9, 2013 by Steffen Winkler • edited Aug 12, 2013 by Steffen Winkler

2 Answers

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. Short filenames that contain lower case letters are additionally stored in a Long File Name entry.

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 Long File Name entry.

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.

answered on Server Fault Apr 23, 2020 by katce • edited Apr 24, 2020 by katce
0

Max file name + directory path is 255 charters as a combined total; so it DOES matter.

answered on Server Fault May 1, 2019 by James

User contributions licensed under CC BY-SA 3.0