Feedback on UFS2 tuning for large number of small files (~100m)

Eduardo Morras emorrasg at
Wed Jun 8 10:56:24 UTC 2016

On Wed, 8 Jun 2016 11:14:40 +0300
Ciprian Dorin Craciun <ciprian.craciun at> wrote:

> Hello all!  (Please keep me in CC as I'm not subscribed on the mailing
> list.  Should I perhaps post this to the `freebsd-fs` mailing list?)
> I would like your feedback on tuning a UFS2 file-system for the
> following use-case, which is very similar to a maildir mail server.  I
> tried to look for hints on the internet, but found nothing more
> in-depth than enabling soft-updates, `noatime`, etc.

You can use tunefs to set:

a) average file size and expected number of files per directory,
b) check if your filesystem has any ACL flags on (NFS, POSIX, whatever) and disable them if you don't use ACLs,
c) if filesystem is full or near full, system switch from faster writes to minimize fragmentation strategy (slower), force the fast access optimization.

They requires a umount/mount only no reformating. 

Newfs can set those values at fs formatting/createing.

There are some sysctl you can tweak, again without reformating:

vfs.ufs.dirhash_maxmem: maximum allowed dirhash memory usage

Defaul value is 6MB. Check first dirhash usage with 

#sysctl vfs.ufs.dirhash_mem

and if it's equal or close to maxmem, grow it (24MB or more, f.ex.)

Tuning at ffs level are more tricky and risky, check sysctl vfs.ffs.*

---   ---
Eduardo Morras <emorrasg at>

More information about the freebsd-questions mailing list