You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3339 lines
123 KiB

7 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
2 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
9 years ago
6 years ago
9 years ago
9 years ago
9 years ago
9 years ago
5 years ago
5 years ago
5 years ago
2 years ago
5 years ago
2 years ago
9 years ago
4 years ago
7 years ago
7 years ago
9 years ago
9 years ago
9 years ago
  1. .\"t
  2. .\" Automatically generated by Pandoc 2.9.2.1
  3. .\"
  4. .TH "mergerfs" "1" "" "mergerfs user manual" ""
  5. .hy
  6. .SH NAME
  7. .PP
  8. mergerfs - a featureful union filesystem
  9. .SH SYNOPSIS
  10. .PP
  11. mergerfs -o<options> <branches> <mountpoint>
  12. .SH DESCRIPTION
  13. .PP
  14. \f[B]mergerfs\f[R] is a union filesystem geared towards simplifying
  15. storage and management of files across numerous commodity storage
  16. devices.
  17. It is similar to \f[B]mhddfs\f[R], \f[B]unionfs\f[R], and
  18. \f[B]aufs\f[R].
  19. .SH FEATURES
  20. .IP \[bu] 2
  21. Configurable behaviors / file placement
  22. .IP \[bu] 2
  23. Ability to add or remove filesystems at will
  24. .IP \[bu] 2
  25. Resistance to individual filesystem failure
  26. .IP \[bu] 2
  27. Support for extended attributes (xattrs)
  28. .IP \[bu] 2
  29. Support for file attributes (chattr)
  30. .IP \[bu] 2
  31. Runtime configurable (via xattrs)
  32. .IP \[bu] 2
  33. Works with heterogeneous filesystem types
  34. .IP \[bu] 2
  35. Moving of file when filesystem runs out of space while writing
  36. .IP \[bu] 2
  37. Ignore read-only filesystems when creating files
  38. .IP \[bu] 2
  39. Turn read-only files into symlinks to underlying file
  40. .IP \[bu] 2
  41. Hard link copy-on-write / CoW
  42. .IP \[bu] 2
  43. Support for POSIX ACLs
  44. .IP \[bu] 2
  45. Misc other things
  46. .SH HOW IT WORKS
  47. .PP
  48. mergerfs logically merges multiple paths together.
  49. Think a union of sets.
  50. The file/s or directory/s acted on or presented through mergerfs are
  51. based on the policy chosen for that particular action.
  52. Read more about policies below.
  53. .IP
  54. .nf
  55. \f[C]
  56. A + B = C
  57. /disk1 /disk2 /merged
  58. | | |
  59. +-- /dir1 +-- /dir1 +-- /dir1
  60. | | | | | |
  61. | +-- file1 | +-- file2 | +-- file1
  62. | | +-- file3 | +-- file2
  63. +-- /dir2 | | +-- file3
  64. | | +-- /dir3 |
  65. | +-- file4 | +-- /dir2
  66. | +-- file5 | |
  67. +-- file6 | +-- file4
  68. |
  69. +-- /dir3
  70. | |
  71. | +-- file5
  72. |
  73. +-- file6
  74. \f[R]
  75. .fi
  76. .PP
  77. mergerfs does \f[B]not\f[R] support the copy-on-write (CoW) or whiteout
  78. behaviors found in \f[B]aufs\f[R] and \f[B]overlayfs\f[R].
  79. You can \f[B]not\f[R] mount a read-only filesystem and write to it.
  80. However, mergerfs will ignore read-only filesystems when creating new
  81. files so you can mix read-write and read-only filesystems.
  82. It also does \f[B]not\f[R] split data across filesystems.
  83. It is not RAID0 / striping.
  84. It is simply a union of other filesystems.
  85. .SH TERMINOLOGY
  86. .IP \[bu] 2
  87. branch: A base path used in the pool.
  88. .IP \[bu] 2
  89. pool: The mergerfs mount.
  90. The union of the branches.
  91. .IP \[bu] 2
  92. relative path: The path in the pool relative to the branch and mount.
  93. .IP \[bu] 2
  94. function: A filesystem call (open, unlink, create, getattr, rmdir, etc.)
  95. .IP \[bu] 2
  96. category: A collection of functions based on basic behavior (action,
  97. create, search).
  98. .IP \[bu] 2
  99. policy: The algorithm used to select a file when performing a function.
  100. .IP \[bu] 2
  101. path preservation: Aspect of some policies which includes checking the
  102. path for which a file would be created.
  103. .SH BASIC SETUP
  104. .PP
  105. If you don\[cq]t already know that you have a special use case then just
  106. start with one of the following option sets.
  107. .SS You need \f[C]mmap\f[R] (used by rtorrent and many sqlite3 base software)
  108. .PP
  109. \f[C]cache.files=partial,dropcacheonclose=true,category.create=mfs\f[R]
  110. .SS You don\[cq]t need \f[C]mmap\f[R]
  111. .PP
  112. \f[C]cache.files=off,dropcacheonclose=true,category.create=mfs\f[R]
  113. .SS Command Line
  114. .PP
  115. \f[C]mergerfs -o cache.files=partial,dropcacheonclose=true,category.create=mfs /mnt/hdd0:/mnt/hdd1 /media\f[R]
  116. .SS /etc/fstab
  117. .PP
  118. \f[C]/mnt/hdd0:/mnt/hdd1 /media fuse.mergerfs cache.files=partial,dropcacheonclose=true,category.create=mfs 0 0\f[R]
  119. .SS systemd mount
  120. .PP
  121. https://github.com/trapexit/mergerfs/wiki/systemd
  122. .IP
  123. .nf
  124. \f[C]
  125. [Unit]
  126. Description=mergerfs service
  127. [Service]
  128. Type=simple
  129. KillMode=none
  130. ExecStart=/usr/bin/mergerfs \[rs]
  131. -f \[rs]
  132. -o cache.files=partial \[rs]
  133. -o dropcacheonclose=true \[rs]
  134. -o category.create=mfs \[rs]
  135. /mnt/hdd0:/mnt/hdd1 \[rs]
  136. /media
  137. ExecStop=/bin/fusermount -uz /media
  138. Restart=on-failure
  139. [Install]
  140. WantedBy=default.target
  141. \f[R]
  142. .fi
  143. .PP
  144. See the mergerfs wiki for real world
  145. deployments (https://github.com/trapexit/mergerfs/wiki/Real-World-Deployments)
  146. for comparisons / ideas.
  147. .SH OPTIONS
  148. .PP
  149. These options are the same regardless of whether you use them with the
  150. \f[C]mergerfs\f[R] commandline program, in fstab, or in a config file.
  151. .SS mount options
  152. .IP \[bu] 2
  153. \f[B]config\f[R]: Path to a config file.
  154. Same arguments as below in key=val / ini style format.
  155. .IP \[bu] 2
  156. \f[B]branches\f[R]: Colon delimited list of branches.
  157. .IP \[bu] 2
  158. \f[B]minfreespace=SIZE\f[R]: The minimum space value used for creation
  159. policies.
  160. Can be overridden by branch specific option.
  161. Understands `K', `M', and `G' to represent kilobyte, megabyte, and
  162. gigabyte respectively.
  163. (default: 4G)
  164. .IP \[bu] 2
  165. \f[B]moveonenospc=BOOL|POLICY\f[R]: When enabled if a \f[B]write\f[R]
  166. fails with \f[B]ENOSPC\f[R] (no space left on device) or
  167. \f[B]EDQUOT\f[R] (disk quota exceeded) the policy selected will run to
  168. find a new location for the file.
  169. An attempt to move the file to that branch will occur (keeping all
  170. metadata possible) and if successful the original is unlinked and the
  171. write retried.
  172. (default: false, true = mfs)
  173. .IP \[bu] 2
  174. \f[B]inodecalc=passthrough|path-hash|devino-hash|hybrid-hash\f[R]:
  175. Selects the inode calculation algorithm.
  176. (default: hybrid-hash)
  177. .IP \[bu] 2
  178. \f[B]dropcacheonclose=BOOL\f[R]: When a file is requested to be closed
  179. call \f[C]posix_fadvise\f[R] on it first to instruct the kernel that we
  180. no longer need the data and it can drop its cache.
  181. Recommended when
  182. \f[B]cache.files=partial|full|auto-full|per-process\f[R] to limit double
  183. caching.
  184. (default: false)
  185. .IP \[bu] 2
  186. \f[B]symlinkify=BOOL\f[R]: When enabled and a file is not writable and
  187. its mtime or ctime is older than \f[B]symlinkify_timeout\f[R] files will
  188. be reported as symlinks to the original files.
  189. Please read more below before using.
  190. (default: false)
  191. .IP \[bu] 2
  192. \f[B]symlinkify_timeout=UINT\f[R]: Time to wait, in seconds, to activate
  193. the \f[B]symlinkify\f[R] behavior.
  194. (default: 3600)
  195. .IP \[bu] 2
  196. \f[B]nullrw=BOOL\f[R]: Turns reads and writes into no-ops.
  197. The request will succeed but do nothing.
  198. Useful for benchmarking mergerfs.
  199. (default: false)
  200. .IP \[bu] 2
  201. \f[B]lazy-umount-mountpoint=BOOL\f[R]: mergerfs will attempt to
  202. \[lq]lazy umount\[rq] the mountpoint before mounting itself.
  203. Useful when performing live upgrades of mergerfs.
  204. (default: false)
  205. .IP \[bu] 2
  206. \f[B]ignorepponrename=BOOL\f[R]: Ignore path preserving on rename.
  207. Typically rename and link act differently depending on the policy of
  208. \f[C]create\f[R] (read below).
  209. Enabling this will cause rename and link to always use the non-path
  210. preserving behavior.
  211. This means files, when renamed or linked, will stay on the same
  212. filesystem.
  213. (default: false)
  214. .IP \[bu] 2
  215. \f[B]export-support=BOOL\f[R]: Sets a low-level FUSE feature intended to
  216. indicate the filesystem can support being exported via NFS.
  217. (default: true)
  218. .IP \[bu] 2
  219. \f[B]security_capability=BOOL\f[R]: If false return ENOATTR when xattr
  220. security.capability is queried.
  221. (default: true)
  222. .IP \[bu] 2
  223. \f[B]xattr=passthrough|noattr|nosys\f[R]: Runtime control of xattrs.
  224. Default is to passthrough xattr requests.
  225. `noattr' will short circuit as if nothing exists.
  226. `nosys' will respond with ENOSYS as if xattrs are not supported or
  227. disabled.
  228. (default: passthrough)
  229. .IP \[bu] 2
  230. \f[B]link_cow=BOOL\f[R]: When enabled if a regular file is opened which
  231. has a link count > 1 it will copy the file to a temporary file and
  232. rename over the original.
  233. Breaking the link and providing a basic copy-on-write function similar
  234. to cow-shell.
  235. (default: false)
  236. .IP \[bu] 2
  237. \f[B]statfs=base|full\f[R]: Controls how statfs works.
  238. `base' means it will always use all branches in statfs calculations.
  239. `full' is in effect path preserving and only includes branches where the
  240. path exists.
  241. (default: base)
  242. .IP \[bu] 2
  243. \f[B]statfs_ignore=none|ro|nc\f[R]: `ro' will cause statfs calculations
  244. to ignore available space for branches mounted or tagged as `read-only'
  245. or `no create'.
  246. `nc' will ignore available space for branches tagged as `no create'.
  247. (default: none)
  248. .IP \[bu] 2
  249. \f[B]nfsopenhack=off|git|all\f[R]: A workaround for exporting mergerfs
  250. over NFS where there are issues with creating files for write while
  251. setting the mode to read-only.
  252. (default: off)
  253. .IP \[bu] 2
  254. \f[B]branches-mount-timeout=UINT\f[R]: Number of seconds to wait at
  255. startup for branches to be a mount other than the mountpoint\[cq]s
  256. filesystem.
  257. (default: 0)
  258. .IP \[bu] 2
  259. \f[B]follow-symlinks=never|directory|regular|all\f[R]: Turns symlinks
  260. into what they point to.
  261. (default: never)
  262. .IP \[bu] 2
  263. \f[B]link-exdev=passthrough|rel-symlink|abs-base-symlink|abs-pool-symlink\f[R]:
  264. When a link fails with EXDEV optionally create a symlink to the file
  265. instead.
  266. .IP \[bu] 2
  267. \f[B]rename-exdev=passthrough|rel-symlink|abs-symlink\f[R]: When a
  268. rename fails with EXDEV optionally move the file to a special directory
  269. and symlink to it.
  270. .IP \[bu] 2
  271. \f[B]readahead=UINT\f[R]: Set readahead (in kilobytes) for mergerfs and
  272. branches if greater than 0.
  273. (default: 0)
  274. .IP \[bu] 2
  275. \f[B]posix_acl=BOOL\f[R]: Enable POSIX ACL support (if supported by
  276. kernel and underlying filesystem).
  277. (default: false)
  278. .IP \[bu] 2
  279. \f[B]async_read=BOOL\f[R]: Perform reads asynchronously.
  280. If disabled or unavailable the kernel will ensure there is at most one
  281. pending read request per file handle and will attempt to order requests
  282. by offset.
  283. (default: true)
  284. .IP \[bu] 2
  285. \f[B]fuse_msg_size=UINT\f[R]: Set the max number of pages per FUSE
  286. message.
  287. Only available on Linux >= 4.20 and ignored otherwise.
  288. (min: 1; max: 256; default: 256)
  289. .IP \[bu] 2
  290. \f[B]threads=INT\f[R]: Number of threads to use.
  291. When used alone (\f[C]process-thread-count=-1\f[R]) it sets the number
  292. of threads reading and processing FUSE messages.
  293. When used together it sets the number of threads reading from FUSE.
  294. When set to zero it will attempt to discover and use the number of
  295. logical cores.
  296. If the thread count is set negative it will look up the number of cores
  297. then divide by the absolute value.
  298. ie.
  299. threads=-2 on an 8 core machine will result in 8 / 2 = 4 threads.
  300. There will always be at least 1 thread.
  301. If set to -1 in combination with \f[C]process-thread-count\f[R] then it
  302. will try to pick reasonable values based on CPU thread count.
  303. NOTE: higher number of threads increases parallelism but usually
  304. decreases throughput.
  305. (default: 0)
  306. .IP \[bu] 2
  307. \f[B]read-thread-count=INT\f[R]: Alias for \f[C]threads\f[R].
  308. .IP \[bu] 2
  309. \f[B]process-thread-count=INT\f[R]: Enables separate thread pool to
  310. asynchronously process FUSE requests.
  311. In this mode \f[C]read-thread-count\f[R] refers to the number of threads
  312. reading FUSE messages which are dispatched to process threads.
  313. -1 means disabled otherwise acts like \f[C]read-thread-count\f[R].
  314. (default: -1)
  315. .IP \[bu] 2
  316. \f[B]process-thread-queue-depth=UINT\f[R]: Sets the number of requests
  317. any single process thread can have queued up at one time.
  318. Meaning the total memory usage of the queues is queue depth multiplied
  319. by the number of process threads plus read thread count.
  320. 0 sets the depth to the same as the process thread count.
  321. (default: 0)
  322. .IP \[bu] 2
  323. \f[B]pin-threads=STR\f[R]: Selects a strategy to pin threads to CPUs
  324. (default: unset)
  325. .IP \[bu] 2
  326. \f[B]flush-on-close=never|always|opened-for-write\f[R]: Flush data cache
  327. on file close.
  328. Mostly for when writeback is enabled or merging network filesystems.
  329. (default: opened-for-write)
  330. .IP \[bu] 2
  331. \f[B]scheduling-priority=INT\f[R]: Set mergerfs\[cq] scheduling
  332. priority.
  333. Valid values range from -20 to 19.
  334. See \f[C]setpriority\f[R] man page for more details.
  335. (default: -10)
  336. .IP \[bu] 2
  337. \f[B]fsname=STR\f[R]: Sets the name of the filesystem as seen in
  338. \f[B]mount\f[R], \f[B]df\f[R], etc.
  339. Defaults to a list of the source paths concatenated together with the
  340. longest common prefix removed.
  341. .IP \[bu] 2
  342. \f[B]func.FUNC=POLICY\f[R]: Sets the specific FUSE function\[cq]s
  343. policy.
  344. See below for the list of value types.
  345. Example: \f[B]func.getattr=newest\f[R]
  346. .IP \[bu] 2
  347. \f[B]func.readdir=seq|cosr|cor|cosr:INT|cor:INT\f[R]: Sets
  348. \f[C]readdir\f[R] policy.
  349. INT value sets the number of threads to use for concurrency.
  350. (default: seq)
  351. .IP \[bu] 2
  352. \f[B]category.action=POLICY\f[R]: Sets policy of all FUSE functions in
  353. the action category.
  354. (default: epall)
  355. .IP \[bu] 2
  356. \f[B]category.create=POLICY\f[R]: Sets policy of all FUSE functions in
  357. the create category.
  358. (default: epmfs)
  359. .IP \[bu] 2
  360. \f[B]category.search=POLICY\f[R]: Sets policy of all FUSE functions in
  361. the search category.
  362. (default: ff)
  363. .IP \[bu] 2
  364. \f[B]cache.open=UINT\f[R]: `open' policy cache timeout in seconds.
  365. (default: 0)
  366. .IP \[bu] 2
  367. \f[B]cache.statfs=UINT\f[R]: `statfs' cache timeout in seconds.
  368. (default:
  369. .RS 2
  370. .RE
  371. .IP \[bu] 2
  372. \f[B]cache.attr=UINT\f[R]: File attribute cache timeout in seconds.
  373. (default: 1)
  374. .IP \[bu] 2
  375. \f[B]cache.entry=UINT\f[R]: File name lookup cache timeout in seconds.
  376. (default: 1)
  377. .IP \[bu] 2
  378. \f[B]cache.negative_entry=UINT\f[R]: Negative file name lookup cache
  379. timeout in seconds.
  380. (default: 0)
  381. .IP \[bu] 2
  382. \f[B]cache.files=libfuse|off|partial|full|auto-full|per-process\f[R]:
  383. File page caching mode (default: libfuse)
  384. .IP \[bu] 2
  385. \f[B]cache.files.process-names=LIST\f[R]: A pipe | delimited list of
  386. process comm (https://man7.org/linux/man-pages/man5/proc.5.html) names
  387. to enable page caching for when \f[C]cache.files=per-process\f[R].
  388. (default: \[lq]rtorrent|qbittorrent-nox\[rq])
  389. .IP \[bu] 2
  390. \f[B]cache.writeback=BOOL\f[R]: Enable kernel writeback caching
  391. (default: false)
  392. .IP \[bu] 2
  393. \f[B]cache.symlinks=BOOL\f[R]: Cache symlinks (if supported by kernel)
  394. (default: false)
  395. .IP \[bu] 2
  396. \f[B]cache.readdir=BOOL\f[R]: Cache readdir (if supported by kernel)
  397. (default: false)
  398. .IP \[bu] 2
  399. \f[B]parallel-direct-writes=BOOL\f[R]: Allow the kernel to dispatch
  400. multiple, parallel (non-extending) write requests for files opened with
  401. \f[C]cache.files=per-process\f[R] (if the process is not in
  402. \f[C]process-names\f[R]) or \f[C]cache.files=off\f[R].
  403. (This requires kernel support, and was added in v6.2)
  404. .IP \[bu] 2
  405. \f[B]direct_io\f[R]: deprecated - Bypass page cache.
  406. Use \f[C]cache.files=off\f[R] instead.
  407. (default: false)
  408. .IP \[bu] 2
  409. \f[B]kernel_cache\f[R]: deprecated - Do not invalidate data cache on
  410. file open.
  411. Use \f[C]cache.files=full\f[R] instead.
  412. (default: false)
  413. .IP \[bu] 2
  414. \f[B]auto_cache\f[R]: deprecated - Invalidate data cache if file mtime
  415. or size change.
  416. Use \f[C]cache.files=auto-full\f[R] instead.
  417. (default: false)
  418. .IP \[bu] 2
  419. \f[B]async_read\f[R]: deprecated - Perform reads asynchronously.
  420. Use \f[C]async_read=true\f[R] instead.
  421. .IP \[bu] 2
  422. \f[B]sync_read\f[R]: deprecated - Perform reads synchronously.
  423. Use \f[C]async_read=false\f[R] instead.
  424. .IP \[bu] 2
  425. \f[B]splice_read\f[R]: deprecated - Does nothing.
  426. .IP \[bu] 2
  427. \f[B]splice_write\f[R]: deprecated - Does nothing.
  428. .IP \[bu] 2
  429. \f[B]splice_move\f[R]: deprecated - Does nothing.
  430. .IP \[bu] 2
  431. \f[B]allow_other\f[R]: deprecated - mergerfs v2.35.0 and newer sets this
  432. FUSE option automatically if running as root.
  433. .IP \[bu] 2
  434. \f[B]use_ino\f[R]: deprecated - mergerfs should always control inode
  435. calculation so this is enabled all the time.
  436. .PP
  437. \f[B]NOTE:\f[R] Options are evaluated in the order listed so if the
  438. options are \f[B]func.rmdir=rand,category.action=ff\f[R] the
  439. \f[B]action\f[R] category setting will override the \f[B]rmdir\f[R]
  440. setting.
  441. .PP
  442. \f[B]NOTE:\f[R] Always look at the documentation for the version of
  443. mergerfs you\[cq]re using.
  444. Not all features are available in older releases.
  445. Use \f[C]man mergerfs\f[R] or find the docs as linked in the release.
  446. .SS Value Types
  447. .IP \[bu] 2
  448. BOOL = `true' | `false'
  449. .IP \[bu] 2
  450. INT = [MIN_INT,MAX_INT]
  451. .IP \[bu] 2
  452. UINT = [0,MAX_INT]
  453. .IP \[bu] 2
  454. SIZE = `NNM'; NN = INT, M = `K' | `M' | `G' | `T'
  455. .IP \[bu] 2
  456. STR = string (may refer to an enumerated value, see details of argument)
  457. .IP \[bu] 2
  458. FUNC = filesystem function
  459. .IP \[bu] 2
  460. CATEGORY = function category
  461. .IP \[bu] 2
  462. POLICY = mergerfs function policy
  463. .SS branches
  464. .PP
  465. The `branches' argument is a colon (`:') delimited list of paths to be
  466. pooled together.
  467. It does not matter if the paths are on the same or different filesystems
  468. nor does it matter the filesystem type (within reason).
  469. Used and available space will not be duplicated for paths on the same
  470. filesystem and any features which aren\[cq]t supported by the underlying
  471. filesystem (such as file attributes or extended attributes) will return
  472. the appropriate errors.
  473. .PP
  474. Branches currently have two options which can be set.
  475. A type which impacts whether or not the branch is included in a policy
  476. calculation and a individual minfreespace value.
  477. The values are set by prepending an \f[C]=\f[R] at the end of a branch
  478. designation and using commas as delimiters.
  479. Example: \f[C]/mnt/drive=RW,1234\f[R]
  480. .SS branch mode
  481. .IP \[bu] 2
  482. RW: (read/write) - Default behavior.
  483. Will be eligible in all policy categories.
  484. .IP \[bu] 2
  485. RO: (read-only) - Will be excluded from \f[C]create\f[R] and
  486. \f[C]action\f[R] policies.
  487. Same as a read-only mounted filesystem would be (though faster to
  488. process).
  489. .IP \[bu] 2
  490. NC: (no-create) - Will be excluded from \f[C]create\f[R] policies.
  491. You can\[cq]t create on that branch but you can change or delete.
  492. .SS minfreespace
  493. .PP
  494. Same purpose and syntax as the global option but specific to the branch.
  495. If not set the global value is used.
  496. .SS globbing
  497. .PP
  498. To make it easier to include multiple branches mergerfs supports
  499. globbing (http://linux.die.net/man/7/glob).
  500. \f[B]The globbing tokens MUST be escaped when using via the shell else
  501. the shell itself will apply the glob itself.\f[R]
  502. .IP
  503. .nf
  504. \f[C]
  505. # mergerfs /mnt/hdd\[rs]*:/mnt/ssd /media
  506. \f[R]
  507. .fi
  508. .PP
  509. The above line will use all mount points in /mnt prefixed with
  510. \f[B]hdd\f[R] and \f[B]ssd\f[R].
  511. .PP
  512. To have the pool mounted at boot or otherwise accessible from related
  513. tools use \f[B]/etc/fstab\f[R].
  514. .IP
  515. .nf
  516. \f[C]
  517. # <file system> <mount point> <type> <options> <dump> <pass>
  518. /mnt/hdd*:/mnt/ssd /media fuse.mergerfs minfreespace=16G 0 0
  519. \f[R]
  520. .fi
  521. .PP
  522. \f[B]NOTE:\f[R] the globbing is done at mount or when updated using the
  523. runtime API.
  524. If a new directory is added matching the glob after the fact it will not
  525. be automatically included.
  526. .PP
  527. \f[B]NOTE:\f[R] for mounting via \f[B]fstab\f[R] to work you must have
  528. \f[B]mount.fuse\f[R] installed.
  529. For Ubuntu/Debian it is included in the \f[B]fuse\f[R] package.
  530. .SS inodecalc
  531. .PP
  532. Inodes (st_ino) are unique identifiers within a filesystem.
  533. Each mounted filesystem has device ID (st_dev) as well and together they
  534. can uniquely identify a file on the whole of the system.
  535. Entries on the same device with the same inode are in fact references to
  536. the same underlying file.
  537. It is a many to one relationship between names and an inode.
  538. Directories, however, do not have multiple links on most systems due to
  539. the complexity they add.
  540. .PP
  541. FUSE allows the server (mergerfs) to set inode values but not device
  542. IDs.
  543. Creating an inode value is somewhat complex in mergerfs\[cq] case as
  544. files aren\[cq]t really in its control.
  545. If a policy changes what directory or file is to be selected or
  546. something changes out of band it becomes unclear what value should be
  547. used.
  548. Most software does not to care what the values are but those that do
  549. often break if a value changes unexpectedly.
  550. The tool \f[C]find\f[R] will abort a directory walk if it sees a
  551. directory inode change.
  552. NFS can return stale handle errors if the inode changes out of band.
  553. File dedup tools will usually leverage device ids and inodes as a
  554. shortcut in searching for duplicate files and would resort to full file
  555. comparisons should it find different inode values.
  556. .PP
  557. mergerfs offers multiple ways to calculate the inode in hopes of
  558. covering different usecases.
  559. .IP \[bu] 2
  560. passthrough: Passes through the underlying inode value.
  561. Mostly intended for testing as using this does not address any of the
  562. problems mentioned above and could confuse file deduplication software
  563. as inodes from different filesystems can be the same.
  564. .IP \[bu] 2
  565. path-hash: Hashes the relative path of the entry in question.
  566. The underlying file\[cq]s values are completely ignored.
  567. This means the inode value will always be the same for that file path.
  568. This is useful when using NFS and you make changes out of band such as
  569. copy data between branches.
  570. This also means that entries that do point to the same file will not be
  571. recognizable via inodes.
  572. That \f[B]does not\f[R] mean hard links don\[cq]t work.
  573. They will.
  574. .IP \[bu] 2
  575. path-hash32: 32bit version of path-hash.
  576. .IP \[bu] 2
  577. devino-hash: Hashes the device id and inode of the underlying entry.
  578. This won\[cq]t prevent issues with NFS should the policy pick a
  579. different file or files move out of band but will present the same inode
  580. for underlying files that do too.
  581. .IP \[bu] 2
  582. devino-hash32: 32bit version of devino-hash.
  583. .IP \[bu] 2
  584. hybrid-hash: Performs \f[C]path-hash\f[R] on directories and
  585. \f[C]devino-hash\f[R] on other file types.
  586. Since directories can\[cq]t have hard links the static value won\[cq]t
  587. make a difference and the files will get values useful for finding
  588. duplicates.
  589. Probably the best to use if not using NFS.
  590. As such it is the default.
  591. .IP \[bu] 2
  592. hybrid-hash32: 32bit version of hybrid-hash.
  593. .PP
  594. 32bit versions are provided as there is some software which does not
  595. handle 64bit inodes well.
  596. .PP
  597. While there is a risk of hash collision in tests of a couple million
  598. entries there were zero collisions.
  599. Unlike a typical filesystem FUSE filesystems can reuse inodes and not
  600. refer to the same entry.
  601. The internal identifier used to reference a file in FUSE is different
  602. from the inode value presented.
  603. The former is the \f[C]nodeid\f[R] and is actually a tuple of 2 64bit
  604. values: \f[C]nodeid\f[R] and \f[C]generation\f[R].
  605. This tuple is not client facing.
  606. The inode that is presented to the client is passed through the kernel
  607. uninterpreted.
  608. .PP
  609. From FUSE docs for \f[C]use_ino\f[R]:
  610. .IP
  611. .nf
  612. \f[C]
  613. Honor the st_ino field in the functions getattr() and
  614. fill_dir(). This value is used to fill in the st_ino field
  615. in the stat(2), lstat(2), fstat(2) functions and the d_ino
  616. field in the readdir(2) function. The filesystem does not
  617. have to guarantee uniqueness, however some applications
  618. rely on this value being unique for the whole filesystem.
  619. Note that this does *not* affect the inode that libfuse
  620. and the kernel use internally (also called the \[dq]nodeid\[dq]).
  621. \f[R]
  622. .fi
  623. .PP
  624. As of version 2.35.0 the \f[C]use_ino\f[R] option has been removed.
  625. mergerfs should always be managing inode values.
  626. .SS pin-threads
  627. .PP
  628. Simple strategies for pinning read and/or process threads.
  629. If process threads are not enabled than the strategy simply works on the
  630. read threads.
  631. Invalid values are ignored.
  632. .IP \[bu] 2
  633. R1L: All read threads pinned to a single logical CPU.
  634. .IP \[bu] 2
  635. R1P: All read threads pinned to a single physical CPU.
  636. .IP \[bu] 2
  637. RP1L: All read and process threads pinned to a single logical CPU.
  638. .IP \[bu] 2
  639. RP1P: All read and process threads pinned to a single physical CPU.
  640. .IP \[bu] 2
  641. R1LP1L: All read threads pinned to a single logical CPU, all process
  642. threads pinned to a (if possible) different logical CPU.
  643. .IP \[bu] 2
  644. R1PP1P: All read threads pinned to a single physical CPU, all process
  645. threads pinned to a (if possible) different logical CPU.
  646. .IP \[bu] 2
  647. RPSL: All read and process threads are spread across all logical CPUs.
  648. .IP \[bu] 2
  649. RPSP: All read and process threads are spread across all physical CPUs.
  650. .IP \[bu] 2
  651. R1PPSP: All read threads are pinned to a single physical CPU while
  652. process threads are spread across all other phsycial CPUs.
  653. .SS fuse_msg_size
  654. .PP
  655. FUSE applications communicate with the kernel over a special character
  656. device: \f[C]/dev/fuse\f[R].
  657. A large portion of the overhead associated with FUSE is the cost of
  658. going back and forth from user space and kernel space over that device.
  659. Generally speaking the fewer trips needed the better the performance
  660. will be.
  661. Reducing the number of trips can be done a number of ways.
  662. Kernel level caching and increasing message sizes being two significant
  663. ones.
  664. When it comes to reads and writes if the message size is doubled the
  665. number of trips are approximately halved.
  666. .PP
  667. In Linux 4.20 a new feature was added allowing the negotiation of the
  668. max message size.
  669. Since the size is in multiples of
  670. pages (https://en.wikipedia.org/wiki/Page_(computer_memory)) the feature
  671. is called \f[C]max_pages\f[R].
  672. There is a maximum \f[C]max_pages\f[R] value of 256 (1MiB) and minimum
  673. of 1 (4KiB).
  674. The default used by Linux >=4.20, and hardcoded value used before 4.20,
  675. is 32 (128KiB).
  676. In mergerfs its referred to as \f[C]fuse_msg_size\f[R] to make it clear
  677. what it impacts and provide some abstraction.
  678. .PP
  679. Since there should be no downsides to increasing \f[C]fuse_msg_size\f[R]
  680. / \f[C]max_pages\f[R], outside a minor bump in RAM usage due to larger
  681. message buffers, mergerfs defaults the value to 256.
  682. On kernels before 4.20 the value has no effect.
  683. The reason the value is configurable is to enable experimentation and
  684. benchmarking.
  685. See the BENCHMARKING section for examples.
  686. .SS follow-symlinks
  687. .PP
  688. This feature, when enabled, will cause symlinks to be interpreted by
  689. mergerfs as their target (depending on the mode).
  690. .PP
  691. When there is a getattr/stat request for a file mergerfs will check if
  692. the file is a symlink and depending on the \f[C]follow-symlinks\f[R]
  693. setting will replace the information about the symlink with that of that
  694. which it points to.
  695. .PP
  696. When unlink\[cq]ing or rmdir\[cq]ing the followed symlink it will remove
  697. the symlink itself and not that which it points to.
  698. .IP \[bu] 2
  699. never: Behave as normal.
  700. Symlinks are treated as such.
  701. .IP \[bu] 2
  702. directory: Resolve symlinks only which point to directories.
  703. .IP \[bu] 2
  704. regular: Resolve symlinks only which point to regular files.
  705. .IP \[bu] 2
  706. all: Resolve all symlinks to that which they point to.
  707. .PP
  708. Symlinks which do not point to anything are left as is.
  709. .PP
  710. WARNING: This feature works but there might be edge cases yet found.
  711. If you find any odd behaviors please file a ticket on
  712. github (https://github.com/trapexit/mergerfs/issues).
  713. .SS link-exdev
  714. .PP
  715. If using path preservation and a \f[C]link\f[R] fails with EXDEV make a
  716. call to \f[C]symlink\f[R] where the \f[C]target\f[R] is the
  717. \f[C]oldlink\f[R] and the \f[C]linkpath\f[R] is the \f[C]newpath\f[R].
  718. The \f[C]target\f[R] value is determined by the value of
  719. \f[C]link-exdev\f[R].
  720. .IP \[bu] 2
  721. passthrough: Return EXDEV as normal.
  722. .IP \[bu] 2
  723. rel-symlink: A relative path from the \f[C]newpath\f[R].
  724. .IP \[bu] 2
  725. abs-base-symlink: A absolute value using the underlying branch.
  726. .IP \[bu] 2
  727. abs-pool-symlink: A absolute value using the mergerfs mount point.
  728. .PP
  729. NOTE: It is possible that some applications check the file they link.
  730. In those cases it is possible it will error or complain.
  731. .SS rename-exdev
  732. .PP
  733. If using path preservation and a \f[C]rename\f[R] fails with EXDEV:
  734. .IP "1." 3
  735. Move file from \f[B]/branch/a/b/c\f[R] to
  736. \f[B]/branch/.mergerfs_rename_exdev/a/b/c\f[R].
  737. .IP "2." 3
  738. symlink the rename\[cq]s \f[C]newpath\f[R] to the moved file.
  739. .PP
  740. The \f[C]target\f[R] value is determined by the value of
  741. \f[C]rename-exdev\f[R].
  742. .IP \[bu] 2
  743. passthrough: Return EXDEV as normal.
  744. .IP \[bu] 2
  745. rel-symlink: A relative path from the \f[C]newpath\f[R].
  746. .IP \[bu] 2
  747. abs-symlink: A absolute value using the mergerfs mount point.
  748. .PP
  749. NOTE: It is possible that some applications check the file they rename.
  750. In those cases it is possible it will error or complain.
  751. .PP
  752. NOTE: The reason \f[C]abs-symlink\f[R] is not split into two like
  753. \f[C]link-exdev\f[R] is due to the complexities in managing absolute
  754. base symlinks when multiple \f[C]oldpaths\f[R] exist.
  755. .SS symlinkify
  756. .PP
  757. Due to the levels of indirection introduced by mergerfs and the
  758. underlying technology FUSE there can be varying levels of performance
  759. degradation.
  760. This feature will turn non-directories which are not writable into
  761. symlinks to the original file found by the \f[C]readlink\f[R] policy
  762. after the mtime and ctime are older than the timeout.
  763. .PP
  764. \f[B]WARNING:\f[R] The current implementation has a known issue in which
  765. if the file is open and being used when the file is converted to a
  766. symlink then the application which has that file open will receive an
  767. error when using it.
  768. This is unlikely to occur in practice but is something to keep in mind.
  769. .PP
  770. \f[B]WARNING:\f[R] Some backup solutions, such as CrashPlan, do not
  771. backup the target of a symlink.
  772. If using this feature it will be necessary to point any backup software
  773. to the original filesystems or configure the software to follow symlinks
  774. if such an option is available.
  775. Alternatively create two mounts.
  776. One for backup and one for general consumption.
  777. .SS nullrw
  778. .PP
  779. Due to how FUSE works there is an overhead to all requests made to a
  780. FUSE filesystem that wouldn\[cq]t exist for an in kernel one.
  781. Meaning that even a simple passthrough will have some slowdown.
  782. However, generally the overhead is minimal in comparison to the cost of
  783. the underlying I/O.
  784. By disabling the underlying I/O we can test the theoretical performance
  785. boundaries.
  786. .PP
  787. By enabling \f[C]nullrw\f[R] mergerfs will work as it always does
  788. \f[B]except\f[R] that all reads and writes will be no-ops.
  789. A write will succeed (the size of the write will be returned as if it
  790. were successful) but mergerfs does nothing with the data it was given.
  791. Similarly a read will return the size requested but won\[cq]t touch the
  792. buffer.
  793. .PP
  794. See the BENCHMARKING section for suggestions on how to test.
  795. .SS xattr
  796. .PP
  797. Runtime extended attribute support can be managed via the
  798. \f[C]xattr\f[R] option.
  799. By default it will passthrough any xattr calls.
  800. Given xattr support is rarely used and can have significant performance
  801. implications mergerfs allows it to be disabled at runtime.
  802. The performance problems mostly comes when file caching is enabled.
  803. The kernel will send a \f[C]getxattr\f[R] for
  804. \f[C]security.capability\f[R] \f[I]before every single write\f[R].
  805. It doesn\[cq]t cache the responses to any \f[C]getxattr\f[R].
  806. This might be addressed in the future but for now mergerfs can really
  807. only offer the following workarounds.
  808. .PP
  809. \f[C]noattr\f[R] will cause mergerfs to short circuit all xattr calls
  810. and return ENOATTR where appropriate.
  811. mergerfs still gets all the requests but they will not be forwarded on
  812. to the underlying filesystems.
  813. The runtime control will still function in this mode.
  814. .PP
  815. \f[C]nosys\f[R] will cause mergerfs to return ENOSYS for any xattr call.
  816. The difference with \f[C]noattr\f[R] is that the kernel will cache this
  817. fact and itself short circuit future calls.
  818. This is more efficient than \f[C]noattr\f[R] but will cause
  819. mergerfs\[cq] runtime control via the hidden file to stop working.
  820. .SS nfsopenhack
  821. .PP
  822. NFS is not fully POSIX compliant and historically certain behaviors,
  823. such as opening files with O_EXCL, are not or not well supported.
  824. When mergerfs (or any FUSE filesystem) is exported over NFS some of
  825. these issues come up due to how NFS and FUSE interact.
  826. .PP
  827. This hack addresses the issue where the creation of a file with a
  828. read-only mode but with a read/write or write only flag.
  829. Normally this is perfectly valid but NFS chops the one open call into
  830. multiple calls.
  831. Exactly how it is translated depends on the configuration and versions
  832. of the NFS server and clients but it results in a permission error
  833. because a normal user is not allowed to open a read-only file as
  834. writable.
  835. .PP
  836. Even though it\[cq]s a more niche situation this hack breaks normal
  837. security and behavior and as such is \f[C]off\f[R] by default.
  838. If set to \f[C]git\f[R] it will only perform the hack when the path in
  839. question includes \f[C]/.git/\f[R].
  840. \f[C]all\f[R] will result it applying anytime a read-only file which is
  841. empty is opened for writing.
  842. .SS export-support
  843. .PP
  844. In theory this flag should not be exposed to the end user.
  845. It is a low-level FUSE flag which indicates whether or not the kernel
  846. can send certain kinds of messages to it for the purposes of using with
  847. NFS.
  848. mergerfs does support these messages but due to a possible bug in the
  849. Linux kernel this option needs to be configurable.
  850. As it turns out at least certain versions of NFS can still work when
  851. disabled and no longer triggers the bug.
  852. .PP
  853. While it may be safe to default this setting to \f[C]false\f[R] in an
  854. abundance of caution it is being left enabled by default.
  855. .PP
  856. Given that this flag is set when the FUSE connection is first initiated
  857. it is not possible to change during run time.
  858. .PP
  859. See Kernel Issues &
  860. Bugs (https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs)
  861. for more details.
  862. .SH FUNCTIONS, CATEGORIES and POLICIES
  863. .PP
  864. The POSIX filesystem API is made up of a number of functions.
  865. \f[B]creat\f[R], \f[B]stat\f[R], \f[B]chown\f[R], etc.
  866. For ease of configuration in mergerfs most of the core functions are
  867. grouped into 3 categories: \f[B]action\f[R], \f[B]create\f[R], and
  868. \f[B]search\f[R].
  869. These functions and categories can be assigned a policy which dictates
  870. which branch is chosen when performing that function.
  871. .PP
  872. Some functions, listed in the category \f[C]N/A\f[R] below, can not be
  873. assigned the normal policies.
  874. These functions work with file handles, rather than file paths, which
  875. were created by \f[C]open\f[R] or \f[C]create\f[R].
  876. That said many times the current FUSE kernel driver will not always
  877. provide the file handle when a client calls \f[C]fgetattr\f[R],
  878. \f[C]fchown\f[R], \f[C]fchmod\f[R], \f[C]futimens\f[R],
  879. \f[C]ftruncate\f[R], etc.
  880. This means it will call the regular, path based, versions.
  881. \f[C]statfs\f[R]\[cq]s behavior can be modified via other options.
  882. .PP
  883. When using policies which are based on a branch\[cq]s available space
  884. the base path provided is used.
  885. Not the full path to the file in question.
  886. Meaning that mounts in the branch won\[cq]t be considered in the space
  887. calculations.
  888. The reason is that it doesn\[cq]t really work for non-path preserving
  889. policies and can lead to non-obvious behaviors.
  890. .PP
  891. NOTE: While any policy can be assigned to a function or category, some
  892. may not be very useful in practice.
  893. For instance: \f[B]rand\f[R] (random) may be useful for file creation
  894. (create) but could lead to very odd behavior if used for \f[C]chmod\f[R]
  895. if there were more than one copy of the file.
  896. .SS Functions and their Category classifications
  897. .PP
  898. .TS
  899. tab(@);
  900. lw(7.4n) lw(62.6n).
  901. T{
  902. Category
  903. T}@T{
  904. FUSE Functions
  905. T}
  906. _
  907. T{
  908. action
  909. T}@T{
  910. chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate,
  911. unlink, utimens
  912. T}
  913. T{
  914. create
  915. T}@T{
  916. create, mkdir, mknod, symlink
  917. T}
  918. T{
  919. search
  920. T}@T{
  921. access, getattr, getxattr, ioctl (directories), listxattr, open,
  922. readlink
  923. T}
  924. T{
  925. N/A
  926. T}@T{
  927. fchmod, fchown, futimens, ftruncate, fallocate, fgetattr, fsync, ioctl
  928. (files), read, readdir, release, statfs, write, copy_file_range
  929. T}
  930. .TE
  931. .PP
  932. In cases where something may be searched for (such as a path to clone)
  933. \f[B]getattr\f[R] will usually be used.
  934. .SS Policies
  935. .PP
  936. A policy is the algorithm used to choose a branch or branches for a
  937. function to work on or generally how the function behaves.
  938. .PP
  939. Any function in the \f[C]create\f[R] category will clone the relative
  940. path if needed.
  941. Some other functions (\f[C]rename\f[R],\f[C]link\f[R],\f[C]ioctl\f[R])
  942. have special requirements or behaviors which you can read more about
  943. below.
  944. .SS Filtering
  945. .PP
  946. Most policies basically search branches and create a list of files /
  947. paths for functions to work on.
  948. The policy is responsible for filtering and sorting the branches.
  949. Filters include \f[B]minfreespace\f[R], whether or not a branch is
  950. mounted read-only, and the branch tagging (RO,NC,RW).
  951. These filters are applied across most policies.
  952. .IP \[bu] 2
  953. No \f[B]search\f[R] function policies filter.
  954. .IP \[bu] 2
  955. All \f[B]action\f[R] function policies filter out branches which are
  956. mounted \f[B]read-only\f[R] or tagged as \f[B]RO (read-only)\f[R].
  957. .IP \[bu] 2
  958. All \f[B]create\f[R] function policies filter out branches which are
  959. mounted \f[B]read-only\f[R], tagged \f[B]RO (read-only)\f[R] or \f[B]NC
  960. (no create)\f[R], or has available space less than
  961. \f[C]minfreespace\f[R].
  962. .PP
  963. Policies may have their own additional filtering such as those that
  964. require existing paths to be present.
  965. .PP
  966. If all branches are filtered an error will be returned.
  967. Typically \f[B]EROFS\f[R] (read-only filesystem) or \f[B]ENOSPC\f[R] (no
  968. space left on device) depending on the most recent reason for filtering
  969. a branch.
  970. \f[B]ENOENT\f[R] will be returned if no eligible branch is found.
  971. .PP
  972. If \f[B]create\f[R], \f[B]mkdir\f[R], \f[B]mknod\f[R], or
  973. \f[B]symlink\f[R] fail with \f[C]EROFS\f[R] or other fundimental errors
  974. then mergerfs will mark any branch found to be read-only as such (IE
  975. will set the mode \f[C]RO\f[R]) and will rerun the policy and try again.
  976. This is mostly for \f[C]ext4\f[R] filesystems that can suddenly become
  977. read-only when it encounters an error.
  978. .SS Path Preservation
  979. .PP
  980. Policies, as described below, are of two basic classifications.
  981. \f[C]path preserving\f[R] and \f[C]non-path preserving\f[R].
  982. .PP
  983. All policies which start with \f[C]ep\f[R] (\f[B]epff\f[R],
  984. \f[B]eplfs\f[R], \f[B]eplus\f[R], \f[B]epmfs\f[R], \f[B]eprand\f[R]) are
  985. \f[C]path preserving\f[R].
  986. \f[C]ep\f[R] stands for \f[C]existing path\f[R].
  987. .PP
  988. A path preserving policy will only consider branches where the relative
  989. path being accessed already exists.
  990. .PP
  991. When using non-path preserving policies paths will be cloned to target
  992. branches as necessary.
  993. .PP
  994. With the \f[C]msp\f[R] or \f[C]most shared path\f[R] policies they are
  995. defined as \f[C]path preserving\f[R] for the purpose of controlling
  996. \f[C]link\f[R] and \f[C]rename\f[R]\[cq]s behaviors since
  997. \f[C]ignorepponrename\f[R] is available to disable that behavior.
  998. .SS Policy descriptions
  999. .PP
  1000. A policy\[cq]s behavior differs, as mentioned above, based on the
  1001. function it is used with.
  1002. Sometimes it really might not make sense to even offer certain policies
  1003. because they are literally the same as others but it makes things a bit
  1004. more uniform.
  1005. .PP
  1006. .TS
  1007. tab(@);
  1008. lw(16.2n) lw(53.8n).
  1009. T{
  1010. Policy
  1011. T}@T{
  1012. Description
  1013. T}
  1014. _
  1015. T{
  1016. all
  1017. T}@T{
  1018. Search: For \f[B]mkdir\f[R], \f[B]mknod\f[R], and \f[B]symlink\f[R] it
  1019. will apply to all branches.
  1020. \f[B]create\f[R] works like \f[B]ff\f[R].
  1021. T}
  1022. T{
  1023. epall (existing path, all)
  1024. T}@T{
  1025. For \f[B]mkdir\f[R], \f[B]mknod\f[R], and \f[B]symlink\f[R] it will
  1026. apply to all found.
  1027. \f[B]create\f[R] works like \f[B]epff\f[R] (but more expensive because
  1028. it doesn\[cq]t stop after finding a valid branch).
  1029. T}
  1030. T{
  1031. epff (existing path, first found)
  1032. T}@T{
  1033. Given the order of the branches, as defined at mount time or configured
  1034. at runtime, act on the first one found where the relative path exists.
  1035. T}
  1036. T{
  1037. eplfs (existing path, least free space)
  1038. T}@T{
  1039. Of all the branches on which the relative path exists choose the branch
  1040. with the least free space.
  1041. T}
  1042. T{
  1043. eplus (existing path, least used space)
  1044. T}@T{
  1045. Of all the branches on which the relative path exists choose the branch
  1046. with the least used space.
  1047. T}
  1048. T{
  1049. epmfs (existing path, most free space)
  1050. T}@T{
  1051. Of all the branches on which the relative path exists choose the branch
  1052. with the most free space.
  1053. T}
  1054. T{
  1055. eppfrd (existing path, percentage free random distribution)
  1056. T}@T{
  1057. Like \f[B]pfrd\f[R] but limited to existing paths.
  1058. T}
  1059. T{
  1060. eprand (existing path, random)
  1061. T}@T{
  1062. Calls \f[B]epall\f[R] and then randomizes.
  1063. Returns 1.
  1064. T}
  1065. T{
  1066. ff (first found)
  1067. T}@T{
  1068. Given the order of the branches, as defined at mount time or configured
  1069. at runtime, act on the first one found.
  1070. T}
  1071. T{
  1072. lfs (least free space)
  1073. T}@T{
  1074. Pick the branch with the least available free space.
  1075. T}
  1076. T{
  1077. lus (least used space)
  1078. T}@T{
  1079. Pick the branch with the least used space.
  1080. T}
  1081. T{
  1082. mfs (most free space)
  1083. T}@T{
  1084. Pick the branch with the most available free space.
  1085. T}
  1086. T{
  1087. msplfs (most shared path, least free space)
  1088. T}@T{
  1089. Like \f[B]eplfs\f[R] but if it fails to find a branch it will try again
  1090. with the parent directory.
  1091. Continues this pattern till finding one.
  1092. T}
  1093. T{
  1094. msplus (most shared path, least used space)
  1095. T}@T{
  1096. Like \f[B]eplus\f[R] but if it fails to find a branch it will try again
  1097. with the parent directory.
  1098. Continues this pattern till finding one.
  1099. T}
  1100. T{
  1101. mspmfs (most shared path, most free space)
  1102. T}@T{
  1103. Like \f[B]epmfs\f[R] but if it fails to find a branch it will try again
  1104. with the parent directory.
  1105. Continues this pattern till finding one.
  1106. T}
  1107. T{
  1108. msppfrd (most shared path, percentage free random distribution)
  1109. T}@T{
  1110. Like \f[B]eppfrd\f[R] but if it fails to find a branch it will try again
  1111. with the parent directory.
  1112. Continues this pattern till finding one.
  1113. T}
  1114. T{
  1115. newest
  1116. T}@T{
  1117. Pick the file / directory with the largest mtime.
  1118. T}
  1119. T{
  1120. pfrd (percentage free random distribution)
  1121. T}@T{
  1122. Chooses a branch at random with the likelihood of selection based on a
  1123. branch\[cq]s available space relative to the total.
  1124. T}
  1125. T{
  1126. rand (random)
  1127. T}@T{
  1128. Calls \f[B]all\f[R] and then randomizes.
  1129. Returns 1 branch.
  1130. T}
  1131. .TE
  1132. .PP
  1133. \f[B]NOTE:\f[R] If you are using an underlying filesystem that reserves
  1134. blocks such as ext2, ext3, or ext4 be aware that mergerfs respects the
  1135. reservation by using \f[C]f_bavail\f[R] (number of free blocks for
  1136. unprivileged users) rather than \f[C]f_bfree\f[R] (number of free
  1137. blocks) in policy calculations.
  1138. \f[B]df\f[R] does NOT use \f[C]f_bavail\f[R], it uses \f[C]f_bfree\f[R],
  1139. so direct comparisons between \f[B]df\f[R] output and mergerfs\[cq]
  1140. policies is not appropriate.
  1141. .SS Defaults
  1142. .PP
  1143. .TS
  1144. tab(@);
  1145. l l.
  1146. T{
  1147. Category
  1148. T}@T{
  1149. Policy
  1150. T}
  1151. _
  1152. T{
  1153. action
  1154. T}@T{
  1155. epall
  1156. T}
  1157. T{
  1158. create
  1159. T}@T{
  1160. epmfs
  1161. T}
  1162. T{
  1163. search
  1164. T}@T{
  1165. ff
  1166. T}
  1167. .TE
  1168. .SS func.readdir
  1169. .PP
  1170. examples: \f[C]func.readdir=seq\f[R], \f[C]func.readdir=cor:4\f[R]
  1171. .PP
  1172. \f[C]readdir\f[R] has policies to control how it manages reading
  1173. directory content.
  1174. .PP
  1175. .TS
  1176. tab(@);
  1177. lw(26.7n) lw(43.3n).
  1178. T{
  1179. Policy
  1180. T}@T{
  1181. Description
  1182. T}
  1183. _
  1184. T{
  1185. seq
  1186. T}@T{
  1187. \[lq]sequential\[rq] : Iterate over branches in the order defined.
  1188. This is the default and traditional behavior found prior to the readdir
  1189. policy introduction.
  1190. T}
  1191. T{
  1192. cosr
  1193. T}@T{
  1194. \[lq]concurrent open, sequential read\[rq] : Concurrently open branch
  1195. directories using a thread pool and process them in order of definition.
  1196. This keeps memory and CPU usage low while also reducing the time spent
  1197. waiting on branches to respond.
  1198. Number of threads defaults to the number of logical cores.
  1199. Can be overwritten via the syntax \f[C]func.readdir=cosr:N\f[R] where
  1200. \f[C]N\f[R] is the number of threads.
  1201. T}
  1202. T{
  1203. cor
  1204. T}@T{
  1205. \[lq]concurrent open and read\[rq] : Concurrently open branch
  1206. directories and immediately start reading their contents using a thread
  1207. pool.
  1208. This will result in slightly higher memory and CPU usage but reduced
  1209. latency.
  1210. Particularly when using higher latency / slower speed network filesystem
  1211. branches.
  1212. Unlike \f[C]seq\f[R] and \f[C]cosr\f[R] the order of files could change
  1213. due the async nature of the thread pool.
  1214. Number of threads defaults to the number of logical cores.
  1215. Can be overwritten via the syntax \f[C]func.readdir=cor:N\f[R] where
  1216. \f[C]N\f[R] is the number of threads.
  1217. T}
  1218. .TE
  1219. .PP
  1220. Keep in mind that \f[C]readdir\f[R] mostly just provides a list of file
  1221. names in a directory and possibly some basic metadata about said files.
  1222. To know details about the files, as one would see from commands like
  1223. \f[C]find\f[R] or \f[C]ls\f[R], it is required to call \f[C]stat\f[R] on
  1224. the file which is controlled by \f[C]fuse.getattr\f[R].
  1225. .SS ioctl
  1226. .PP
  1227. When \f[C]ioctl\f[R] is used with an open file then it will use the file
  1228. handle which was created at the original \f[C]open\f[R] call.
  1229. However, when using \f[C]ioctl\f[R] with a directory mergerfs will use
  1230. the \f[C]open\f[R] policy to find the directory to act on.
  1231. .SS rename & link
  1232. .PP
  1233. \f[B]NOTE:\f[R] If you\[cq]re receiving errors from software when files
  1234. are moved / renamed / linked then you should consider changing the
  1235. create policy to one which is \f[B]not\f[R] path preserving, enabling
  1236. \f[C]ignorepponrename\f[R], or contacting the author of the offending
  1237. software and requesting that \f[C]EXDEV\f[R] (cross device / improper
  1238. link) be properly handled.
  1239. .PP
  1240. \f[C]rename\f[R] and \f[C]link\f[R] are tricky functions in a union
  1241. filesystem.
  1242. \f[C]rename\f[R] only works within a single filesystem or device.
  1243. If a rename can\[cq]t be done atomically due to the source and
  1244. destination paths existing on different mount points it will return
  1245. \f[B]-1\f[R] with \f[B]errno = EXDEV\f[R] (cross device / improper
  1246. link).
  1247. So if a \f[C]rename\f[R]\[cq]s source and target are on different
  1248. filesystems within the pool it creates an issue.
  1249. .PP
  1250. Originally mergerfs would return EXDEV whenever a rename was requested
  1251. which was cross directory in any way.
  1252. This made the code simple and was technically compliant with POSIX
  1253. requirements.
  1254. However, many applications fail to handle EXDEV at all and treat it as a
  1255. normal error or otherwise handle it poorly.
  1256. Such apps include: gvfsd-fuse v1.20.3 and prior, Finder / CIFS/SMB
  1257. client in Apple OSX 10.9+, NZBGet, Samba\[cq]s recycling bin feature.
  1258. .PP
  1259. As a result a compromise was made in order to get most software to work
  1260. while still obeying mergerfs\[cq] policies.
  1261. Below is the basic logic.
  1262. .IP \[bu] 2
  1263. If using a \f[B]create\f[R] policy which tries to preserve directory
  1264. paths (epff,eplfs,eplus,epmfs)
  1265. .RS 2
  1266. .IP \[bu] 2
  1267. Using the \f[B]rename\f[R] policy get the list of files to rename
  1268. .IP \[bu] 2
  1269. For each file attempt rename:
  1270. .RS 2
  1271. .IP \[bu] 2
  1272. If failure with ENOENT (no such file or directory) run \f[B]create\f[R]
  1273. policy
  1274. .IP \[bu] 2
  1275. If create policy returns the same branch as currently evaluating then
  1276. clone the path
  1277. .IP \[bu] 2
  1278. Re-attempt rename
  1279. .RE
  1280. .IP \[bu] 2
  1281. If \f[B]any\f[R] of the renames succeed the higher level rename is
  1282. considered a success
  1283. .IP \[bu] 2
  1284. If \f[B]no\f[R] renames succeed the first error encountered will be
  1285. returned
  1286. .IP \[bu] 2
  1287. On success:
  1288. .RS 2
  1289. .IP \[bu] 2
  1290. Remove the target from all branches with no source file
  1291. .IP \[bu] 2
  1292. Remove the source from all branches which failed to rename
  1293. .RE
  1294. .RE
  1295. .IP \[bu] 2
  1296. If using a \f[B]create\f[R] policy which does \f[B]not\f[R] try to
  1297. preserve directory paths
  1298. .RS 2
  1299. .IP \[bu] 2
  1300. Using the \f[B]rename\f[R] policy get the list of files to rename
  1301. .IP \[bu] 2
  1302. Using the \f[B]getattr\f[R] policy get the target path
  1303. .IP \[bu] 2
  1304. For each file attempt rename:
  1305. .RS 2
  1306. .IP \[bu] 2
  1307. If the source branch != target branch:
  1308. .RS 2
  1309. .IP \[bu] 2
  1310. Clone target path from target branch to source branch
  1311. .RE
  1312. .IP \[bu] 2
  1313. Rename
  1314. .RE
  1315. .IP \[bu] 2
  1316. If \f[B]any\f[R] of the renames succeed the higher level rename is
  1317. considered a success
  1318. .IP \[bu] 2
  1319. If \f[B]no\f[R] renames succeed the first error encountered will be
  1320. returned
  1321. .IP \[bu] 2
  1322. On success:
  1323. .RS 2
  1324. .IP \[bu] 2
  1325. Remove the target from all branches with no source file
  1326. .IP \[bu] 2
  1327. Remove the source from all branches which failed to rename
  1328. .RE
  1329. .RE
  1330. .PP
  1331. The the removals are subject to normal entitlement checks.
  1332. .PP
  1333. The above behavior will help minimize the likelihood of EXDEV being
  1334. returned but it will still be possible.
  1335. .PP
  1336. \f[B]link\f[R] uses the same strategy but without the removals.
  1337. .SS statfs / statvfs
  1338. .PP
  1339. statvfs (http://linux.die.net/man/2/statvfs) normalizes the source
  1340. filesystems based on the fragment size and sums the number of adjusted
  1341. blocks and inodes.
  1342. This means you will see the combined space of all sources.
  1343. Total, used, and free.
  1344. The sources however are dedupped based on the filesystem so multiple
  1345. sources on the same drive will not result in double counting its space.
  1346. Other filesystems mounted further down the tree of the branch will not
  1347. be included when checking the mount\[cq]s stats.
  1348. .PP
  1349. The options \f[C]statfs\f[R] and \f[C]statfs_ignore\f[R] can be used to
  1350. modify \f[C]statfs\f[R] behavior.
  1351. .SS flush-on-close
  1352. .PP
  1353. https://lkml.kernel.org/linux-fsdevel/20211024132607.1636952-1-amir73il\[at]gmail.com/T/
  1354. .PP
  1355. By default FUSE would issue a flush before the release of a file
  1356. descriptor.
  1357. This was considered a bit aggressive and a feature added to give the
  1358. FUSE server the ability to choose when that happens.
  1359. .PP
  1360. Options: * always * never * opened-for-write
  1361. .PP
  1362. For now it defaults to \[lq]opened-for-write\[rq] which is less
  1363. aggressive than the behavior before this feature was added.
  1364. It should not be a problem because the flush is really only relevant
  1365. when a file is written to.
  1366. Given flush is irrelevant for many filesystems in the future a branch
  1367. specific flag may be added so only files opened on a specific branch
  1368. would be flushed on close.
  1369. .SH ERROR HANDLING
  1370. .PP
  1371. POSIX filesystem functions offer a single return code meaning that there
  1372. is some complication regarding the handling of multiple branches as
  1373. mergerfs does.
  1374. It tries to handle errors in a way that would generally return
  1375. meaningful values for that particular function.
  1376. .SS chmod, chown, removexattr, setxattr, truncate, utimens
  1377. .IP "1)" 3
  1378. if no error: return 0 (success)
  1379. .IP "2)" 3
  1380. if no successes: return first error
  1381. .IP "3)" 3
  1382. if one of the files acted on was the same as the related search
  1383. function: return its value
  1384. .IP "4)" 3
  1385. return 0 (success)
  1386. .PP
  1387. While doing this increases the complexity and cost of error handling,
  1388. particularly step 3, this provides probably the most reasonable return
  1389. value.
  1390. .SS unlink, rmdir
  1391. .IP "1)" 3
  1392. if no errors: return 0 (success)
  1393. .IP "2)" 3
  1394. return first error
  1395. .PP
  1396. Older version of mergerfs would return success if any success occurred
  1397. but for unlink and rmdir there are downstream assumptions that, while
  1398. not impossible to occur, can confuse some software.
  1399. .SS others
  1400. .PP
  1401. For search functions there is always a single thing acted on and as such
  1402. whatever return value that comes from the single function call is
  1403. returned.
  1404. .PP
  1405. For create functions \f[C]mkdir\f[R], \f[C]mknod\f[R], and
  1406. \f[C]symlink\f[R] which don\[cq]t return a file descriptor and therefore
  1407. can have \f[C]all\f[R] or \f[C]epall\f[R] policies it will return
  1408. success if any of the calls succeed and an error otherwise.
  1409. .SH INSTALL
  1410. .PP
  1411. https://github.com/trapexit/mergerfs/releases
  1412. .PP
  1413. If your distribution\[cq]s package manager includes mergerfs check if
  1414. the version is up to date.
  1415. If out of date it is recommended to use the latest release found on the
  1416. release page.
  1417. Details for common distros are below.
  1418. .SS Debian
  1419. .PP
  1420. Most Debian installs are of a stable branch and therefore do not have
  1421. the most up to date software.
  1422. While mergerfs is available via \f[C]apt\f[R] it is suggested that uses
  1423. install the most recent version available from the releases
  1424. page (https://github.com/trapexit/mergerfs/releases).
  1425. .SS prebuilt deb
  1426. .IP
  1427. .nf
  1428. \f[C]
  1429. wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs_<ver>.debian-<rel>_<arch>.deb
  1430. dpkg -i mergerfs_<ver>.debian-<rel>_<arch>.deb
  1431. \f[R]
  1432. .fi
  1433. .SS apt
  1434. .IP
  1435. .nf
  1436. \f[C]
  1437. sudo apt install -y mergerfs
  1438. \f[R]
  1439. .fi
  1440. .SS Ubuntu
  1441. .PP
  1442. Most Ubuntu installs are of a stable branch and therefore do not have
  1443. the most up to date software.
  1444. While mergerfs is available via \f[C]apt\f[R] it is suggested that uses
  1445. install the most recent version available from the releases
  1446. page (https://github.com/trapexit/mergerfs/releases).
  1447. .SS prebuilt deb
  1448. .IP
  1449. .nf
  1450. \f[C]
  1451. wget https://github.com/trapexit/mergerfs/releases/download/<version>/mergerfs_<ver>.ubuntu-<rel>_<arch>.deb
  1452. dpkg -i mergerfs_<ver>.ubuntu-<rel>_<arch>.deb
  1453. \f[R]
  1454. .fi
  1455. .SS apt
  1456. .IP
  1457. .nf
  1458. \f[C]
  1459. sudo apt install -y mergerfs
  1460. \f[R]
  1461. .fi
  1462. .SS Raspberry Pi OS
  1463. .PP
  1464. Effectively the same as Debian or Ubuntu.
  1465. .SS Fedora
  1466. .IP
  1467. .nf
  1468. \f[C]
  1469. wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.fc<rel>.<arch>.rpm
  1470. sudo rpm -i mergerfs-<ver>.fc<rel>.<arch>.rpm
  1471. \f[R]
  1472. .fi
  1473. .SS CentOS / Rocky
  1474. .IP
  1475. .nf
  1476. \f[C]
  1477. wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.el<rel>.<arch>.rpm
  1478. sudo rpm -i mergerfs-<ver>.el<rel>.<arch>.rpm
  1479. \f[R]
  1480. .fi
  1481. .SS ArchLinux
  1482. .IP "1." 3
  1483. Setup AUR
  1484. .IP "2." 3
  1485. Install \f[C]mergerfs\f[R]
  1486. .SS Other
  1487. .PP
  1488. Static binaries are provided for situations where native packages are
  1489. unavailable.
  1490. .IP
  1491. .nf
  1492. \f[C]
  1493. wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-static-linux_<arch>.tar.gz
  1494. sudo tar xvf mergerfs-static-linux_<arch>.tar.gz -C /
  1495. \f[R]
  1496. .fi
  1497. .SH BUILD
  1498. .PP
  1499. \f[B]NOTE:\f[R] Prebuilt packages can be found at and recommended for
  1500. most users: https://github.com/trapexit/mergerfs/releases
  1501. .PP
  1502. \f[B]NOTE:\f[R] Only tagged releases are supported.
  1503. \f[C]master\f[R] and other branches should be considered works in
  1504. progress.
  1505. .PP
  1506. First get the code from github (https://github.com/trapexit/mergerfs).
  1507. .IP
  1508. .nf
  1509. \f[C]
  1510. $ git clone https://github.com/trapexit/mergerfs.git
  1511. $ # or
  1512. $ wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.tar.gz
  1513. \f[R]
  1514. .fi
  1515. .SS Debian / Ubuntu
  1516. .IP
  1517. .nf
  1518. \f[C]
  1519. $ cd mergerfs
  1520. $ sudo tools/install-build-pkgs
  1521. $ make deb
  1522. $ sudo dpkg -i ../mergerfs_<version>_<arch>.deb
  1523. \f[R]
  1524. .fi
  1525. .SS RHEL / CentOS / Rocky / Fedora
  1526. .IP
  1527. .nf
  1528. \f[C]
  1529. $ su -
  1530. # cd mergerfs
  1531. # tools/install-build-pkgs
  1532. # make rpm
  1533. # rpm -i rpmbuild/RPMS/<arch>/mergerfs-<version>.<arch>.rpm
  1534. \f[R]
  1535. .fi
  1536. .SS Generic
  1537. .PP
  1538. Have git, g++, make, python installed.
  1539. .IP
  1540. .nf
  1541. \f[C]
  1542. $ cd mergerfs
  1543. $ make
  1544. $ sudo make install
  1545. \f[R]
  1546. .fi
  1547. .SS Build options
  1548. .IP
  1549. .nf
  1550. \f[C]
  1551. $ make help
  1552. usage: make
  1553. make USE_XATTR=0 - build program without xattrs functionality
  1554. make STATIC=1 - build static binary
  1555. make LTO=1 - build with link time optimization
  1556. \f[R]
  1557. .fi
  1558. .SH UPGRADE
  1559. .PP
  1560. mergerfs can be upgraded live by mounting on top of the previous
  1561. instance.
  1562. Simply install the new version of mergerfs and follow the instructions
  1563. below.
  1564. .PP
  1565. Run mergerfs again or if using \f[C]/etc/fstab\f[R] call for it to mount
  1566. again.
  1567. Existing open files and such will continue to work fine though they
  1568. won\[cq]t see runtime changes since any such change would be the new
  1569. mount.
  1570. If you plan on changing settings with the new mount you should / could
  1571. apply those before mounting the new version.
  1572. .IP
  1573. .nf
  1574. \f[C]
  1575. $ sudo mount /mnt/mergerfs
  1576. $ mount | grep mergerfs
  1577. media on /mnt/mergerfs type fuse.mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
  1578. media on /mnt/mergerfs type fuse.mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
  1579. \f[R]
  1580. .fi
  1581. .PP
  1582. A problem with this approach is that the underlying instance will
  1583. continue to run even if the software using it stop or are restarted.
  1584. To work around this you can use a \[lq]lazy umount\[rq].
  1585. Before mounting over top the mount point with the new instance of
  1586. mergerfs issue: \f[C]umount -l <mergerfs_mountpoint>\f[R].
  1587. Or you can let mergerfs do it by setting the option
  1588. \f[C]lazy-umount-mountpoint=true\f[R].
  1589. .SH RUNTIME INTERFACES
  1590. .SS RUNTIME CONFIG
  1591. .SS .mergerfs pseudo file
  1592. .IP
  1593. .nf
  1594. \f[C]
  1595. <mountpoint>/.mergerfs
  1596. \f[R]
  1597. .fi
  1598. .PP
  1599. There is a pseudo file available at the mount point which allows for the
  1600. runtime modification of certain \f[B]mergerfs\f[R] options.
  1601. The file will not show up in \f[B]readdir\f[R] but can be
  1602. \f[B]stat\f[R]\[cq]ed and manipulated via
  1603. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls.
  1604. .PP
  1605. Any changes made at runtime are \f[B]not\f[R] persisted.
  1606. If you wish for values to persist they must be included as options
  1607. wherever you configure the mounting of mergerfs (/etc/fstab).
  1608. .SS Keys
  1609. .PP
  1610. Use \f[C]getfattr -d /mountpoint/.mergerfs\f[R] or
  1611. \f[C]xattr -l /mountpoint/.mergerfs\f[R] to see all supported keys.
  1612. Some are informational and therefore read-only.
  1613. \f[C]setxattr\f[R] will return EINVAL (invalid argument) on read-only
  1614. keys.
  1615. .SS Values
  1616. .PP
  1617. Same as the command line.
  1618. .SS user.mergerfs.branches
  1619. .PP
  1620. Used to query or modify the list of branches.
  1621. When modifying there are several shortcuts to easy manipulation of the
  1622. list.
  1623. .PP
  1624. .TS
  1625. tab(@);
  1626. l l.
  1627. T{
  1628. Value
  1629. T}@T{
  1630. Description
  1631. T}
  1632. _
  1633. T{
  1634. [list]
  1635. T}@T{
  1636. set
  1637. T}
  1638. T{
  1639. +<[list]
  1640. T}@T{
  1641. prepend
  1642. T}
  1643. T{
  1644. +>[list]
  1645. T}@T{
  1646. append
  1647. T}
  1648. T{
  1649. -[list]
  1650. T}@T{
  1651. remove all values provided
  1652. T}
  1653. T{
  1654. -<
  1655. T}@T{
  1656. remove first in list
  1657. T}
  1658. T{
  1659. ->
  1660. T}@T{
  1661. remove last in list
  1662. T}
  1663. .TE
  1664. .PP
  1665. \f[C]xattr -w user.mergerfs.branches +</mnt/drive3 /mnt/pool/.mergerfs\f[R]
  1666. .PP
  1667. The \f[C]=NC\f[R], \f[C]=RO\f[R], \f[C]=RW\f[R] syntax works just as on
  1668. the command line.
  1669. .SS Example
  1670. .IP
  1671. .nf
  1672. \f[C]
  1673. [trapexit:/mnt/mergerfs] $ getfattr -d .mergerfs
  1674. user.mergerfs.branches=\[dq]/mnt/a=RW:/mnt/b=RW\[dq]
  1675. user.mergerfs.minfreespace=\[dq]4294967295\[dq]
  1676. user.mergerfs.moveonenospc=\[dq]false\[dq]
  1677. \&...
  1678. [trapexit:/mnt/mergerfs] $ getfattr -n user.mergerfs.category.search .mergerfs
  1679. user.mergerfs.category.search=\[dq]ff\[dq]
  1680. [trapexit:/mnt/mergerfs] $ setfattr -n user.mergerfs.category.search -v newest .mergerfs
  1681. [trapexit:/mnt/mergerfs] $ getfattr -n user.mergerfs.category.search .mergerfs
  1682. user.mergerfs.category.search=\[dq]newest\[dq]
  1683. \f[R]
  1684. .fi
  1685. .SS file / directory xattrs
  1686. .PP
  1687. While they won\[cq]t show up when using \f[C]getfattr\f[R]
  1688. \f[B]mergerfs\f[R] offers a number of special xattrs to query
  1689. information about the files served.
  1690. To access the values you will need to issue a
  1691. getxattr (http://linux.die.net/man/2/getxattr) for one of the following:
  1692. .IP \[bu] 2
  1693. \f[B]user.mergerfs.basepath\f[R]: the base mount point for the file
  1694. given the current getattr policy
  1695. .IP \[bu] 2
  1696. \f[B]user.mergerfs.relpath\f[R]: the relative path of the file from the
  1697. perspective of the mount point
  1698. .IP \[bu] 2
  1699. \f[B]user.mergerfs.fullpath\f[R]: the full path of the original file
  1700. given the getattr policy
  1701. .IP \[bu] 2
  1702. \f[B]user.mergerfs.allpaths\f[R]: a NUL (`\[rs]0') separated list of
  1703. full paths to all files found
  1704. .SS SIGNALS
  1705. .IP \[bu] 2
  1706. USR1: This will cause mergerfs to send invalidation notifications to the
  1707. kernel for all files.
  1708. This will cause all unused files to be released from memory.
  1709. .IP \[bu] 2
  1710. USR2: Trigger a general cleanup of currently unused memory.
  1711. A more thorough version of what happens every \[ti]15 minutes.
  1712. .SS IOCTLS
  1713. .PP
  1714. Found in \f[C]fuse_ioctl.cpp\f[R]:
  1715. .IP
  1716. .nf
  1717. \f[C]
  1718. typedef char IOCTL_BUF[4096];
  1719. #define IOCTL_APP_TYPE 0xDF
  1720. #define IOCTL_FILE_INFO _IOWR(IOCTL_APP_TYPE,0,IOCTL_BUF)
  1721. #define IOCTL_GC _IO(IOCTL_APP_TYPE,1)
  1722. #define IOCTL_GC1 _IO(IOCTL_APP_TYPE,2)
  1723. #define IOCTL_INVALIDATE_ALL_NODES _IO(IOCTL_APP_TYPE,3)
  1724. \f[R]
  1725. .fi
  1726. .IP \[bu] 2
  1727. IOCTL_FILE_INFO: Same as the \[lq]file / directory xattrs\[rq] mentioned
  1728. above.
  1729. Use a buffer size of 4096 bytes.
  1730. Pass in a string of \[lq]basepath\[rq], \[lq]relpath\[rq],
  1731. \[lq]fullpath\[rq], or \[lq]allpaths\[rq].
  1732. Receive details in same buffer.
  1733. .IP \[bu] 2
  1734. IOCTL_GC: Triggers a thorough garbage collection of excess memory.
  1735. Same as SIGUSR2.
  1736. .IP \[bu] 2
  1737. IOCTL_GC1: Triggers a simple garbage collection of excess memory.
  1738. Same as what happens every 15 minutes normally.
  1739. .IP \[bu] 2
  1740. IOCTL_INVALIDATE_ALL_NODES: Same as SIGUSR1.
  1741. Send invalidation notifications to the kernel for all files causing
  1742. unused files to be released from memory.
  1743. .SH TOOLING
  1744. .SS preload.so
  1745. .PP
  1746. EXPERIMENTAL
  1747. .PP
  1748. For some time there has been work to enable passthrough IO in FUSE.
  1749. Passthrough IO would allow for near native performance with regards to
  1750. reads and writes (at the expense of certain mergerfs features.) However,
  1751. there have been several complications which have kept the feature from
  1752. making it into the mainline Linux kernel.
  1753. Until that feature is available there are two methods to provide similar
  1754. functionality.
  1755. One method is using the LD_PRELOAD feature of the dynamic linker.
  1756. The other leveraging ptrace to intercept syscalls.
  1757. Each has their disadvantages.
  1758. At the moment only a preload based tool is available.
  1759. A ptrace based tool may be developed later if there is a need.
  1760. .PP
  1761. \f[C]/usr/lib/mergerfs/preload.so\f[R]
  1762. .PP
  1763. This preloadable
  1764. library (https://man7.org/linux/man-pages/man8/ld.so.8.html#ENVIRONMENT)
  1765. overrides the creation and opening of files in order to simulate
  1766. passthrough file IO.
  1767. It catches the open/creat/fopen calls, has mergerfs do the call, queries
  1768. mergerfs for the branch the file exists on, reopens the file on the
  1769. underlying filesystem and returns that instead.
  1770. Meaning that you will get native read/write performance because mergerfs
  1771. is no longer part of the workflow.
  1772. Keep in mind that this also means certain mergerfs features that work by
  1773. interrupting the read/write workflow, such as \f[C]moveonenospc\f[R],
  1774. will no longer work.
  1775. .PP
  1776. Also understand that this will only work on dynamically linked software.
  1777. Anything statically compiled will not work.
  1778. Many GoLang and Rust apps are statically compiled.
  1779. .PP
  1780. The library will not interfere with non-mergerfs filesystems.
  1781. The library is written to always fallback to returning the mergerfs
  1782. opened file on error.
  1783. .PP
  1784. While the library was written to account for a number of edgecases there
  1785. could be some yet accounted for so please report any oddities.
  1786. .PP
  1787. Thank you to nohajc (https://github.com/nohajc/mergerfs-io-passthrough)
  1788. for prototyping the idea.
  1789. .SS general usage
  1790. .IP
  1791. .nf
  1792. \f[C]
  1793. LD_PRELOAD=/usr/lib/mergerfs/preload.so touch /mnt/mergerfs/filename
  1794. \f[R]
  1795. .fi
  1796. .SS Docker usage
  1797. .PP
  1798. Assume \f[C]/mnt/fs0\f[R] and \f[C]/mnt/fs1\f[R] are pooled with
  1799. mergerfs at \f[C]/media\f[R].
  1800. .PP
  1801. All mergerfs branch paths \f[I]must\f[R] be bind mounted into the
  1802. container at the same path as found on the host so the preload library
  1803. can see them.
  1804. .IP
  1805. .nf
  1806. \f[C]
  1807. docker run \[rs]
  1808. -e LD_PRELOAD=/usr/lib/mergerfs/preload.so \[rs]
  1809. -v /usr/lib/mergerfs/preload.so:/usr/lib/mergerfs/preload.so:ro \[rs]
  1810. -v /media:/data \[rs]
  1811. -v /mnt:/mnt \[rs]
  1812. ubuntu:latest \[rs]
  1813. bash
  1814. \f[R]
  1815. .fi
  1816. .PP
  1817. or more explicitly
  1818. .IP
  1819. .nf
  1820. \f[C]
  1821. docker run \[rs]
  1822. -e LD_PRELOAD=/usr/lib/mergerfs/preload.so \[rs]
  1823. -v /usr/lib/mergerfs/preload.so:/usr/lib/mergerfs/preload.so:ro \[rs]
  1824. -v /media:/data \[rs]
  1825. -v /mnt/fs0:/mnt/fs0 \[rs]
  1826. -v /mnt/fs1:/mnt/fs1 \[rs]
  1827. ubuntu:latest \[rs]
  1828. bash
  1829. \f[R]
  1830. .fi
  1831. .SS systemd unit
  1832. .PP
  1833. Use the \f[C]Environment\f[R] option to set the LD_PRELOAD variable.
  1834. .IP \[bu] 2
  1835. https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Command%20lines
  1836. .IP \[bu] 2
  1837. https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service
  1838. .IP
  1839. .nf
  1840. \f[C]
  1841. [Service]
  1842. Environment=LD_PRELOAD=/usr/lib/mergerfs/preload.so
  1843. \f[R]
  1844. .fi
  1845. .SS Misc
  1846. .IP \[bu] 2
  1847. https://github.com/trapexit/mergerfs-tools
  1848. .RS 2
  1849. .IP \[bu] 2
  1850. mergerfs.ctl: A tool to make it easier to query and configure mergerfs
  1851. at runtime
  1852. .IP \[bu] 2
  1853. mergerfs.fsck: Provides permissions and ownership auditing and the
  1854. ability to fix them
  1855. .IP \[bu] 2
  1856. mergerfs.dedup: Will help identify and optionally remove duplicate files
  1857. .IP \[bu] 2
  1858. mergerfs.dup: Ensure there are at least N copies of a file across the
  1859. pool
  1860. .IP \[bu] 2
  1861. mergerfs.balance: Rebalance files across filesystems by moving them from
  1862. the most filled to the least filled
  1863. .IP \[bu] 2
  1864. mergerfs.consolidate: move files within a single mergerfs directory to
  1865. the filesystem with most free space
  1866. .RE
  1867. .IP \[bu] 2
  1868. https://github.com/trapexit/scorch
  1869. .RS 2
  1870. .IP \[bu] 2
  1871. scorch: A tool to help discover silent corruption of files and keep
  1872. track of files
  1873. .RE
  1874. .IP \[bu] 2
  1875. https://github.com/trapexit/bbf
  1876. .RS 2
  1877. .IP \[bu] 2
  1878. bbf (bad block finder): a tool to scan for and `fix' hard drive bad
  1879. blocks and find the files using those blocks
  1880. .RE
  1881. .SH CACHING
  1882. .SS page caching
  1883. .PP
  1884. https://en.wikipedia.org/wiki/Page_cache
  1885. .IP \[bu] 2
  1886. cache.files=off: Disables page caching.
  1887. Underlying files cached, mergerfs files are not.
  1888. .IP \[bu] 2
  1889. cache.files=partial: Enables page caching.
  1890. Underlying files cached, mergerfs files cached while open.
  1891. .IP \[bu] 2
  1892. cache.files=full: Enables page caching.
  1893. Underlying files cached, mergerfs files cached across opens.
  1894. .IP \[bu] 2
  1895. cache.files=auto-full: Enables page caching.
  1896. Underlying files cached, mergerfs files cached across opens if mtime and
  1897. size are unchanged since previous open.
  1898. .IP \[bu] 2
  1899. cache.files=libfuse: follow traditional libfuse \f[C]direct_io\f[R],
  1900. \f[C]kernel_cache\f[R], and \f[C]auto_cache\f[R] arguments.
  1901. .IP \[bu] 2
  1902. cache.files=per-process: Enable page caching (equivalent to
  1903. \f[C]cache.files=partial\f[R]) only for processes whose `comm' name
  1904. matches one of the values defined in
  1905. \f[C]cache.files.process-names\f[R].
  1906. If the name does not match the file open is equivalent to
  1907. \f[C]cache.files=off\f[R].
  1908. .PP
  1909. FUSE, which mergerfs uses, offers a number of page caching modes.
  1910. mergerfs tries to simplify their use via the \f[C]cache.files\f[R]
  1911. option.
  1912. It can and should replace usage of \f[C]direct_io\f[R],
  1913. \f[C]kernel_cache\f[R], and \f[C]auto_cache\f[R].
  1914. .PP
  1915. Due to mergerfs using FUSE and therefore being a userland process
  1916. proxying existing filesystems the kernel will double cache the content
  1917. being read and written through mergerfs.
  1918. Once from the underlying filesystem and once from mergerfs (it sees them
  1919. as two separate entities).
  1920. Using \f[C]cache.files=off\f[R] will keep the double caching from
  1921. happening by disabling caching of mergerfs but this has the side effect
  1922. that \f[I]all\f[R] read and write calls will be passed to mergerfs which
  1923. may be slower than enabling caching, you lose shared \f[C]mmap\f[R]
  1924. support which can affect apps such as rtorrent, and no read-ahead will
  1925. take place.
  1926. The kernel will still cache the underlying filesystem data but that only
  1927. helps so much given mergerfs will still process all requests.
  1928. .PP
  1929. If you do enable file page caching,
  1930. \f[C]cache.files=partial|full|auto-full\f[R], you should also enable
  1931. \f[C]dropcacheonclose\f[R] which will cause mergerfs to instruct the
  1932. kernel to flush the underlying file\[cq]s page cache when the file is
  1933. closed.
  1934. This behavior is the same as the rsync fadvise / drop cache patch and
  1935. Feh\[cq]s nocache project.
  1936. .PP
  1937. If most files are read once through and closed (like media) it is best
  1938. to enable \f[C]dropcacheonclose\f[R] regardless of caching mode in order
  1939. to minimize buffer bloat.
  1940. .PP
  1941. It is difficult to balance memory usage, cache bloat & duplication, and
  1942. performance.
  1943. Ideally mergerfs would be able to disable caching for the files it
  1944. reads/writes but allow page caching for itself.
  1945. That would limit the FUSE overhead.
  1946. However, there isn\[cq]t a good way to achieve this.
  1947. It would need to open all files with O_DIRECT which places limitations
  1948. on the what underlying filesystems would be supported and complicates
  1949. the code.
  1950. .PP
  1951. kernel documentation:
  1952. https://www.kernel.org/doc/Documentation/filesystems/fuse-io.txt
  1953. .SS entry & attribute caching
  1954. .PP
  1955. Given the relatively high cost of FUSE due to the kernel <-> userspace
  1956. round trips there are kernel side caches for file entries and
  1957. attributes.
  1958. The entry cache limits the \f[C]lookup\f[R] calls to mergerfs which ask
  1959. if a file exists.
  1960. The attribute cache limits the need to make \f[C]getattr\f[R] calls to
  1961. mergerfs which provide file attributes (mode, size, type, etc.).
  1962. As with the page cache these should not be used if the underlying
  1963. filesystems are being manipulated at the same time as it could lead to
  1964. odd behavior or data corruption.
  1965. The options for setting these are \f[C]cache.entry\f[R] and
  1966. \f[C]cache.negative_entry\f[R] for the entry cache and
  1967. \f[C]cache.attr\f[R] for the attributes cache.
  1968. \f[C]cache.negative_entry\f[R] refers to the timeout for negative
  1969. responses to lookups (non-existent files).
  1970. .SS writeback caching
  1971. .PP
  1972. When \f[C]cache.files\f[R] is enabled the default is for it to perform
  1973. writethrough caching.
  1974. This behavior won\[cq]t help improve performance as each write still
  1975. goes one for one through the filesystem.
  1976. By enabling the FUSE writeback cache small writes may be aggregated by
  1977. the kernel and then sent to mergerfs as one larger request.
  1978. This can greatly improve the throughput for apps which write to files
  1979. inefficiently.
  1980. The amount the kernel can aggregate is limited by the size of a FUSE
  1981. message.
  1982. Read the \f[C]fuse_msg_size\f[R] section for more details.
  1983. .PP
  1984. There is a small side effect as a result of enabling writeback caching.
  1985. Underlying files won\[cq]t ever be opened with O_APPEND or O_WRONLY.
  1986. The former because the kernel then manages append mode and the latter
  1987. because the kernel may request file data from mergerfs to populate the
  1988. write cache.
  1989. The O_APPEND change means that if a file is changed outside of mergerfs
  1990. it could lead to corruption as the kernel won\[cq]t know the end of the
  1991. file has changed.
  1992. That said any time you use caching you should keep from using the same
  1993. file outside of mergerfs at the same time.
  1994. .PP
  1995. Note that if an application is properly sizing writes then writeback
  1996. caching will have little or no effect.
  1997. It will only help with writes of sizes below the FUSE message size (128K
  1998. on older kernels, 1M on newer).
  1999. .SS statfs caching
  2000. .PP
  2001. Of the syscalls used by mergerfs in policies the \f[C]statfs\f[R] /
  2002. \f[C]statvfs\f[R] call is perhaps the most expensive.
  2003. It\[cq]s used to find out the available space of a filesystem and
  2004. whether it is mounted read-only.
  2005. Depending on the setup and usage pattern these queries can be relatively
  2006. costly.
  2007. When \f[C]cache.statfs\f[R] is enabled all calls to \f[C]statfs\f[R] by
  2008. a policy will be cached for the number of seconds its set to.
  2009. .PP
  2010. Example: If the create policy is \f[C]mfs\f[R] and the timeout is 60
  2011. then for that 60 seconds the same filesystem will be returned as the
  2012. target for creates because the available space won\[cq]t be updated for
  2013. that time.
  2014. .SS symlink caching
  2015. .PP
  2016. As of version 4.20 Linux supports symlink caching.
  2017. Significant performance increases can be had in workloads which use a
  2018. lot of symlinks.
  2019. Setting \f[C]cache.symlinks=true\f[R] will result in requesting symlink
  2020. caching from the kernel only if supported.
  2021. As a result its safe to enable it on systems prior to 4.20.
  2022. That said it is disabled by default for now.
  2023. You can see if caching is enabled by querying the xattr
  2024. \f[C]user.mergerfs.cache.symlinks\f[R] but given it must be requested at
  2025. startup you can not change it at runtime.
  2026. .SS readdir caching
  2027. .PP
  2028. As of version 4.20 Linux supports readdir caching.
  2029. This can have a significant impact on directory traversal.
  2030. Especially when combined with entry (\f[C]cache.entry\f[R]) and
  2031. attribute (\f[C]cache.attr\f[R]) caching.
  2032. Setting \f[C]cache.readdir=true\f[R] will result in requesting readdir
  2033. caching from the kernel on each \f[C]opendir\f[R].
  2034. If the kernel doesn\[cq]t support readdir caching setting the option to
  2035. \f[C]true\f[R] has no effect.
  2036. This option is configurable at runtime via xattr
  2037. \f[C]user.mergerfs.cache.readdir\f[R].
  2038. .SS tiered caching
  2039. .PP
  2040. Some storage technologies support what some call \[lq]tiered\[rq]
  2041. caching.
  2042. The placing of usually smaller, faster storage as a transparent cache to
  2043. larger, slower storage.
  2044. NVMe, SSD, Optane in front of traditional HDDs for instance.
  2045. .PP
  2046. mergerfs does not natively support any sort of tiered caching.
  2047. Most users have no use for such a feature and its inclusion would
  2048. complicate the code.
  2049. However, there are a few situations where a cache filesystem could help
  2050. with a typical mergerfs setup.
  2051. .IP "1." 3
  2052. Fast network, slow filesystems, many readers: You\[cq]ve a 10+Gbps
  2053. network with many readers and your regular filesystems can\[cq]t keep
  2054. up.
  2055. .IP "2." 3
  2056. Fast network, slow filesystems, small\[cq]ish bursty writes: You have a
  2057. 10+Gbps network and wish to transfer amounts of data less than your
  2058. cache filesystem but wish to do so quickly.
  2059. .PP
  2060. With #1 it\[cq]s arguable if you should be using mergerfs at all.
  2061. RAID would probably be the better solution.
  2062. If you\[cq]re going to use mergerfs there are other tactics that may
  2063. help: spreading the data across filesystems (see the mergerfs.dup tool)
  2064. and setting \f[C]func.open=rand\f[R], using \f[C]symlinkify\f[R], or
  2065. using dm-cache or a similar technology to add tiered cache to the
  2066. underlying device.
  2067. .PP
  2068. With #2 one could use dm-cache as well but there is another solution
  2069. which requires only mergerfs and a cronjob.
  2070. .IP "1." 3
  2071. Create 2 mergerfs pools.
  2072. One which includes just the slow devices and one which has both the fast
  2073. devices (SSD,NVME,etc.) and slow devices.
  2074. .IP "2." 3
  2075. The `cache' pool should have the cache filesystems listed first.
  2076. .IP "3." 3
  2077. The best \f[C]create\f[R] policies to use for the `cache' pool would
  2078. probably be \f[C]ff\f[R], \f[C]epff\f[R], \f[C]lfs\f[R], or
  2079. \f[C]eplfs\f[R].
  2080. The latter two under the assumption that the cache filesystem(s) are far
  2081. smaller than the backing filesystems.
  2082. If using path preserving policies remember that you\[cq]ll need to
  2083. manually create the core directories of those paths you wish to be
  2084. cached.
  2085. Be sure the permissions are in sync.
  2086. Use \f[C]mergerfs.fsck\f[R] to check / correct them.
  2087. You could also set the slow filesystems mode to \f[C]NC\f[R] though
  2088. that\[cq]d mean if the cache filesystems fill you\[cq]d get \[lq]out of
  2089. space\[rq] errors.
  2090. .IP "4." 3
  2091. Enable \f[C]moveonenospc\f[R] and set \f[C]minfreespace\f[R]
  2092. appropriately.
  2093. To make sure there is enough room on the \[lq]slow\[rq] pool you might
  2094. want to set \f[C]minfreespace\f[R] to at least as large as the size of
  2095. the largest cache filesystem if not larger.
  2096. This way in the worst case the whole of the cache filesystem(s) can be
  2097. moved to the other drives.
  2098. .IP "5." 3
  2099. Set your programs to use the cache pool.
  2100. .IP "6." 3
  2101. Save one of the below scripts or create you\[cq]re own.
  2102. .IP "7." 3
  2103. Use \f[C]cron\f[R] (as root) to schedule the command at whatever
  2104. frequency is appropriate for your workflow.
  2105. .SS time based expiring
  2106. .PP
  2107. Move files from cache to backing pool based only on the last time the
  2108. file was accessed.
  2109. Replace \f[C]-atime\f[R] with \f[C]-amin\f[R] if you want minutes rather
  2110. than days.
  2111. May want to use the \f[C]fadvise\f[R] / \f[C]--drop-cache\f[R] version
  2112. of rsync or run rsync with the tool \[lq]nocache\[rq].
  2113. .PP
  2114. \f[I]NOTE:\f[R] The arguments to these scripts include the cache
  2115. \f[B]filesystem\f[R] itself.
  2116. Not the pool with the cache filesystem.
  2117. You could have data loss if the source is the cache pool.
  2118. .PP
  2119. mergerfs.time-based-mover
  2120. .SS percentage full expiring
  2121. .PP
  2122. Move the oldest file from the cache to the backing pool.
  2123. Continue till below percentage threshold.
  2124. .PP
  2125. \f[I]NOTE:\f[R] The arguments to these scripts include the cache
  2126. \f[B]filesystem\f[R] itself.
  2127. Not the pool with the cache filesystem.
  2128. You could have data loss if the source is the cache pool.
  2129. .PP
  2130. mergerfs.percent-full-mover
  2131. .SH PERFORMANCE
  2132. .PP
  2133. mergerfs is at its core just a proxy and therefore its theoretical max
  2134. performance is that of the underlying devices.
  2135. However, given it is a FUSE filesystem working from userspace there is
  2136. an increase in overhead relative to kernel based solutions.
  2137. That said the performance can match the theoretical max but it depends
  2138. greatly on the system\[cq]s configuration.
  2139. Especially when adding network filesystems into the mix there are many
  2140. variables which can impact performance.
  2141. Device speeds and latency, network speeds and latency, general
  2142. concurrency, read/write sizes, etc.
  2143. Unfortunately, given the number of variables it has been difficult to
  2144. find a single set of settings which provide optimal performance.
  2145. If you\[cq]re having performance issues please look over the suggestions
  2146. below (including the benchmarking section.)
  2147. .PP
  2148. NOTE: be sure to read about these features before changing them to
  2149. understand what behaviors it may impact
  2150. .IP \[bu] 2
  2151. disable \f[C]security_capability\f[R] and/or \f[C]xattr\f[R]
  2152. .IP \[bu] 2
  2153. increase cache timeouts \f[C]cache.attr\f[R], \f[C]cache.entry\f[R],
  2154. \f[C]cache.negative_entry\f[R]
  2155. .IP \[bu] 2
  2156. enable (or disable) page caching (\f[C]cache.files\f[R])
  2157. .IP \[bu] 2
  2158. enable \f[C]parallel-direct-writes\f[R]
  2159. .IP \[bu] 2
  2160. enable \f[C]cache.writeback\f[R]
  2161. .IP \[bu] 2
  2162. enable \f[C]cache.statfs\f[R]
  2163. .IP \[bu] 2
  2164. enable \f[C]cache.symlinks\f[R]
  2165. .IP \[bu] 2
  2166. enable \f[C]cache.readdir\f[R]
  2167. .IP \[bu] 2
  2168. change the number of worker threads
  2169. .IP \[bu] 2
  2170. disable \f[C]posix_acl\f[R]
  2171. .IP \[bu] 2
  2172. disable \f[C]async_read\f[R]
  2173. .IP \[bu] 2
  2174. test theoretical performance using \f[C]nullrw\f[R] or mounting a ram
  2175. disk
  2176. .IP \[bu] 2
  2177. use \f[C]symlinkify\f[R] if your data is largely static and read-only
  2178. .IP \[bu] 2
  2179. use tiered cache devices
  2180. .IP \[bu] 2
  2181. use LVM and LVM cache to place a SSD in front of your HDDs
  2182. .IP \[bu] 2
  2183. increase readahead: \f[C]readahead=1024\f[R]
  2184. .PP
  2185. If you come across a setting that significantly impacts performance
  2186. please contact trapexit so he may investigate further.
  2187. Please test both against your normal setup, a singular branch, and with
  2188. \f[C]nullrw=true\f[R]
  2189. .SH BENCHMARKING
  2190. .PP
  2191. Filesystems are complicated.
  2192. They do many things and many of those are interconnected.
  2193. Additionally, the OS, drivers, hardware, etc.
  2194. all can impact performance.
  2195. Therefore, when benchmarking, it is \f[B]necessary\f[R] that the test
  2196. focus as narrowly as possible.
  2197. .PP
  2198. For most throughput is the key benchmark.
  2199. To test throughput \f[C]dd\f[R] is useful but \f[B]must\f[R] be used
  2200. with the correct settings in order to ensure the filesystem or device is
  2201. actually being tested.
  2202. The OS can and will cache data.
  2203. Without forcing synchronous reads and writes and/or disabling caching
  2204. the values returned will not be representative of the device\[cq]s true
  2205. performance.
  2206. .PP
  2207. When benchmarking through mergerfs ensure you only use 1 branch to
  2208. remove any possibility of the policies complicating the situation.
  2209. Benchmark the underlying filesystem first and then mount mergerfs over
  2210. it and test again.
  2211. If you\[cq]re experience speeds below your expectation you will need to
  2212. narrow down precisely which component is leading to the slowdown.
  2213. Preferably test the following in the order listed (but not combined).
  2214. .IP "1." 3
  2215. Enable \f[C]nullrw\f[R] mode with \f[C]nullrw=true\f[R].
  2216. This will effectively make reads and writes no-ops.
  2217. Removing the underlying device / filesystem from the equation.
  2218. This will give us the top theoretical speeds.
  2219. .IP "2." 3
  2220. Mount mergerfs over \f[C]tmpfs\f[R].
  2221. \f[C]tmpfs\f[R] is a RAM disk.
  2222. Extremely high speed and very low latency.
  2223. This is a more realistic best case scenario.
  2224. Example: \f[C]mount -t tmpfs -o size=2G tmpfs /tmp/tmpfs\f[R]
  2225. .IP "3." 3
  2226. Mount mergerfs over a local device.
  2227. NVMe, SSD, HDD, etc.
  2228. If you have more than one I\[cq]d suggest testing each of them as drives
  2229. and/or controllers (their drivers) could impact performance.
  2230. .IP "4." 3
  2231. Finally, if you intend to use mergerfs with a network filesystem, either
  2232. as the source of data or to combine with another through mergerfs, test
  2233. each of those alone as above.
  2234. .PP
  2235. Once you find the component which has the performance issue you can do
  2236. further testing with different options to see if they impact
  2237. performance.
  2238. For reads and writes the most relevant would be: \f[C]cache.files\f[R],
  2239. \f[C]async_read\f[R].
  2240. Less likely but relevant when using NFS or with certain filesystems
  2241. would be \f[C]security_capability\f[R], \f[C]xattr\f[R], and
  2242. \f[C]posix_acl\f[R].
  2243. If you find a specific system, device, filesystem, controller, etc.
  2244. that performs poorly contact trapexit so he may investigate further.
  2245. .PP
  2246. Sometimes the problem is really the application accessing or writing
  2247. data through mergerfs.
  2248. Some software use small buffer sizes which can lead to more requests and
  2249. therefore greater overhead.
  2250. You can test this out yourself by replace \f[C]bs=1M\f[R] in the
  2251. examples below with \f[C]ibs\f[R] or \f[C]obs\f[R] and using a size of
  2252. \f[C]512\f[R] instead of \f[C]1M\f[R].
  2253. In one example test using \f[C]nullrw\f[R] the write speed dropped from
  2254. 4.9GB/s to 69.7MB/s when moving from \f[C]1M\f[R] to \f[C]512\f[R].
  2255. Similar results were had when testing reads.
  2256. Small writes overhead may be improved by leveraging a write cache but in
  2257. casual tests little gain was found.
  2258. More tests will need to be done before this feature would become
  2259. available.
  2260. If you have an app that appears slow with mergerfs it could be due to
  2261. this.
  2262. Contact trapexit so he may investigate further.
  2263. .SS write benchmark
  2264. .IP
  2265. .nf
  2266. \f[C]
  2267. $ dd if=/dev/zero of=/mnt/mergerfs/1GB.file bs=1M count=1024 oflag=nocache conv=fdatasync status=progress
  2268. \f[R]
  2269. .fi
  2270. .SS read benchmark
  2271. .IP
  2272. .nf
  2273. \f[C]
  2274. $ dd if=/mnt/mergerfs/1GB.file of=/dev/null bs=1M count=1024 iflag=nocache conv=fdatasync status=progress
  2275. \f[R]
  2276. .fi
  2277. .SS other benchmarks
  2278. .PP
  2279. If you are attempting to benchmark other behaviors you must ensure you
  2280. clear kernel caches before runs.
  2281. In fact it would be a good deal to run before the read and write
  2282. benchmarks as well just in case.
  2283. .IP
  2284. .nf
  2285. \f[C]
  2286. sync
  2287. echo 3 | sudo tee /proc/sys/vm/drop_caches
  2288. \f[R]
  2289. .fi
  2290. .SH TIPS / NOTES
  2291. .IP \[bu] 2
  2292. This document is literal and thorough.
  2293. If a suspected feature isn\[cq]t mentioned it doesn\[cq]t exist.
  2294. If certain libfuse arguments aren\[cq]t listed they probably
  2295. shouldn\[cq]t be used.
  2296. .IP \[bu] 2
  2297. Ensure you\[cq]re using the latest version.
  2298. .IP \[bu] 2
  2299. Run mergerfs as \f[C]root\f[R].
  2300. mergerfs is designed and intended to be run as \f[C]root\f[R] and may
  2301. exibit incorrect behavior if run otherwise..
  2302. .IP \[bu] 2
  2303. If you don\[cq]t see some directories and files you expect, policies
  2304. seem to skip branches, you get strange permission errors, etc.
  2305. be sure the underlying filesystems\[cq] permissions are all the same.
  2306. Use \f[C]mergerfs.fsck\f[R] to audit the filesystem for out of sync
  2307. permissions.
  2308. .IP \[bu] 2
  2309. If you still have permission issues be sure you are using POSIX ACL
  2310. compliant filesystems.
  2311. mergerfs doesn\[cq]t generally make exceptions for FAT, NTFS, or other
  2312. non-POSIX filesystem.
  2313. .IP \[bu] 2
  2314. Do \f[B]not\f[R] use \f[C]cache.files=off\f[R] if you expect
  2315. applications (such as rtorrent) to use
  2316. mmap (http://linux.die.net/man/2/mmap) files.
  2317. Shared mmap is not currently supported in FUSE w/ page caching disabled.
  2318. Enabling \f[C]dropcacheonclose\f[R] is recommended when
  2319. \f[C]cache.files=partial|full|auto-full\f[R].
  2320. .IP \[bu] 2
  2321. Kodi (http://kodi.tv), Plex (http://plex.tv),
  2322. Subsonic (http://subsonic.org), etc.
  2323. can use directory mtime (http://linux.die.net/man/2/stat) to more
  2324. efficiently determine whether to scan for new content rather than simply
  2325. performing a full scan.
  2326. If using the default \f[B]getattr\f[R] policy of \f[B]ff\f[R] it\[cq]s
  2327. possible those programs will miss an update on account of it returning
  2328. the first directory found\[cq]s \f[B]stat\f[R] info and it\[cq]s a later
  2329. directory on another mount which had the \f[B]mtime\f[R] recently
  2330. updated.
  2331. To fix this you will want to set \f[B]func.getattr=newest\f[R].
  2332. Remember though that this is just \f[B]stat\f[R].
  2333. If the file is later \f[B]open\f[R]\[cq]ed or \f[B]unlink\f[R]\[cq]ed
  2334. and the policy is different for those then a completely different file
  2335. or directory could be acted on.
  2336. .IP \[bu] 2
  2337. Some policies mixed with some functions may result in strange behaviors.
  2338. Not that some of these behaviors and race conditions couldn\[cq]t happen
  2339. outside \f[B]mergerfs\f[R] but that they are far more likely to occur on
  2340. account of the attempt to merge together multiple sources of data which
  2341. could be out of sync due to the different policies.
  2342. .IP \[bu] 2
  2343. For consistency its generally best to set \f[B]category\f[R] wide
  2344. policies rather than individual \f[B]func\f[R]\[cq]s.
  2345. This will help limit the confusion of tools such as
  2346. rsync (http://linux.die.net/man/1/rsync).
  2347. However, the flexibility is there if needed.
  2348. .SH KNOWN ISSUES / BUGS
  2349. .SS kernel issues & bugs
  2350. .PP
  2351. <https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs>
  2352. .SS directory mtime is not being updated
  2353. .PP
  2354. Remember that the default policy for \f[C]getattr\f[R] is \f[C]ff\f[R].
  2355. The information for the first directory found will be returned.
  2356. If it wasn\[cq]t the directory which had been updated then it will
  2357. appear outdated.
  2358. .PP
  2359. The reason this is the default is because any other policy would be more
  2360. expensive and for many applications it is unnecessary.
  2361. To always return the directory with the most recent mtime or a faked
  2362. value based on all found would require a scan of all filesystems.
  2363. .PP
  2364. If you always want the directory information from the one with the most
  2365. recent mtime then use the \f[C]newest\f[R] policy for \f[C]getattr\f[R].
  2366. .SS `mv /mnt/pool/foo /mnt/disk1/foo' removes `foo'
  2367. .PP
  2368. This is not a bug.
  2369. .PP
  2370. Run in verbose mode to better understand what\[cq]s happening:
  2371. .IP
  2372. .nf
  2373. \f[C]
  2374. $ mv -v /mnt/pool/foo /mnt/disk1/foo
  2375. copied \[aq]/mnt/pool/foo\[aq] -> \[aq]/mnt/disk1/foo\[aq]
  2376. removed \[aq]/mnt/pool/foo\[aq]
  2377. $ ls /mnt/pool/foo
  2378. ls: cannot access \[aq]/mnt/pool/foo\[aq]: No such file or directory
  2379. \f[R]
  2380. .fi
  2381. .PP
  2382. \f[C]mv\f[R], when working across devices, is copying the source to
  2383. target and then removing the source.
  2384. Since the source \f[B]is\f[R] the target in this case, depending on the
  2385. unlink policy, it will remove the just copied file and other files
  2386. across the branches.
  2387. .PP
  2388. If you want to move files to one filesystem just copy them there and use
  2389. mergerfs.dedup to clean up the old paths or manually remove them from
  2390. the branches directly.
  2391. .SS cached memory appears greater than it should be
  2392. .PP
  2393. Use \f[C]cache.files=off\f[R] and/or \f[C]dropcacheonclose=true\f[R].
  2394. See the section on page caching.
  2395. .SS NFS clients returning ESTALE / Stale file handle
  2396. .PP
  2397. NFS generally does not like out of band changes.
  2398. Take a look at the section on NFS in the #remote-filesystems for more
  2399. details.
  2400. .SS rtorrent fails with ENODEV (No such device)
  2401. .PP
  2402. Be sure to set \f[C]cache.files=partial|full|auto-full|per-processe\f[R]
  2403. or turn off \f[C]direct_io\f[R].
  2404. rtorrent and some other applications use
  2405. mmap (http://linux.die.net/man/2/mmap) to read and write to files and
  2406. offer no fallback to traditional methods.
  2407. FUSE does not currently support mmap while using \f[C]direct_io\f[R].
  2408. There may be a performance penalty on writes with \f[C]direct_io\f[R]
  2409. off as well as the problem of double caching but it\[cq]s the only way
  2410. to get such applications to work.
  2411. If the performance loss is too high for other apps you can mount
  2412. mergerfs twice.
  2413. Once with \f[C]direct_io\f[R] enabled and one without it.
  2414. Be sure to set \f[C]dropcacheonclose=true\f[R] if not using
  2415. \f[C]direct_io\f[R].
  2416. .SS Plex doesn\[cq]t work with mergerfs
  2417. .PP
  2418. It does.
  2419. If you\[cq]re trying to put Plex\[cq]s config / metadata / database on
  2420. mergerfs you can\[cq]t set \f[C]cache.files=off\f[R] because Plex is
  2421. using sqlite3 with mmap enabled.
  2422. Shared mmap is not supported by Linux\[cq]s FUSE implementation when
  2423. page caching is disabled.
  2424. To fix this place the data elsewhere (preferable) or enable
  2425. \f[C]cache.files\f[R] (with \f[C]dropcacheonclose=true\f[R]).
  2426. Sqlite3 does not need mmap but the developer needs to fall back to
  2427. standard IO if mmap fails.
  2428. .PP
  2429. This applies to other software: Radarr, Sonarr, Lidarr, Jellyfin, etc.
  2430. .PP
  2431. I would recommend reaching out to the developers of the software
  2432. you\[cq]re having troubles with and asking them to add a fallback to
  2433. regular file IO when mmap is unavailable.
  2434. .PP
  2435. If the issue is that scanning doesn\[cq]t seem to pick up media then be
  2436. sure to set \f[C]func.getattr=newest\f[R] though generally a full scan
  2437. will pick up all media anyway.
  2438. .SS When a program tries to move or rename a file it fails
  2439. .PP
  2440. Please read the section above regarding rename & link.
  2441. .PP
  2442. The problem is that many applications do not properly handle
  2443. \f[C]EXDEV\f[R] errors which \f[C]rename\f[R] and \f[C]link\f[R] may
  2444. return even though they are perfectly valid situations which do not
  2445. indicate actual device, filesystem, or OS errors.
  2446. The error will only be returned by mergerfs if using a path preserving
  2447. policy as described in the policy section above.
  2448. If you do not care about path preservation simply change the mergerfs
  2449. policy to the non-path preserving version.
  2450. For example: \f[C]-o category.create=mfs\f[R] Ideally the offending
  2451. software would be fixed and it is recommended that if you run into this
  2452. problem you contact the software\[cq]s author and request proper
  2453. handling of \f[C]EXDEV\f[R] errors.
  2454. .SS my 32bit software has problems
  2455. .PP
  2456. Some software have problems with 64bit inode values.
  2457. The symptoms can include EOVERFLOW errors when trying to list files.
  2458. You can address this by setting \f[C]inodecalc\f[R] to one of the 32bit
  2459. based algos as described in the relevant section.
  2460. .SS Samba: Moving files / directories fails
  2461. .PP
  2462. Workaround: Copy the file/directory and then remove the original rather
  2463. than move.
  2464. .PP
  2465. This isn\[cq]t an issue with Samba but some SMB clients.
  2466. GVFS-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed
  2467. to handle certain error codes correctly.
  2468. Particularly \f[B]STATUS_NOT_SAME_DEVICE\f[R] which comes from the
  2469. \f[B]EXDEV\f[R] which is returned by \f[B]rename\f[R] when the call is
  2470. crossing mount points.
  2471. When a program gets an \f[B]EXDEV\f[R] it needs to explicitly take an
  2472. alternate action to accomplish its goal.
  2473. In the case of \f[B]mv\f[R] or similar it tries \f[B]rename\f[R] and on
  2474. \f[B]EXDEV\f[R] falls back to a manual copying of data between the two
  2475. locations and unlinking the source.
  2476. In these older versions of GVFS-fuse if it received \f[B]EXDEV\f[R] it
  2477. would translate that into \f[B]EIO\f[R].
  2478. This would cause \f[B]mv\f[R] or most any application attempting to move
  2479. files around on that SMB share to fail with a IO error.
  2480. .PP
  2481. GVFS-fuse v1.22.0 (https://bugzilla.gnome.org/show_bug.cgi?id=734568)
  2482. and above fixed this issue but a large number of systems use the older
  2483. release.
  2484. On Ubuntu the version can be checked by issuing
  2485. \f[C]apt-cache showpkg gvfs-fuse\f[R].
  2486. Most distros released in 2015 seem to have the updated release and will
  2487. work fine but older systems may not.
  2488. Upgrading gvfs-fuse or the distro in general will address the problem.
  2489. .PP
  2490. In Apple\[cq]s MacOSX 10.9 they replaced Samba (client and server) with
  2491. their own product.
  2492. It appears their new client does not handle \f[B]EXDEV\f[R] either and
  2493. responds similar to older release of gvfs on Linux.
  2494. .SS Trashing files occasionally fails
  2495. .PP
  2496. This is the same issue as with Samba.
  2497. \f[C]rename\f[R] returns \f[C]EXDEV\f[R] (in our case that will really
  2498. only happen with path preserving policies like \f[C]epmfs\f[R]) and the
  2499. software doesn\[cq]t handle the situation well.
  2500. This is unfortunately a common failure of software which moves files
  2501. around.
  2502. The standard indicates that an implementation \f[C]MAY\f[R] choose to
  2503. support non-user home directory trashing of files (which is a
  2504. \f[C]MUST\f[R]).
  2505. The implementation \f[C]MAY\f[R] also support \[lq]top directory
  2506. trashes\[rq] which many probably do.
  2507. .PP
  2508. To create a \f[C]$topdir/.Trash\f[R] directory as defined in the
  2509. standard use the
  2510. mergerfs-tools (https://github.com/trapexit/mergerfs-tools) tool
  2511. \f[C]mergerfs.mktrash\f[R].
  2512. .SS Supplemental user groups
  2513. .PP
  2514. Due to the overhead of
  2515. getgroups/setgroups (http://linux.die.net/man/2/setgroups) mergerfs
  2516. utilizes a cache.
  2517. This cache is opportunistic and per thread.
  2518. Each thread will query the supplemental groups for a user when that
  2519. particular thread needs to change credentials and will keep that data
  2520. for the lifetime of the thread.
  2521. This means that if a user is added to a group it may not be picked up
  2522. without the restart of mergerfs.
  2523. However, since the high level FUSE API\[cq]s (at least the standard
  2524. version) thread pool dynamically grows and shrinks it\[cq]s possible
  2525. that over time a thread will be killed and later a new thread with no
  2526. cache will start and query the new data.
  2527. .PP
  2528. The gid cache uses fixed storage to simplify the design and be
  2529. compatible with older systems which may not have C++11 compilers.
  2530. There is enough storage for 256 users\[cq] supplemental groups.
  2531. Each user is allowed up to 32 supplemental groups.
  2532. Linux >= 2.6.3 allows up to 65535 groups per user but most other *nixs
  2533. allow far less.
  2534. NFS allowing only 16.
  2535. The system does handle overflow gracefully.
  2536. If the user has more than 32 supplemental groups only the first 32 will
  2537. be used.
  2538. If more than 256 users are using the system when an uncached user is
  2539. found it will evict an existing user\[cq]s cache at random.
  2540. So long as there aren\[cq]t more than 256 active users this should be
  2541. fine.
  2542. If either value is too low for your needs you will have to modify
  2543. \f[C]gidcache.hpp\f[R] to increase the values.
  2544. Note that doing so will increase the memory needed by each thread.
  2545. .PP
  2546. While not a bug some users have found when using containers that
  2547. supplemental groups defined inside the container don\[cq]t work properly
  2548. with regard to permissions.
  2549. This is expected as mergerfs lives outside the container and therefore
  2550. is querying the host\[cq]s group database.
  2551. There might be a hack to work around this (make mergerfs read the
  2552. /etc/group file in the container) but it is not yet implemented and
  2553. would be limited to Linux and the /etc/group DB.
  2554. Preferably users would mount in the host group file into the containers
  2555. or use a standard shared user & groups technology like NIS or LDAP.
  2556. .SH Remote Filesystems
  2557. .PP
  2558. Many users ask about compatibility with remote filesystems.
  2559. This section is to describe any known issues or quirks when using
  2560. mergerfs with common remote filesystems.
  2561. .PP
  2562. Keep in mind that, like with caching, it is not a good idea to change
  2563. the contents of the remote filesystem
  2564. out-of-band (https://en.wikipedia.org/wiki/Out-of-band).
  2565. Meaning that you really shouldn\[cq]t change the contents of the
  2566. underlying filesystems or mergerfs on the server hosting the remote
  2567. filesystem.
  2568. Doing so can lead to weird behavior, inconsistency, errors, and even
  2569. data corruption should multiple programs try to write or read the same
  2570. data at the same time.
  2571. This isn\[cq]t to say you can\[cq]t do it or that data corruption is
  2572. likely but it \f[I]could\f[R] happen.
  2573. It is better to always use the remote filesystem.
  2574. Even on the machine serving it.
  2575. .SS NFS
  2576. .PP
  2577. NFS (https://en.wikipedia.org/wiki/Network_File_System) is a common
  2578. remote filesystem on Unix/POSIX systems.
  2579. Due to how NFS works there are some settings which need to be set in
  2580. order for mergerfs to work with it.
  2581. .PP
  2582. It should be noted that NFS and FUSE (the technology mergerfs uses) do
  2583. not work perfectly with one another due to certain design choices in
  2584. FUSE (and mergerfs.) Due to these issues it is generally recommended to
  2585. use SMB when possible till situations change.
  2586. That said issues should still be reported.
  2587. NFS is not really recommended but it isn\[cq]t unsupported.
  2588. .PP
  2589. mergerfs settings: * noforget * inodecalc=path-hash *
  2590. export-support=false (only available in v2.40.0 and above)
  2591. .PP
  2592. NFS export settings: * fsid=UUID * no_root_squash
  2593. .PP
  2594. \f[C]noforget\f[R] is needed because NFS uses the
  2595. \f[C]name_to_handle_at\f[R] and \f[C]open_by_handle_at\f[R] functions
  2596. which allow a program to keep a reference to a file without technically
  2597. having it open in the typical sense.
  2598. The problem is that FUSE has no way to know that NFS has a handle that
  2599. it will later use to open the file again.
  2600. As a result it is possible for the kernel to tell mergerfs to forget
  2601. about the node and should NFS ever ask for that node\[cq]s details in
  2602. the future it would have nothing to respond with.
  2603. Keeping nodes around forever is not ideal but at the moment the only way
  2604. to manage the situation.
  2605. .PP
  2606. \f[C]inodecalc=path-hash\f[R] is needed because NFS is sensitive to
  2607. out-of-band changes.
  2608. FUSE doesn\[cq]t care if a file\[cq]s inode value changes but NFS, being
  2609. stateful, does.
  2610. So if you used the default inode calculation algorithm then it is
  2611. possible that if you changed a file or updated a directory the file
  2612. mergerfs will use will be on a different branch and therefore the inode
  2613. would change.
  2614. This isn\[cq]t an ideal solution and others are being considered but it
  2615. works for most situations.
  2616. It might be possible to leave the default value of \f[C]hybrid-hash\f[R]
  2617. if \f[C]export-support=false\f[R] but it hasn\[cq]t been fully tested
  2618. yet.
  2619. .PP
  2620. \f[C]export-support=false\f[R] is a low-level FUSE option that is needed
  2621. as a workaround to a Linux kernel bug.
  2622. Technically this option should be set to \f[C]true\f[R] when expecting
  2623. to use mergerfs with NFS but it turns out that at least some versions of
  2624. NFS work when not enabled.
  2625. At the moment it is unclear if this has any negative side effects but
  2626. when disabled NFS appears to work alright and the kernel no longer sends
  2627. invalid requests.
  2628. When the issue is resolved in the kernel these docs will be updated with
  2629. appropriate details.
  2630. .PP
  2631. Also see Kernel Issues &
  2632. Bugs (https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs)
  2633. for more details.
  2634. .PP
  2635. \f[C]fsid=UUID\f[R] is needed because FUSE filesystems don\[cq]t have
  2636. different \f[C]st_dev\f[R] values which can cause issues when exporting.
  2637. The easiest thing to do is set each mergerfs export \f[C]fsid\f[R] to
  2638. some random value.
  2639. An easy way to generate a random value is to use the command line tool
  2640. \f[C]uuidgen\f[R] or through a website such as
  2641. uuidgenerator.net (https://www.uuidgenerator.net/).
  2642. .PP
  2643. \f[C]no_root_squash\f[R] is not strictly necessary but can lead to
  2644. confusing permission and ownership issues.
  2645. .SS SMB / CIFS
  2646. .PP
  2647. SMB (https://en.wikipedia.org/wiki/Server_Message_Block) is a protocol
  2648. most used by Microsoft Windows systems to share file shares, printers,
  2649. etc.
  2650. However, due to the popularity for Windows, it is also supported on many
  2651. other platforms including Linux.
  2652. The most popular way of supporting SMB on Linux is via the software
  2653. Samba.
  2654. .PP
  2655. Samba (https://en.wikipedia.org/wiki/Samba_(software)), and other ways
  2656. of serving Linux filesystems, via SMB should work fine with mergerfs.
  2657. The services do not tend to use the same technologies which NFS uses and
  2658. therefore don\[cq]t have the same issues.
  2659. There should not be an special settings required to use mergerfs with
  2660. Samba.
  2661. However, CIFSD (https://en.wikipedia.org/wiki/CIFSD) and other programs
  2662. have not been extensively tested.
  2663. If you use mergerfs with CIFSD or other SMB servers please submit your
  2664. experiences so these docs can be updated.
  2665. .SS SSHFS
  2666. .PP
  2667. SSHFS (https://en.wikipedia.org/wiki/SSHFS) is a FUSE filesystem
  2668. leveraging SSH as the connection and transport layer.
  2669. While often simpler to setup when compared to NFS or Samba the
  2670. performance can be lacking and the project is very much in maintenance
  2671. mode.
  2672. .PP
  2673. There are no known issues using sshfs with mergerfs.
  2674. You may want to use the following arguments to improve performance but
  2675. your millage may vary.
  2676. .IP \[bu] 2
  2677. \f[C]-o Ciphers=arcfour\f[R]
  2678. .IP \[bu] 2
  2679. \f[C]-o Compression=no\f[R]
  2680. .PP
  2681. More info can be found
  2682. here (https://ideatrash.net/2016/08/odds-and-ends-optimizing-sshfs-moving.html).
  2683. .SS Other
  2684. .PP
  2685. There are other remote filesystems but none popularly used to serve
  2686. mergerfs.
  2687. If you use something not listed above feel free to reach out and I will
  2688. add it to the list.
  2689. .SH FAQ
  2690. .SS How well does mergerfs scale? Is it \[lq]production ready?\[rq]
  2691. .PP
  2692. Users have reported running mergerfs on everything from a Raspberry Pi
  2693. to dual socket Xeon systems with >20 cores.
  2694. I\[cq]m aware of at least a few companies which use mergerfs in
  2695. production.
  2696. Open Media Vault (https://www.openmediavault.org) includes mergerfs as
  2697. its sole solution for pooling filesystems.
  2698. The author of mergerfs had it running for over 300 days managing 16+
  2699. devices with reasonably heavy 24/7 read and write usage.
  2700. Stopping only after the machine\[cq]s power supply died.
  2701. .PP
  2702. Most serious issues (crashes or data corruption) have been due to kernel
  2703. bugs (https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs).
  2704. All of which are fixed in stable releases.
  2705. .SS Can mergerfs be used with filesystems which already have data / are in use?
  2706. .PP
  2707. Yes.
  2708. mergerfs is really just a proxy and does \f[B]NOT\f[R] interfere with
  2709. the normal form or function of the filesystems / mounts / paths it
  2710. manages.
  2711. It is just another userland application that is acting as a
  2712. man-in-the-middle.
  2713. It can\[cq]t do anything that any other random piece of software
  2714. can\[cq]t do.
  2715. .PP
  2716. mergerfs is \f[B]not\f[R] a traditional filesystem that takes control
  2717. over the underlying block device.
  2718. mergerfs is \f[B]not\f[R] RAID.
  2719. It does \f[B]not\f[R] manipulate the data that passes through it.
  2720. It does \f[B]not\f[R] shard data across filesystems.
  2721. It merely shards some \f[B]behavior\f[R] and aggregates others.
  2722. .SS Can drives/filesystems be removed from the pool at will?
  2723. .PP
  2724. Yes.
  2725. See previous question\[cq]s answer.
  2726. .SS Can mergerfs be removed without affecting the data?
  2727. .PP
  2728. Yes.
  2729. See the previous question\[cq]s answer.
  2730. .SS Can drives/filesystems be moved to another pool?
  2731. .PP
  2732. Yes.
  2733. See the previous question\[cq]s answer.
  2734. .SS How do I migrate data into or out of the pool when adding/removing drives/filesystems?
  2735. .PP
  2736. You don\[cq]t need to.
  2737. See the previous question\[cq]s answer.
  2738. .SS How do I remove a drive/filesystem but keep the data in the pool?
  2739. .PP
  2740. Nothing special needs to be done.
  2741. Remove the branch from mergerfs\[cq] config and copy (rsync) the data
  2742. from the removed filesystem into the pool.
  2743. Effectively the same as if it were you transfering data from one
  2744. filesystem to another.
  2745. .PP
  2746. If you wish to continue using the pool while performing the transfer
  2747. simply create another, temporary pool without the filesystem in question
  2748. and then copy the data.
  2749. It would probably be a good idea to set the branch to \f[C]RO\f[R] prior
  2750. to doing this to ensure no new content is written to the filesystem
  2751. while performing the copy.
  2752. .SS What policies should I use?
  2753. .PP
  2754. Unless you\[cq]re doing something more niche the average user is
  2755. probably best off using \f[C]mfs\f[R] for \f[C]category.create\f[R].
  2756. It will spread files out across your branches based on available space.
  2757. Use \f[C]mspmfs\f[R] if you want to try to colocate the data a bit more.
  2758. You may want to use \f[C]lus\f[R] if you prefer a slightly different
  2759. distribution of data if you have a mix of smaller and larger
  2760. filesystems.
  2761. Generally though \f[C]mfs\f[R], \f[C]lus\f[R], or even \f[C]rand\f[R]
  2762. are good for the general use case.
  2763. If you are starting with an imbalanced pool you can use the tool
  2764. \f[B]mergerfs.balance\f[R] to redistribute files across the pool.
  2765. .PP
  2766. If you really wish to try to colocate files based on directory you can
  2767. set \f[C]func.create\f[R] to \f[C]epmfs\f[R] or similar and
  2768. \f[C]func.mkdir\f[R] to \f[C]rand\f[R] or \f[C]eprand\f[R] depending on
  2769. if you just want to colocate generally or on specific branches.
  2770. Either way the \f[I]need\f[R] to colocate is rare.
  2771. For instance: if you wish to remove the device regularly and want the
  2772. data to predictably be on that device or if you don\[cq]t use backup at
  2773. all and don\[cq]t wish to replace that data piecemeal.
  2774. In which case using path preservation can help but will require some
  2775. manual attention.
  2776. Colocating after the fact can be accomplished using the
  2777. \f[B]mergerfs.consolidate\f[R] tool.
  2778. If you don\[cq]t need strict colocation which the \f[C]ep\f[R] policies
  2779. provide then you can use the \f[C]msp\f[R] based policies which will
  2780. walk back the path till finding a branch that works.
  2781. .PP
  2782. Ultimately there is no correct answer.
  2783. It is a preference or based on some particular need.
  2784. mergerfs is very easy to test and experiment with.
  2785. I suggest creating a test setup and experimenting to get a sense of what
  2786. you want.
  2787. .PP
  2788. \f[C]epmfs\f[R] is the default \f[C]category.create\f[R] policy because
  2789. \f[C]ep\f[R] policies are not going to change the general layout of the
  2790. branches.
  2791. It won\[cq]t place files/dirs on branches that don\[cq]t already have
  2792. the relative branch.
  2793. So it keeps the system in a known state.
  2794. It\[cq]s much easier to stop using \f[C]epmfs\f[R] or redistribute files
  2795. around the filesystem than it is to consolidate them back.
  2796. .SS What settings should I use?
  2797. .PP
  2798. Depends on what features you want.
  2799. Generally speaking there are no \[lq]wrong\[rq] settings.
  2800. All settings are performance or feature related.
  2801. The best bet is to read over the available options and choose what fits
  2802. your situation.
  2803. If something isn\[cq]t clear from the documentation please reach out and
  2804. the documentation will be improved.
  2805. .PP
  2806. That said, for the average person, the following should be fine:
  2807. .PP
  2808. \f[C]cache.files=off,dropcacheonclose=true,category.create=mfs\f[R]
  2809. .SS Why are all my files ending up on 1 filesystem?!
  2810. .PP
  2811. Did you start with empty filesystems?
  2812. Did you explicitly configure a \f[C]category.create\f[R] policy?
  2813. Are you using an \f[C]existing path\f[R] / \f[C]path preserving\f[R]
  2814. policy?
  2815. .PP
  2816. The default create policy is \f[C]epmfs\f[R].
  2817. That is a path preserving algorithm.
  2818. With such a policy for \f[C]mkdir\f[R] and \f[C]create\f[R] with a set
  2819. of empty filesystems it will select only 1 filesystem when the first
  2820. directory is created.
  2821. Anything, files or directories, created in that first directory will be
  2822. placed on the same branch because it is preserving paths.
  2823. .PP
  2824. This catches a lot of new users off guard but changing the default would
  2825. break the setup for many existing users and this policy is the safest
  2826. policy as it will not change the general layout of the existing
  2827. filesystems.
  2828. If you do not care about path preservation and wish your files to be
  2829. spread across all your filesystems change to \f[C]mfs\f[R] or similar
  2830. policy as described above.
  2831. If you do want path preservation you\[cq]ll need to perform the manual
  2832. act of creating paths on the filesystems you want the data to land on
  2833. before transferring your data.
  2834. Setting \f[C]func.mkdir=epall\f[R] can simplify managing path
  2835. preservation for \f[C]create\f[R].
  2836. Or use \f[C]func.mkdir=rand\f[R] if you\[cq]re interested in just
  2837. grouping together directory content by filesystem.
  2838. .SS Do hardlinks work?
  2839. .PP
  2840. Yes.
  2841. See also the option \f[C]inodecalc\f[R] for how inode values are
  2842. calculated.
  2843. .PP
  2844. What mergerfs does not do is fake hard links across branches.
  2845. Read the section \[lq]rename & link\[rq] for how it works.
  2846. .PP
  2847. Remember that hardlinks will NOT work across devices.
  2848. That includes between the original filesystem and a mergerfs pool,
  2849. between two separate pools of the same underlying filesystems, or bind
  2850. mounts of paths within the mergerfs pool.
  2851. The latter is common when using Docker or Podman.
  2852. Multiple volumes (bind mounts) to the same underlying filesystem are
  2853. considered different devices.
  2854. There is no way to link between them.
  2855. You should mount in the highest directory in the mergerfs pool that
  2856. includes all the paths you need if you want links to work.
  2857. .SS Does FICLONE or FICLONERANGE work?
  2858. .PP
  2859. Unfortunately not.
  2860. FUSE, the technology mergerfs is based on, does not support the
  2861. \f[C]clone_file_range\f[R] feature needed for it to work.
  2862. mergerfs won\[cq]t even know such a request is made.
  2863. The kernel will simply return an error back to the application making
  2864. the request.
  2865. .PP
  2866. Should FUSE gain the ability mergerfs will be updated to support it.
  2867. .SS Can I use mergerfs without SnapRAID? SnapRAID without mergerfs?
  2868. .PP
  2869. Yes.
  2870. They are completely unrelated pieces of software.
  2871. .SS Can mergerfs run via Docker, Podman, Kubernetes, etc.
  2872. .PP
  2873. Yes.
  2874. With Docker you\[cq]ll need to include
  2875. \f[C]--cap-add=SYS_ADMIN --device=/dev/fuse --security-opt=apparmor:unconfined\f[R]
  2876. or similar with other container runtimes.
  2877. You should also be running it as root or given sufficient caps to change
  2878. user and group identity as well as have root like filesystem
  2879. permissions.
  2880. .PP
  2881. Keep in mind that you \f[B]MUST\f[R] consider identity when using
  2882. containers.
  2883. For example: supplemental groups will be picked up from the container
  2884. unless you properly manage users and groups by sharing relevant /etc
  2885. files or by using some other means to share identity across containers.
  2886. Similarly if you use \[lq]rootless\[rq] containers and user namespaces
  2887. to do uid/gid translations you \f[B]MUST\f[R] consider that while
  2888. managing shared files.
  2889. .PP
  2890. Also, as mentioned by hotio (https://hotio.dev/containers/mergerfs),
  2891. with Docker you should probably be mounting with
  2892. \f[C]bind-propagation\f[R] set to \f[C]slave\f[R].
  2893. .SS Does mergerfs support CoW / copy-on-write / writes to read-only filesystems?
  2894. .PP
  2895. Not in the sense of a filesystem like BTRFS or ZFS nor in the overlayfs
  2896. or aufs sense.
  2897. It does offer a
  2898. cow-shell (http://manpages.ubuntu.com/manpages/bionic/man1/cow-shell.1.html)
  2899. like hard link breaking (copy to temp file then rename over original)
  2900. which can be useful when wanting to save space by hardlinking duplicate
  2901. files but wish to treat each name as if it were a unique and separate
  2902. file.
  2903. .PP
  2904. If you want to write to a read-only filesystem you should look at
  2905. overlayfs.
  2906. You can always include the overlayfs mount into a mergerfs pool.
  2907. .SS Why can\[cq]t I see my files / directories?
  2908. .PP
  2909. It\[cq]s almost always a permissions issue.
  2910. Unlike mhddfs and unionfs-fuse, which runs as root and attempts to
  2911. access content as such, mergerfs always changes its credentials to that
  2912. of the caller.
  2913. This means that if the user does not have access to a file or directory
  2914. than neither will mergerfs.
  2915. However, because mergerfs is creating a union of paths it may be able to
  2916. read some files and directories on one filesystem but not another
  2917. resulting in an incomplete set.
  2918. .PP
  2919. Whenever you run into a split permission issue (seeing some but not all
  2920. files) try using
  2921. mergerfs.fsck (https://github.com/trapexit/mergerfs-tools) tool to check
  2922. for and fix the mismatch.
  2923. If you aren\[cq]t seeing anything at all be sure that the basic
  2924. permissions are correct.
  2925. The user and group values are correct and that directories have their
  2926. executable bit set.
  2927. A common mistake by users new to Linux is to \f[C]chmod -R 644\f[R] when
  2928. they should have \f[C]chmod -R u=rwX,go=rX\f[R].
  2929. .PP
  2930. If using a network filesystem such as NFS or SMB (Samba) be sure to pay
  2931. close attention to anything regarding permissioning and users.
  2932. Root squashing and user translation for instance has bitten a few
  2933. mergerfs users.
  2934. Some of these also affect the use of mergerfs from container platforms
  2935. such as Docker.
  2936. .SS Why use FUSE? Why not a kernel based solution?
  2937. .PP
  2938. As with any solutions to a problem there are advantages and
  2939. disadvantages to each one.
  2940. .PP
  2941. A FUSE based solution has all the downsides of FUSE:
  2942. .IP \[bu] 2
  2943. Higher IO latency due to the trips in and out of kernel space
  2944. .IP \[bu] 2
  2945. Higher general overhead due to trips in and out of kernel space
  2946. .IP \[bu] 2
  2947. Double caching when using page caching
  2948. .IP \[bu] 2
  2949. Misc limitations due to FUSE\[cq]s design
  2950. .PP
  2951. But FUSE also has a lot of upsides:
  2952. .IP \[bu] 2
  2953. Easier to offer a cross platform solution
  2954. .IP \[bu] 2
  2955. Easier forward and backward compatibility
  2956. .IP \[bu] 2
  2957. Easier updates for users
  2958. .IP \[bu] 2
  2959. Easier and faster release cadence
  2960. .IP \[bu] 2
  2961. Allows more flexibility in design and features
  2962. .IP \[bu] 2
  2963. Overall easier to write, secure, and maintain
  2964. .IP \[bu] 2
  2965. Much lower barrier to entry (getting code into the kernel takes a lot of
  2966. time and effort initially)
  2967. .PP
  2968. FUSE was chosen because of all the advantages listed above.
  2969. The negatives of FUSE do not outweigh the positives.
  2970. .SS Is my OS\[cq]s libfuse needed for mergerfs to work?
  2971. .PP
  2972. No.\ Normally \f[C]mount.fuse\f[R] is needed to get mergerfs (or any
  2973. FUSE filesystem to mount using the \f[C]mount\f[R] command but in
  2974. vendoring the libfuse library the \f[C]mount.fuse\f[R] app has been
  2975. renamed to \f[C]mount.mergerfs\f[R] meaning the filesystem type in
  2976. \f[C]fstab\f[R] can simply be \f[C]mergerfs\f[R].
  2977. That said there should be no harm in having it installed and continuing
  2978. to using \f[C]fuse.mergerfs\f[R] as the type in \f[C]/etc/fstab\f[R].
  2979. .PP
  2980. If \f[C]mergerfs\f[R] doesn\[cq]t work as a type it could be due to how
  2981. the \f[C]mount.mergerfs\f[R] tool was installed.
  2982. Must be in \f[C]/sbin/\f[R] with proper permissions.
  2983. .SS Why was splice support removed?
  2984. .PP
  2985. After a lot of testing over the years splicing always appeared to be at
  2986. best provide equivalent performance and in cases worse performance.
  2987. Splice is not supported on other platforms forcing a traditional
  2988. read/write fallback to be provided.
  2989. The splice code was removed to simplify the codebase.
  2990. .SS What should mergerfs NOT be used for?
  2991. .IP \[bu] 2
  2992. databases: Even if the database stored data in separate files (mergerfs
  2993. wouldn\[cq]t offer much otherwise) the higher latency of the indirection
  2994. will kill performance.
  2995. If it is a lightly used SQLITE database then it may be fine but
  2996. you\[cq]ll need to test.
  2997. .IP \[bu] 2
  2998. VM images: For the same reasons as databases.
  2999. VM images are accessed very aggressively and mergerfs will introduce too
  3000. much latency (if it works at all).
  3001. .IP \[bu] 2
  3002. As replacement for RAID: mergerfs is just for pooling branches.
  3003. If you need that kind of device performance aggregation or high
  3004. availability you should stick with RAID.
  3005. .SS Can filesystems be written to directly? Outside of mergerfs while pooled?
  3006. .PP
  3007. Yes, however it\[cq]s not recommended to use the same file from within
  3008. the pool and from without at the same time (particularly writing).
  3009. Especially if using caching of any kind (cache.files, cache.entry,
  3010. cache.attr, cache.negative_entry, cache.symlinks, cache.readdir, etc.)
  3011. as there could be a conflict between cached data and not.
  3012. .SS Why do I get an \[lq]out of space\[rq] / \[lq]no space left on device\[rq] / ENOSPC error even though there appears to be lots of space available?
  3013. .PP
  3014. First make sure you\[cq]ve read the sections above about policies, path
  3015. preservation, branch filtering, and the options \f[B]minfreespace\f[R],
  3016. \f[B]moveonenospc\f[R], \f[B]statfs\f[R], and \f[B]statfs_ignore\f[R].
  3017. .PP
  3018. mergerfs is simply presenting a union of the content within multiple
  3019. branches.
  3020. The reported free space is an aggregate of space available within the
  3021. pool (behavior modified by \f[B]statfs\f[R] and
  3022. \f[B]statfs_ignore\f[R]).
  3023. It does not represent a contiguous space.
  3024. In the same way that read-only filesystems, those with quotas, or
  3025. reserved space report the full theoretical space available.
  3026. .PP
  3027. Due to path preservation, branch tagging, read-only status, and
  3028. \f[B]minfreespace\f[R] settings it is perfectly valid that
  3029. \f[C]ENOSPC\f[R] / \[lq]out of space\[rq] / \[lq]no space left on
  3030. device\[rq] be returned.
  3031. It is doing what was asked of it: filtering possible branches due to
  3032. those settings.
  3033. Only one error can be returned and if one of the reasons for filtering a
  3034. branch was \f[B]minfreespace\f[R] then it will be returned as such.
  3035. \f[B]moveonenospc\f[R] is only relevant to writing a file which is too
  3036. large for the filesystem it\[cq]s currently on.
  3037. .PP
  3038. It is also possible that the filesystem selected has run out of inodes.
  3039. Use \f[C]df -i\f[R] to list the total and available inodes per
  3040. filesystem.
  3041. .PP
  3042. If you don\[cq]t care about path preservation then simply change the
  3043. \f[C]create\f[R] policy to one which isn\[cq]t.
  3044. \f[C]mfs\f[R] is probably what most are looking for.
  3045. The reason it\[cq]s not default is because it was originally set to
  3046. \f[C]epmfs\f[R] and changing it now would change people\[cq]s setup.
  3047. Such a setting change will likely occur in mergerfs 3.
  3048. .SS Why does the total available space in mergerfs not equal outside?
  3049. .PP
  3050. Are you using ext2/3/4?
  3051. With reserve for root?
  3052. mergerfs uses available space for statfs calculations.
  3053. If you\[cq]ve reserved space for root then it won\[cq]t show up.
  3054. .PP
  3055. You can remove the reserve by running: \f[C]tune2fs -m 0 <device>\f[R]
  3056. .SS I notice massive slowdowns of writes when enabling cache.files.
  3057. .PP
  3058. When file caching is enabled in any form (\f[C]cache.files!=off\f[R]) it
  3059. will issue \f[C]getxattr\f[R] requests for \f[C]security.capability\f[R]
  3060. prior to \f[I]every single write\f[R].
  3061. This will usually result in a performance degradation, especially when
  3062. using a network filesystem (such as NFS or SMB.) Unfortunately at this
  3063. moment the kernel is not caching the response.
  3064. .PP
  3065. To work around this situation mergerfs offers a few solutions.
  3066. .IP "1." 3
  3067. Set \f[C]security_capability=false\f[R].
  3068. It will short circuit any call and return \f[C]ENOATTR\f[R].
  3069. This still means though that mergerfs will receive the request before
  3070. every write but at least it doesn\[cq]t get passed through to the
  3071. underlying filesystem.
  3072. .IP "2." 3
  3073. Set \f[C]xattr=noattr\f[R].
  3074. Same as above but applies to \f[I]all\f[R] calls to getxattr.
  3075. Not just \f[C]security.capability\f[R].
  3076. This will not be cached by the kernel either but mergerfs\[cq] runtime
  3077. config system will still function.
  3078. .IP "3." 3
  3079. Set \f[C]xattr=nosys\f[R].
  3080. Results in mergerfs returning \f[C]ENOSYS\f[R] which \f[I]will\f[R] be
  3081. cached by the kernel.
  3082. No future xattr calls will be forwarded to mergerfs.
  3083. The downside is that also means the xattr based config and query
  3084. functionality won\[cq]t work either.
  3085. .IP "4." 3
  3086. Disable file caching.
  3087. If you aren\[cq]t using applications which use \f[C]mmap\f[R] it\[cq]s
  3088. probably simpler to just disable it all together.
  3089. The kernel won\[cq]t send the requests when caching is disabled.
  3090. .SS It\[cq]s mentioned that there are some security issues with mhddfs. What are they? How does mergerfs address them?
  3091. .PP
  3092. mhddfs (https://github.com/trapexit/mhddfs) manages running as
  3093. \f[B]root\f[R] by calling
  3094. getuid() (https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  3095. and if it returns \f[B]0\f[R] then it will
  3096. chown (http://linux.die.net/man/1/chown) the file.
  3097. Not only is that a race condition but it doesn\[cq]t handle other
  3098. situations.
  3099. Rather than attempting to simulate POSIX ACL behavior the proper way to
  3100. manage this is to use seteuid (http://linux.die.net/man/2/seteuid) and
  3101. setegid (http://linux.die.net/man/2/setegid), in effect becoming the
  3102. user making the original call, and perform the action as them.
  3103. This is what mergerfs does and why mergerfs should always run as root.
  3104. .PP
  3105. In Linux setreuid syscalls apply only to the thread.
  3106. GLIBC hides this away by using realtime signals to inform all threads to
  3107. change credentials.
  3108. Taking after \f[B]Samba\f[R], mergerfs uses
  3109. \f[B]syscall(SYS_setreuid,\&...)\f[R] to set the callers credentials for
  3110. that thread only.
  3111. Jumping back to \f[B]root\f[R] as necessary should escalated privileges
  3112. be needed (for instance: to clone paths between filesystems).
  3113. .PP
  3114. For non-Linux systems mergerfs uses a read-write lock and changes
  3115. credentials only when necessary.
  3116. If multiple threads are to be user X then only the first one will need
  3117. to change the processes credentials.
  3118. So long as the other threads need to be user X they will take a readlock
  3119. allowing multiple threads to share the credentials.
  3120. Once a request comes in to run as user Y that thread will attempt a
  3121. write lock and change to Y\[cq]s credentials when it can.
  3122. If the ability to give writers priority is supported then that flag will
  3123. be used so threads trying to change credentials don\[cq]t starve.
  3124. This isn\[cq]t the best solution but should work reasonably well
  3125. assuming there are few users.
  3126. .SH mergerfs versus X
  3127. .SS mhddfs
  3128. .PP
  3129. mhddfs had not been maintained for some time and has some known
  3130. stability and security issues.
  3131. mergerfs provides a superset of mhddfs\[cq] features and should offer
  3132. the same or better performance.
  3133. .PP
  3134. Below is an example of mhddfs and mergerfs setup to work similarly.
  3135. .PP
  3136. \f[C]mhddfs -o mlimit=4G,allow_other /mnt/drive1,/mnt/drive2 /mnt/pool\f[R]
  3137. .PP
  3138. \f[C]mergerfs -o minfreespace=4G,category.create=ff /mnt/drive1:/mnt/drive2 /mnt/pool\f[R]
  3139. .SS aufs
  3140. .PP
  3141. aufs is mostly abandoned and no longer available in most Linux distros.
  3142. .PP
  3143. While aufs can offer better peak performance mergerfs provides more
  3144. configurability and is generally easier to use.
  3145. mergerfs however does not offer the overlay / copy-on-write (CoW)
  3146. features which aufs has.
  3147. .SS unionfs-fuse
  3148. .PP
  3149. unionfs-fuse is more like aufs than mergerfs in that it offers overlay /
  3150. copy-on-write (CoW) features.
  3151. If you\[cq]re just looking to create a union of filesystems and want
  3152. flexibility in file/directory placement then mergerfs offers that
  3153. whereas unionfs is more for overlaying read/write filesystems over
  3154. read-only ones.
  3155. .SS overlayfs
  3156. .PP
  3157. overlayfs is similar to aufs and unionfs-fuse in that it also is
  3158. primarily used to layer a read/write filesystem over one or more
  3159. read-only filesystems.
  3160. It does not have the ability to spread files/directories across numerous
  3161. filesystems.
  3162. .SS RAID0, JBOD, drive concatenation, striping
  3163. .PP
  3164. With simple JBOD / drive concatenation / stripping / RAID0 a single
  3165. drive failure will result in full pool failure.
  3166. mergerfs performs a similar function without the possibility of
  3167. catastrophic failure and the difficulties in recovery.
  3168. Drives may fail but all other filesystems and their data will continue
  3169. to be accessible.
  3170. .PP
  3171. The main practical difference with mergerfs is the fact you don\[cq]t
  3172. actually have contiguous space as large as if you used those other
  3173. technologies.
  3174. Meaning you can\[cq]t create a 2TB file on a pool of 2 1TB filesystems.
  3175. .PP
  3176. When combined with something like SnapRaid (http://www.snapraid.it)
  3177. and/or an offsite backup solution you can have the flexibility of JBOD
  3178. without the single point of failure.
  3179. .SS UnRAID
  3180. .PP
  3181. UnRAID is a full OS and its storage layer, as I understand, is
  3182. proprietary and closed source.
  3183. Users who have experience with both have often said they prefer the
  3184. flexibility offered by mergerfs and for some the fact it is open source
  3185. is important.
  3186. .PP
  3187. There are a number of UnRAID users who use mergerfs as well though
  3188. I\[cq]m not entirely familiar with the use case.
  3189. .PP
  3190. For semi-static data mergerfs + SnapRaid (http://www.snapraid.it)
  3191. provides a similar solution.
  3192. .SS ZFS
  3193. .PP
  3194. mergerfs is very different from ZFS.
  3195. mergerfs is intended to provide flexible pooling of arbitrary
  3196. filesystems (local or remote), of arbitrary sizes, and arbitrary
  3197. filesystems.
  3198. For \f[C]write once, read many\f[R] usecases such as bulk media storage.
  3199. Where data integrity and backup is managed in other ways.
  3200. In those usecases ZFS can introduce a number of costs and limitations as
  3201. described
  3202. here (http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html),
  3203. here (https://markmcb.com/2020/01/07/five-years-of-btrfs/), and
  3204. here (https://utcc.utoronto.ca/~cks/space/blog/solaris/ZFSWhyNoRealReshaping).
  3205. .SS StableBit\[cq]s DrivePool
  3206. .PP
  3207. DrivePool works only on Windows so not as common an alternative as other
  3208. Linux solutions.
  3209. If you want to use Windows then DrivePool is a good option.
  3210. Functionally the two projects work a bit differently.
  3211. DrivePool always writes to the filesystem with the most free space and
  3212. later rebalances.
  3213. mergerfs does not offer rebalance but chooses a branch at file/directory
  3214. create time.
  3215. DrivePool\[cq]s rebalancing can be done differently in any directory and
  3216. has file pattern matching to further customize the behavior.
  3217. mergerfs, not having rebalancing does not have these features, but
  3218. similar features are planned for mergerfs v3.
  3219. DrivePool has builtin file duplication which mergerfs does not natively
  3220. support (but can be done via an external script.)
  3221. .PP
  3222. There are a lot of misc differences between the two projects but most
  3223. features in DrivePool can be replicated with external tools in
  3224. combination with mergerfs.
  3225. .PP
  3226. Additionally DrivePool is a closed source commercial product vs mergerfs
  3227. a ISC licensed OSS project.
  3228. .SH SUPPORT
  3229. .PP
  3230. Filesystems are complex and difficult to debug.
  3231. mergerfs, while being just a proxy of sorts, can be difficult to debug
  3232. given the large number of possible settings it can have itself and the
  3233. number of environments it can run in.
  3234. When reporting on a suspected issue \f[B]please\f[R] include as much of
  3235. the below information as possible otherwise it will be difficult or
  3236. impossible to diagnose.
  3237. Also please read the above documentation as it provides details on many
  3238. previously encountered questions/issues.
  3239. .PP
  3240. \f[B]Please make sure you are using the latest
  3241. release (https://github.com/trapexit/mergerfs/releases) or have tried it
  3242. in comparison. Old versions, which are often included in distros like
  3243. Debian and Ubuntu, are not ever going to be updated and the issue you
  3244. are encountering may have been addressed already.\f[R]
  3245. .PP
  3246. \f[B]For commercial support or feature requests please contact me
  3247. directly. (mailto:support@spawn.link)\f[R]
  3248. .SS Information to include in bug reports
  3249. .IP \[bu] 2
  3250. Information about the broader problem along with any attempted
  3251. solutions. (https://xyproblem.info)
  3252. .IP \[bu] 2
  3253. Solution already ruled out and why.
  3254. .IP \[bu] 2
  3255. Version of mergerfs: \f[C]mergerfs --version\f[R]
  3256. .IP \[bu] 2
  3257. mergerfs settings / arguments: from fstab, systemd unit, command line,
  3258. OMV plugin, etc.
  3259. .IP \[bu] 2
  3260. Version of the OS: \f[C]uname -a\f[R] and \f[C]lsb_release -a\f[R]
  3261. .IP \[bu] 2
  3262. List of branches, their filesystem types, sizes (before and after
  3263. issue): \f[C]df -h\f[R]
  3264. .IP \[bu] 2
  3265. \f[B]All\f[R] information about the relevant paths and files:
  3266. permissions, ownership, etc.
  3267. .IP \[bu] 2
  3268. \f[B]All\f[R] information about the client app making the requests:
  3269. version, uid/gid
  3270. .IP \[bu] 2
  3271. Runtime environment:
  3272. .RS 2
  3273. .IP \[bu] 2
  3274. Is mergerfs running within a container?
  3275. .IP \[bu] 2
  3276. Are the client apps using mergerfs running in a container?
  3277. .RE
  3278. .IP \[bu] 2
  3279. A \f[C]strace\f[R] of the app having problems:
  3280. .RS 2
  3281. .IP \[bu] 2
  3282. \f[C]strace -fvTtt -s 256 -o /tmp/app.strace.txt <cmd>\f[R]
  3283. .RE
  3284. .IP \[bu] 2
  3285. A \f[C]strace\f[R] of mergerfs while the program is trying to do
  3286. whatever it is failing to do:
  3287. .RS 2
  3288. .IP \[bu] 2
  3289. \f[C]strace -fvTtt -s 256 -p <mergerfsPID> -o /tmp/mergerfs.strace.txt\f[R]
  3290. .RE
  3291. .IP \[bu] 2
  3292. \f[B]Precise\f[R] directions on replicating the issue.
  3293. Do not leave \f[B]anything\f[R] out.
  3294. .IP \[bu] 2
  3295. Try to recreate the problem in the simplest way using standard programs:
  3296. \f[C]ln\f[R], \f[C]mv\f[R], \f[C]cp\f[R], \f[C]ls\f[R], \f[C]dd\f[R],
  3297. etc.
  3298. .SS Contact / Issue submission
  3299. .IP \[bu] 2
  3300. github.com: https://github.com/trapexit/mergerfs/issues
  3301. .IP \[bu] 2
  3302. discord: https://discord.gg/MpAr69V
  3303. .IP \[bu] 2
  3304. reddit: https://www.reddit.com/r/mergerfs
  3305. .SS Donations
  3306. .PP
  3307. https://github.com/trapexit/support
  3308. .PP
  3309. Development and support of a project like mergerfs requires a
  3310. significant amount of time and effort.
  3311. The software is released under the very liberal ISC license and is
  3312. therefore free to use for personal or commercial uses.
  3313. .PP
  3314. If you are a personal user and find mergerfs and its support valuable
  3315. and would like to support the project financially it would be very much
  3316. appreciated.
  3317. .PP
  3318. If you are using mergerfs commercially please consider sponsoring the
  3319. project to ensure it continues to be maintained and receive updates.
  3320. If custom features are needed feel free to contact me
  3321. directly (mailto:support@spawn.link).
  3322. .SH LINKS
  3323. .IP \[bu] 2
  3324. https://spawn.link
  3325. .IP \[bu] 2
  3326. https://github.com/trapexit/mergerfs
  3327. .IP \[bu] 2
  3328. https://github.com/trapexit/mergerfs/wiki
  3329. .IP \[bu] 2
  3330. https://github.com/trapexit/mergerfs-tools
  3331. .IP \[bu] 2
  3332. https://github.com/trapexit/scorch
  3333. .IP \[bu] 2
  3334. https://github.com/trapexit/bbf