Maximum number of inodes in a directory?

88,718

Solution 1

df -i should tell you the number of inodes used and free on the file system.

Solution 2

Try ls -U or ls -f.

ls, by default, sorts the files alphabetically. If you have 2 million files, that sort can take a long time. If ls -U (or perhaps ls -f), then the file names will be printed immediately.

Solution 3

No. Inode limits are per-filesystem, and decided at filesystem creation time. You could be hitting another limit, or maybe 'ls' just doesn't perform that well.

Try this:

tune2fs -l /dev/DEVICE | grep -i inode

It should tell you all sorts of inode related info.

Solution 4

What you hit is an internal limit of ls. Here is an article which explains it quite well: http://www.olark.com/spw/2011/08/you-can-list-a-directory-with-8-million-files-but-not-with-ls/

Solution 5

Maximum directory size is filesystem-dependent, and thus the exact limit varies. However, having very large directories is a bad practice.

You should consider making your directories smaller by sorting files into subdirectories. One common scheme is to use the first two characters for a first-level subdirectory, as follows:

${topdir}/aa/aardvark
${topdir}/ai/airplane

This works particularly well if using UUID, GUIDs or content hash values for naming.

Share:
88,718
Mark Witczak
Author by

Mark Witczak

I haven't done any serious programming in 12 years, but I like to stay on top of the latest technologies.

Updated on May 15, 2020

Comments

  • Mark Witczak
    Mark Witczak about 4 years

    Is there a maximum number of inodes in a single directory?

    I have a directory of over 2 million files and can't get the ls command to work against that directory. So now I'm wondering if I've exceeded a limit on inodes in Linux. Is there a limit before a 2^64 numerical limit?