Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Using Redhat, if that makes a difference.

Is there a default limit? Can it be changed? If not, are there any workarounds to increase the number of folders allowed in a directory?

share|improve this question
add comment

migrated from stackoverflow.com Nov 5 '09 at 19:39

This question came from our site for professional and enthusiast programmers.

4 Answers

It depends on what filesystem your distribution uses. If you use a newer desktop distribution (i.e. Ubuntu 9.10, a recent version of Fedora), you probably use ext4. If you use something older, it is most likely ext3.

share|improve this answer
add comment

You may want to consider alternatives to whatever it is you're trying to do. Even if you stay under the filesystem limit (e.g., 32k for ext2), storing tens of thousands of files in a single directory can be cumbersome to say the least.

One possibility is that you're trying to use the filesystem for something that would be more suited to a database. Consider storing your data in a PostgreSQL, MySQL, or even a sqlite database. There aren't too many filesystems that cope well with a huge number of files-- moving or backing up your data will be slow.

If you really need to store lots of files, consider alternative directory structures. For example, you may be able to separate your files alphabetically, e.g.:

a/aaron.dat
a/alex.dat
a/alan.dat
b/bill.dat
b/brian.dat

This approach can scale by increasing the depth of your separation, e.g.,:

a/a/aaron.dat
a/l/alex.dat
a/l/alan.dat

Or if you are entering daily log files or receiving daily deliveries, you could separate them by date, e.g.:

2009-10-04/logfile-01.txt
2009-10-05/logfile-01.txt
2009-10-05/logfile-02.txt

In this particular case, you would probably also want to cron a job to package old logs into zipped tarballs to reduce the file count.

share|improve this answer
add comment

Folder limits are why enterprise systems which have to deal with an arbitrary number of files will store in one or two subdirectories based on a hash of the filename. For example, md5() the filename, and use the first four bytes as a subfolder to store the file in; for additional levels, use the next 4 for an additional subfolder, or the next 4 after that, etc. Most systems would never exceed 2 levels deep.

share|improve this answer
add comment

In ext2, 32,768 according to Wikipedia - http://en.wikipedia.org/wiki/Ext2fs#File%5Fsystem%5Flimits. Depends on what file system you use.

share|improve this answer
2  
Yep. Folder count is attached to the file system, not the OS. –  Satanicpuppy Nov 5 '09 at 19:48
    
Looks like ext4 bumps that limit to a hard 64k but supports even more than that through tweaking –  basszero Nov 5 '09 at 21:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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