cheat-sheets

mergerfs

mergerfs is a FUSE union filesystem that presents several disks or directories as one mount point, while each disk keeps its own filesystem and can be read on its own. It is the usual way to pool mismatched disks in a media server, often together with SnapRAID for parity.

Documentation: mergerfs README · mergerfs docs Project: mergerfs on GitHub

Verification: options and policy names were checked against the mergerfs man page of version 2.33.5 (Ubuntu 24.04 package). Current upstream releases (2.40 and later) have changed some defaults and renamed options, so check the documentation for your installed version (mergerfs -V). No pool was mounted on real disks. Prefer the upstream release packages over the distribution one for new installs.

Concepts #

TERMMEANING
BranchOne source directory or disk in the pool
PolicyRule that picks which branch a function (create, search, action) uses
create policyChooses the branch for new files; the main setting to tune
mfsMost free space: spreads new files to the emptiest disk
ffFirst found: fills disks in listed order
lfs / lusLeast free space / least used space
randRandom branch
ep* (epmfs, epff, …)Path preserving: only branches where the parent directory already exists

Mount #

COMMANDDESCRIPTION
mergerfs -o allow_other,use_ino,category.create=mfs /mnt/disk1:/mnt/disk2:/mnt/disk3 /mnt/poolMount three disks as one
mergerfs -o allow_other,use_ino,category.create=mfs '/mnt/disk*' /mnt/poolUse a glob; quote it so mergerfs expands it
mergerfs -VVersion
fusermount -u /mnt/poolUnmount (or sudo umount /mnt/pool)
mount | grep mergerfsShow the pool and its options

Permanent mount in /etc/fstab:

text
/mnt/disk* /mnt/pool fuse.mergerfs allow_other,use_ino,cache.files=off,dropcacheonclose=true,category.create=mfs,minfreespace=50G,fsname=pool 0 0

Common Options #

OPTIONPURPOSE
allow_otherLet users other than the mounting user see the pool (required for services)
use_inomergerfs supplies inode numbers (recommended)
category.create=mfsPolicy for creating files
category.search=ff / category.action=epallPolicies for lookups and for actions such as chmod
func.FUNC=POLICYOverride one function, for example func.getattr=newest
minfreespace=SIZESkip branches with less free space than this when creating files
moveonenospc=trueOn a full disk, move the file to another branch and retry
cache.files=off / partial / fullPage cache mode; off is safest, partial allows mmap
dropcacheonclose=trueAvoid double caching
fsname=NAMEName shown in df and mount
statfs=base / fullHow free space is reported
ignorepponrename=trueIgnore path preservation on rename

Options are evaluated in order, so put category.* before func.* overrides.

Branch Modes #

Append a mode to a branch with =:

text
/mnt/disk1=RW:/mnt/disk2=RW:/mnt/archive=NC
MODEMEANING
RWRead and write (default)
RORead-only branch, never chosen for creation or action
NCNo create: files can be read and changed but new files are not created there

Runtime Control #

mergerfs exposes extended attributes on the pool. The .mergerfs pseudo file is marked deprecated in the 2.33.5 man page, so check the documentation of your version for the current interface.

COMMANDDESCRIPTION
getfattr -d -m mergerfs /mnt/pool/.mergerfsList runtime settings (needs attr package)
setfattr -n user.mergerfs.category.create -v epmfs /mnt/pool/.mergerfsChange a setting without remounting
getfattr -n user.mergerfs.basepath /mnt/pool/<FILE>Which disk holds a file

Key names follow the man page; the getfattr and setfattr commands themselves are from the attr package and were not run against a pool here (unverified). Test on a scratch pool first.

Typical Media Server Layout #

text
/mnt/disk1  /mnt/disk2  /mnt/disk3   # data disks, each its own filesystem
/mnt/parity1                          # SnapRAID parity disk
/mnt/pool                             # mergerfs pool of the data disks, used by Plex, Jellyfin and the arr apps

Point the containers and apps at /mnt/pool, not the individual disks. Keep downloads and the library in the same pool so moves are fast renames; see Docker-Compose for bind mounts.

Troubleshooting #

SYMPTOMFIX
Services cannot see the poolAdd allow_other, and user_allow_other in /etc/fuse.conf
New files always land on one diskcategory.create is ff or an ep* policy; use mfs, and check minfreespace
No space left on device with space on another diskUse moveonenospc=true or a non-path-preserving create policy
mmap errors (some databases and apps)Use cache.files=partial or full
Pool empty after bootMount the disks first, then the pool; systemd mount ordering options are not covered here (unverified)

See Also #

Search all sheets

Tip: / or Ctrl/Cmd+K to open, Esc to close.