Maximum number of files and folders in a single directory?

April 22, 2014 5.8k views
Running ubuntu 12.04, what is the maximum number of files and folders a single directory can hold assuming that each files are pretty small ~1kb. I need a way to store up to a million files in a single directory
3 Answers

The maximum number of files on your drive is limited by the inode limit. For example:

df -i

/dev/vda 1310720 230115 1080605 18% /

Shows that there are only about 1,080,000 free inodes (1,310,720 total and 230,115 used) on my droplet. So you would have to keep it under that.

You cannot currently change the number of inodes. DigitalOcean currently uses an inode ratio of 16kb meaning 20gb / 16kb = the max number of inodes. So more disk space would allow you to host more files.

A million files shouldn't be a problem. ext4 does have a 64,000 subdir limit, however.


You shouldn't have a problem with a million files. There isn't any specific limit on the number of files in a directory, but each file no matter how small take up at least on "inode." The number of available inodes is related to the size of the disk. This does a good job of explaining it:

Have another answer? Share your knowledge.