I have a Ubuntu 14.04 server that is failing to create a new directory beyond the 65,000 directory. I have run a tune2fs -l and can see that the dir_nlink flag is set. Does anyone know what else can be checked to allow this to occur? I have many other clones of this servers configuration that are all past the 65,000 mark and working as expected. I have compared the tune2fs -l outputs and they seem the same. I still have several million free inodes and blocks. I have unmounted and remounted the file system and nothing changed.

  • 1
    Did you try something like remount your partition? – Khaled Jan 19 '17 at 14:19
  • Not running out of inodes? – HBruijn Jan 19 '17 at 14:25
  • I'm having the same problem. I've yet been unable to reproduce the issue. (E.g. by upgrading a ext3 to a ext4 partition.) I've looked at the ext4 code which suggests that the dir_nlink flag is non-functional anyway. Have you found out in the meantime what the problem was? – Georg Schölly Dec 3 '17 at 19:26

Ext4 directory limit

Ext4 supports two kinds of directories:

  • traditional almost-linear directories
  • hash-based directories

Linear directories have a limit of 65000 links, i.e. around that many subdirectories are possible. Hash-based directories do not have a limit.

When creating a new file system, the default is hash directories. If your directories are still linear, it's probably because you upgraded an old ext3 partition. (Ext3 got the hash-based directories feature later.)

Test whether a directory is almost-linear or hash-based

$ sudo debugfs /dev/partition
$ htree /
htree: Not a hash-indexed directory


  1. Unmount the partition
  2. Enable the dir_index (hash-based dirs) and dir_nlink (unlimited links) features.

    sudo tune2fs -O dir_index,dir_nlink /dev/partition

All newly created directories are now capable of holding unlimited subdirectories.

If you want to convert existing directories, do the following:

  1. Unmount the partition (important to guard against data loss)
  2. Tell fsck to rebuild the directory indices:

    sudo e2fsck -f -D /dev/partition

-f forces fsck to check the disk even if it's in the clean state

-D tells e2fsck to rebuild the indices:

This option causes e2fsck to try to optimize all directories, either by reindexing them if the filesystem supports directory indexing, or by sorting and compressing directories for smaller directories, or for filesystems using traditional linear directories.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.