I have been through the other questions/answers regarding inode usage, mounting issues and others but none of those questions seem to apply...
df -h
/dev/sdd1 931G 100G 785G 12% /media/teradisk
df -ih
/dev/sdd1 59M 12M 47M 21% /media/teradisk
Basically, I have an EXT4 formatted drive 1TB in size, and am writing arount 12 million (12201106) files into one directory. I can't find any documentation on a files-per-directory limit for EXT4 but the filesystem reports no space left.
Oddly, I can still create new files on the drive and target folder but when doing a large cp/rsync, the calls to mkstemp
and rename
report no space left on device.
rsync: mkstemp "/media/teradisk/files/f.xml.No79k5" failed: No space left on device (28)
rsync: rename "/media/teradisk/files/f.xml.No79k5" -> "files/f.xml": No space left on device (28)
I know storing this many files in one directory isn't advised for a ton of reasons, but unless I can help it I don't wish to split them up.
Inode and space usage for tmpfs, the device and everything else looks fine. Any ideas of the cause?
It seems you are hitting directory size limit. Directory itself is some kind of special file which contains names (+ inode numbers and probably some other metadata) of all files in it. And it can't be larger than 2G.
Anyway, it's not a good idea to have more than few thousands of files in one dir: searches by file name would be very slow and you'll have a lot of problems with standard tools like ls, rm and others.
Update:
a-ha!
http://old.nabble.com/re:The-maximum-number-of-files-under-a-folder-td16033098.html
The XFS filesystem would be a more supportable (long-term) solution for what you're trying to do now. Large file-count directories are not a problem for XFS. Of course, fixing this at the application level would also be helpful...
is ext4 absolutely needed for you? These days XFS should handle a situation like this without a hitch.
I had this problem. My solution was:
mkfs.ext4 -i 1024 -b 1024 /dev/blah
Another source of
ENOSPC
errors when using theext4
filesystem can be hash collisions of the directory index hash algorithm used.This blog post talks about more details:
Changing the directory hash algorithm to
tea
should resolve the problems.It seems you're running out of i-nodes. Show output of
df -iht ext4
.I also have had a problem with removing a directory on EXT4 containing ~ 1 million of files (linux kernel 3.0, IIRC). What's kernel version in your case?
Finally, I'd suggest using Reiser3 — it doesn't have format time i-node limits, and in aforementioned case seemed to have solved the problem as well.
UPD.: For those wondering if Reiser3 being supported on not:
cd linux-stable/fs/reiserfs && git log --pretty='format:%aD %s' . | head -n20