Best options to create and mount an ext4 volume containing > 10M files in one directory
What are the appropriate options to mkfs
and mount
for an ext4 filesystem with a folder containing >10 million files for read access?
What I have so far:
umount /media/dirsizetest
mkfs.ext4 -L DIRSIZETEST -E lazy_itable_init=1 -E lazy_journal_init=1 -m 1 /dev/sda1
mount -t ext4 -o nodiratime /dev/sda1 /media/dirsizetest
Some context is in order. I'm doing a slightly (OK, very) crazy experiment involving seeing how different file systems perform with a single folder filled with millions of small files. Eventually I'll be filling a 1TB drive to capacity doing this (I told you it was a crazy experiment!).
The access patten is something along these lines:
Recreate the volume from scratch (using mkfs) and mount it.
Create a sub-directory, fill it with N files in sequence (named 1...N)
(where N can be up to 2^63)
Read all files in order
Read all files in random order
Print how it takes
My natural habitat is the Windows NTFS world, and the number of options to mount
and mkfs
are a bit daunting. So I'm looking for guidance on what options are likely to shoot my performance in the foot.
I'm working in a 64 bit Ubuntu 12.04 desktop environment.
Solution 1:
Attention: Security advice
These instructions are UNSAFE and should not be used in production environment without precautions.
For example a battery backed RAID card can help to decrease risks.
Use at own risk
If you just like it as a test environment I'd recommend the ext4 options
noatime,data=writeback,barrier=0,nobh,errors=remount-ro
This
- disables accesstimes on read
- writes metadata lazily
- disables the enforcing of proper on-disk ordering of journal commits
- tries to avoid associating buffer heads
- remounts read only on error
for mkfs.ext4 I could only find the option
dir_index
Use hashed b-trees to speed up lookups in large directories.
usefull
Solution 2:
Some research I did found the following links. Chris Perrin's answer provides a short list of options; these should provide additional reference material.
- Blog post in improve ext4 performance
- Kernel.org documentation for ext4
man
page formkfs.ext4