16

What is the limit of EXT4, what i found is only EXT3, and other links only suppositions and not a real number?

Can you please provide me: max number per directory, max size?

Community
  • 1
  • 1
Abdelouahab Pp
  • 4,252
  • 11
  • 42
  • 65

3 Answers3

16

Follow-up on @Curt's answer. The creation parameters can determine the number of inodes, and that's what can limit you in the end. df's -i switch gives you inode info.

(env)somesone@somewhere:/$ df -iT
Filesystem     Type       Inodes  IUsed    IFree IUse% Mounted on
/dev/root      ext4     25149440 612277 24537163    3% /
devtmpfs       devtmpfs  3085602   1418  3084184    1% /dev
none           tmpfs     3086068      2  3086066    1% /sys/fs/cgroup
none           tmpfs     3086068    858  3085210    1% /run
none           tmpfs     3086068      1  3086067    1% /run/lock
none           tmpfs     3086068      1  3086067    1% /run/shm
none           tmpfs     3086068      4  3086064    1% /run/user

This is a Linode box BTW, so it's virtualized environment. The number I look at is 24537163, that's how many free inodes the root fs has. Note, that more than 10K files in a directory can cause difficulties for many tools. 100K can be really hard on utilities.

See also: https://serverfault.com/questions/104986/what-is-the-maximum-number-of-files-a-file-system-can-contain

Csaba Toth
  • 10,021
  • 5
  • 75
  • 121
  • 1
    Another limitation is the number of directories within a directory under ext4... on several sites it is mentioned that 64000 is the max number of subdirectories you can have in a directory. – basZero Oct 22 '21 at 11:54
  • @basZero Thanks, that can be a tough limit if some code is generating the directories. I see for Ext3 it was 32000 and Ext4 doubled that https://ext4.wiki.kernel.org/index.php/Ext4_Howto#Sub_directory_scalability – Csaba Toth Oct 24 '21 at 00:11
  • 1
    Yes, it's a crazy strong limitation... of course Ext4 offers to use "large directory" feature, but in that configuration directories get very slow (as they are not indexed anymore). – basZero Oct 26 '21 at 09:41
4

It depends upon the MKFS parameters used during the filesystem creation. Different Linux flavors have different defaults, so it's really impossible to answer your question definitively.

Curt
  • 5,518
  • 1
  • 21
  • 35
  • so this is why i only find EXT3 ? – Abdelouahab Pp Jul 08 '13 at 23:15
  • 2
    https://ext4.wiki.kernel.org/index.php/Ext4_Howto#Bigger_File_System_and_File_Sizes – Curt Jul 08 '13 at 23:16
  • 1
    The 48-bit block addressing suggests an absolute maximum number of files of 281,474,976,710,656 (presuming only one-block files), but I suspect that won't be a problem for you... ;-) – Curt Jul 08 '13 at 23:22
  • because what i will do, si talking about filesystem, so i gave a comparison between FAT32, NTFS and EXT4 (since EXT3 is old). so i talked about max files on directory (the subject is about webserver) – Abdelouahab Pp Jul 08 '13 at 23:24
  • I think this answer is incorrect... inodes are a per-partition limit. On ext4 you can create more files in a directory until you blow the directory index limit. Source: https://access.redhat.com/solutions/29894 . I'm writing a blog post about it now... will appear at https://adammonsen.com/post/1555 soon . – Adam Monsen Dec 20 '18 at 05:50
  • @AdamMonsen That's not right. The inodes are a part of the _filesystem_ (there's one inode for each allocated block). The partitions are just a structured way of designating raw storage space upon which filesystems can be built. – Curt Dec 28 '18 at 01:27
  • 2
    Ah, good point @Curt, and agreed: inodes are indeed a per-filesystem limit. But assuming plenty of inodes in a new ext4 filesystem, the more relevant resource constraint is the directory index limit. You could hit this long before the inode limit... this is exactly what happened to me. The original question is specifically about limits on the number of files in a directory. That said, I don't know how to calculate the files-per-directory limit. :) – Adam Monsen Dec 29 '18 at 02:10
  • @AdamMonsen As far as I'm aware, directory entries are stored in regular data blocks. [This](https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Directory_Entries) seems to support that... – Curt Dec 29 '18 at 21:40
  • @Curt agreed, but that's orthogonal to the **directory index**--a separate structure with a different resource limit. I'm just too lazy to go read the ext4 source code right now and I don't see details on directory index limits on the ext4 wiki page you shared. See the links I posted: https://access.redhat.com/solutions/29894 and https://adammonsen.com/post/1555 – Adam Monsen Dec 31 '18 at 01:34
  • 1
    But there must be a way to find the max number of subdirectories in a directory. How do we do that? – basZero Oct 26 '21 at 14:39
0

In addition to Inode capacity being one of the limits, there is also a filesystem limit with EXT4 with this situation.

According to https://www.phoronix.com/news/EXT4-Linux-4.13-Work it's "roughly 10 million entries allowed in a single directory" however this can be extended with the large_dir feature, though there are limitations/issues with this (for example GRUB might not be able to use this partition to boot).

From my own anecdotal experience I ran into an issues once we crossed about 32 million files in a single directory.

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286