Possible Duplicate:
Number of files per directory

I need to save 1 million static html files in one directory as there is not possible to group the files into the directories (all files must have path like page-name.html. Already tested with 200 000 files and there seems to be no problem on Linux, but wonder if it still won't be problematic with 1 million of static pages?

marked as duplicate by Gilles, Michael Mrozek May 16 '11 at 21:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com May 15 '11 at 14:01

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

  • question, maybe you could put those files into a sql database instead? – Johan May 16 '11 at 10:43
  • 1
    Not an answer to your question, but most of the time in scenarios such as this, you would in fact create multiple directories to improve performance (huge directories are slow as molasses). With truly random file names, a common situation is to use the first one, two or three letters of the file name and make it a directory. So a file named "1bcaf.html" would go into maindir/1bc/1bcaf.html". Doing this would require restructuring the code that accesses it, which may or may not be possible in your situation. – Kevin Keane Apr 20 '15 at 21:28

The number of inodes that can be created on a linux system is typically extremely massive. The exact number depends on a LOT of variables, but here's a thread on the Ubuntu forums about calculating inodes for your system and about how to show information through terminal commands.

Edit (Ubuntuforums thread now requires login):
Here's essentially what the thread says, and references Wikipedia.

It varies. First off, depending on what file system your Linux install uses. The default is ext3, but even within that filesystem, the maximum number of files varies. From Wikipedia:


The maximum number of inodes (and hence the maximum number of files and directories) is set when the file system is created. If V is the volume size in bytes, then the default number of inodes is given by V/2^13 (or the number of blocks, whichever is less), and the minimum by V/2^23. The default was deemed sufficient for most applications.

The Wikipedia quote is cited as plain text, so there's no verifiable source, so that's pretty much the end of that trail.

I think the bottom line is that unless you've filled your disk with billions of tiny files, you're probably going to run out of disk space before you run out of inodes.