Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I created a single primary partition to my WD WD800BB-55JHA0 80GB HDD using MBR partitioning scheme. Into this partition I created an ext4 file-system with 200048640 inodes! Then I created loads of very small files with while true; do echo a > /media/$RANDOM$RANDOM$RANDOM; done command. At some point I was not able to add more files:

sh-4.2# strace echo a > /media/$RANDOM$RANDOM$RANDOM

The file is not created and there is no output to shell. It just hangs there forever.

Output of dumpe2fs /dev/sdb1 can be seen below:

Filesystem volume name:   <none>
Last mounted on:          /media
Filesystem UUID:          233d7f5b-51b0-4c3d-8f1d-5d8c34f08a8f
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean with errors
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              200048640
Block count:              19536000
Reserved block count:     976871
Free blocks:              6665698
Free inodes:              199748660
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      1024
Blocks per group:         3200
Fragments per group:      3200
Inodes per group:         32768
Inode blocks per group:   2048
Flex block group size:    16
Filesystem created:       Thu Jan  5 11:20:15 2006
Last mount time:          Thu Jan  5 11:48:02 2006
Last write time:          Thu Jan  5 11:53:15 2006
Mount count:              1
Maximum mount count:      -1
Last checked:             Thu Jan  5 11:20:15 2006
Check interval:           0 (<none>)
Lifetime writes:          3540 MB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
First orphan inode:       280161
Default directory hash:   half_md4
Directory Hash Seed:      84caa27e-4e4c-4853-b222-e739c0fda1de
Journal backup:           inode blocks
FS Error count:           1
First error time:         Thu Jan  5 11:53:15 2006
First error function:     ext4_mb_generate_buddy
First error line #:       741
First error inode #:      0
First error block #:      0
Last error time:          Thu Jan  5 11:53:15 2006
Last error function:      ext4_mb_generate_buddy
Last error line #:        741
Last error inode #:       0
Last error block #:       0
Journal features:         (none)
Journal size:             128M
Journal length:           32768
Journal sequence:         0x000000c7
Journal start:            29840

I clearly did not run out of inodes and there is enough space left to create more files:

sh-4.2# df -i /dev/sdb1
Filesystem        Inodes  IUsed     IFree IUse% Mounted on
/dev/sdb1      200048640 299980 199748660    1% /media
sh-4.2# df /dev/sdb1
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sdb1       28079472 1416684  22755304   6% /media
sh-4.2# 

What might restricting new files? Is there a limit of files per directory?

share|improve this question
1  
strace echo a > file is wrong. The redirection takes place before strace is run. You need: strace -f bash -c 'echo a > /media/file' –  Hauke Laging Jul 5 '13 at 12:38
1  
Also, strace is probably not going to show you much more than a hanging write() syscall which you could have probably guessed. It's better to look at the log files like dmesg and messages to see if anything descriptive got printed there. –  Bratchley Jul 5 '13 at 13:01
    
Just an FYI - You can also use the command tune2fs -l <dev> to get the superblock info. –  slm Jul 5 '13 at 17:37

1 Answer 1

Per http://en.wikipedia.org/wiki/Ext4

There is a limit of 64,000 entries per directory. Your problem is that you have hit this limit.

Edited to fix the entries per directory.

share|improve this answer
2  
Minor quibble: article actually says 32k is for ext3, ext4 has a 64k limit. –  Bratchley Jul 5 '13 at 13:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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