This question is related to this one.
I work with animation, which generates a LOT of files (+/- 1,000,000) typically stored on a single directory. On Mac Os X, some bugs came up with more than +/-30,000 files, so I used to break the animation into various directories.
On Ubuntu, is there a limit for the number of files a single directory can hold?
Ubuntu does not limit the size of a directory, it's imposed by the file system. Each file and directory is an so-called inode. You can use
df -i
to check the number of inodes in use and available for all mounted filesystems.I've just created 1 million and one files without issues because my inode limit for my ext4 home partition of 50 GB (46 GiB) is large enough.
I used shell expansion for creating the files, combined with the
touch
utility:This creates 1000001 files which can be verified with
ls | wc -l
. Why300000..600000
and not300001..600000
? Because I was too lazy to put that 1 at the end.df -i
looks like:Now remove the test files (
cd ..&&rm -f test
took much longer, so userm
with the filenames):and the number of inodes in use decreased immediately after removal of the files:
Note that even if the filesystem allows such large numbers of files, it's a horrible idea to store such large files in a single directory. At least use some subdirectories with a structure like
f/i/l/e/filename.ext
. Programs do often not expect such large quantities of files.