Home » Questions » Computers [ Ask a new question ]

What is the maximum number of folders allowed in a folder in Linux?

What is the maximum number of folders allowed in a folder in Linux?

Using Redhat, if that makes a difference.

Asked by: Guest | Views: 152
Total answers/comments: 1
Guest [Entry]

"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.:


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


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


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."