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.

3315 lines
122 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 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 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 bugs and quirks found in
  849. the kernel and mergerfs this option is provided just in case it is
  850. needed for debugging.
  851. .PP
  852. Given that this flag is set when the FUSE connection is first initiated
  853. it is not possible to change during run time.
  854. .SH FUNCTIONS, CATEGORIES and POLICIES
  855. .PP
  856. The POSIX filesystem API is made up of a number of functions.
  857. \f[B]creat\f[R], \f[B]stat\f[R], \f[B]chown\f[R], etc.
  858. For ease of configuration in mergerfs most of the core functions are
  859. grouped into 3 categories: \f[B]action\f[R], \f[B]create\f[R], and
  860. \f[B]search\f[R].
  861. These functions and categories can be assigned a policy which dictates
  862. which branch is chosen when performing that function.
  863. .PP
  864. Some functions, listed in the category \f[C]N/A\f[R] below, can not be
  865. assigned the normal policies.
  866. These functions work with file handles, rather than file paths, which
  867. were created by \f[C]open\f[R] or \f[C]create\f[R].
  868. That said many times the current FUSE kernel driver will not always
  869. provide the file handle when a client calls \f[C]fgetattr\f[R],
  870. \f[C]fchown\f[R], \f[C]fchmod\f[R], \f[C]futimens\f[R],
  871. \f[C]ftruncate\f[R], etc.
  872. This means it will call the regular, path based, versions.
  873. \f[C]statfs\f[R]\[cq]s behavior can be modified via other options.
  874. .PP
  875. When using policies which are based on a branch\[cq]s available space
  876. the base path provided is used.
  877. Not the full path to the file in question.
  878. Meaning that mounts in the branch won\[cq]t be considered in the space
  879. calculations.
  880. The reason is that it doesn\[cq]t really work for non-path preserving
  881. policies and can lead to non-obvious behaviors.
  882. .PP
  883. NOTE: While any policy can be assigned to a function or category, some
  884. may not be very useful in practice.
  885. For instance: \f[B]rand\f[R] (random) may be useful for file creation
  886. (create) but could lead to very odd behavior if used for \f[C]chmod\f[R]
  887. if there were more than one copy of the file.
  888. .SS Functions and their Category classifications
  889. .PP
  890. .TS
  891. tab(@);
  892. lw(7.4n) lw(62.6n).
  893. T{
  894. Category
  895. T}@T{
  896. FUSE Functions
  897. T}
  898. _
  899. T{
  900. action
  901. T}@T{
  902. chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate,
  903. unlink, utimens
  904. T}
  905. T{
  906. create
  907. T}@T{
  908. create, mkdir, mknod, symlink
  909. T}
  910. T{
  911. search
  912. T}@T{
  913. access, getattr, getxattr, ioctl (directories), listxattr, open,
  914. readlink
  915. T}
  916. T{
  917. N/A
  918. T}@T{
  919. fchmod, fchown, futimens, ftruncate, fallocate, fgetattr, fsync, ioctl
  920. (files), read, readdir, release, statfs, write, copy_file_range
  921. T}
  922. .TE
  923. .PP
  924. In cases where something may be searched for (such as a path to clone)
  925. \f[B]getattr\f[R] will usually be used.
  926. .SS Policies
  927. .PP
  928. A policy is the algorithm used to choose a branch or branches for a
  929. function to work on or generally how the function behaves.
  930. .PP
  931. Any function in the \f[C]create\f[R] category will clone the relative
  932. path if needed.
  933. Some other functions (\f[C]rename\f[R],\f[C]link\f[R],\f[C]ioctl\f[R])
  934. have special requirements or behaviors which you can read more about
  935. below.
  936. .SS Filtering
  937. .PP
  938. Most policies basically search branches and create a list of files /
  939. paths for functions to work on.
  940. The policy is responsible for filtering and sorting the branches.
  941. Filters include \f[B]minfreespace\f[R], whether or not a branch is
  942. mounted read-only, and the branch tagging (RO,NC,RW).
  943. These filters are applied across most policies.
  944. .IP \[bu] 2
  945. No \f[B]search\f[R] function policies filter.
  946. .IP \[bu] 2
  947. All \f[B]action\f[R] function policies filter out branches which are
  948. mounted \f[B]read-only\f[R] or tagged as \f[B]RO (read-only)\f[R].
  949. .IP \[bu] 2
  950. All \f[B]create\f[R] function policies filter out branches which are
  951. mounted \f[B]read-only\f[R], tagged \f[B]RO (read-only)\f[R] or \f[B]NC
  952. (no create)\f[R], or has available space less than
  953. \f[C]minfreespace\f[R].
  954. .PP
  955. Policies may have their own additional filtering such as those that
  956. require existing paths to be present.
  957. .PP
  958. If all branches are filtered an error will be returned.
  959. Typically \f[B]EROFS\f[R] (read-only filesystem) or \f[B]ENOSPC\f[R] (no
  960. space left on device) depending on the most recent reason for filtering
  961. a branch.
  962. \f[B]ENOENT\f[R] will be returned if no eligible branch is found.
  963. .PP
  964. If \f[B]create\f[R], \f[B]mkdir\f[R], \f[B]mknod\f[R], or
  965. \f[B]symlink\f[R] fail with \f[C]EROFS\f[R] or other fundimental errors
  966. then mergerfs will mark any branch found to be read-only as such (IE
  967. will set the mode \f[C]RO\f[R]) and will rerun the policy and try again.
  968. This is mostly for \f[C]ext4\f[R] filesystems that can suddenly become
  969. read-only when it encounters an error.
  970. .SS Path Preservation
  971. .PP
  972. Policies, as described below, are of two basic classifications.
  973. \f[C]path preserving\f[R] and \f[C]non-path preserving\f[R].
  974. .PP
  975. All policies which start with \f[C]ep\f[R] (\f[B]epff\f[R],
  976. \f[B]eplfs\f[R], \f[B]eplus\f[R], \f[B]epmfs\f[R], \f[B]eprand\f[R]) are
  977. \f[C]path preserving\f[R].
  978. \f[C]ep\f[R] stands for \f[C]existing path\f[R].
  979. .PP
  980. A path preserving policy will only consider branches where the relative
  981. path being accessed already exists.
  982. .PP
  983. When using non-path preserving policies paths will be cloned to target
  984. branches as necessary.
  985. .PP
  986. With the \f[C]msp\f[R] or \f[C]most shared path\f[R] policies they are
  987. defined as \f[C]path preserving\f[R] for the purpose of controlling
  988. \f[C]link\f[R] and \f[C]rename\f[R]\[cq]s behaviors since
  989. \f[C]ignorepponrename\f[R] is available to disable that behavior.
  990. .SS Policy descriptions
  991. .PP
  992. A policy\[cq]s behavior differs, as mentioned above, based on the
  993. function it is used with.
  994. Sometimes it really might not make sense to even offer certain policies
  995. because they are literally the same as others but it makes things a bit
  996. more uniform.
  997. .PP
  998. .TS
  999. tab(@);
  1000. lw(16.2n) lw(53.8n).
  1001. T{
  1002. Policy
  1003. T}@T{
  1004. Description
  1005. T}
  1006. _
  1007. T{
  1008. all
  1009. T}@T{
  1010. Search: For \f[B]mkdir\f[R], \f[B]mknod\f[R], and \f[B]symlink\f[R] it
  1011. will apply to all branches.
  1012. \f[B]create\f[R] works like \f[B]ff\f[R].
  1013. T}
  1014. T{
  1015. epall (existing path, all)
  1016. T}@T{
  1017. For \f[B]mkdir\f[R], \f[B]mknod\f[R], and \f[B]symlink\f[R] it will
  1018. apply to all found.
  1019. \f[B]create\f[R] works like \f[B]epff\f[R] (but more expensive because
  1020. it doesn\[cq]t stop after finding a valid branch).
  1021. T}
  1022. T{
  1023. epff (existing path, first found)
  1024. T}@T{
  1025. Given the order of the branches, as defined at mount time or configured
  1026. at runtime, act on the first one found where the relative path exists.
  1027. T}
  1028. T{
  1029. eplfs (existing path, least free space)
  1030. T}@T{
  1031. Of all the branches on which the relative path exists choose the branch
  1032. with the least free space.
  1033. T}
  1034. T{
  1035. eplus (existing path, least used space)
  1036. T}@T{
  1037. Of all the branches on which the relative path exists choose the branch
  1038. with the least used space.
  1039. T}
  1040. T{
  1041. epmfs (existing path, most free space)
  1042. T}@T{
  1043. Of all the branches on which the relative path exists choose the branch
  1044. with the most free space.
  1045. T}
  1046. T{
  1047. eppfrd (existing path, percentage free random distribution)
  1048. T}@T{
  1049. Like \f[B]pfrd\f[R] but limited to existing paths.
  1050. T}
  1051. T{
  1052. eprand (existing path, random)
  1053. T}@T{
  1054. Calls \f[B]epall\f[R] and then randomizes.
  1055. Returns 1.
  1056. T}
  1057. T{
  1058. ff (first found)
  1059. T}@T{
  1060. Given the order of the branches, as defined at mount time or configured
  1061. at runtime, act on the first one found.
  1062. T}
  1063. T{
  1064. lfs (least free space)
  1065. T}@T{
  1066. Pick the branch with the least available free space.
  1067. T}
  1068. T{
  1069. lus (least used space)
  1070. T}@T{
  1071. Pick the branch with the least used space.
  1072. T}
  1073. T{
  1074. mfs (most free space)
  1075. T}@T{
  1076. Pick the branch with the most available free space.
  1077. T}
  1078. T{
  1079. msplfs (most shared path, least free space)
  1080. T}@T{
  1081. Like \f[B]eplfs\f[R] but if it fails to find a branch it will try again
  1082. with the parent directory.
  1083. Continues this pattern till finding one.
  1084. T}
  1085. T{
  1086. msplus (most shared path, least used space)
  1087. T}@T{
  1088. Like \f[B]eplus\f[R] but if it fails to find a branch it will try again
  1089. with the parent directory.
  1090. Continues this pattern till finding one.
  1091. T}
  1092. T{
  1093. mspmfs (most shared path, most free space)
  1094. T}@T{
  1095. Like \f[B]epmfs\f[R] but if it fails to find a branch it will try again
  1096. with the parent directory.
  1097. Continues this pattern till finding one.
  1098. T}
  1099. T{
  1100. msppfrd (most shared path, percentage free random distribution)
  1101. T}@T{
  1102. Like \f[B]eppfrd\f[R] but if it fails to find a branch it will try again
  1103. with the parent directory.
  1104. Continues this pattern till finding one.
  1105. T}
  1106. T{
  1107. newest
  1108. T}@T{
  1109. Pick the file / directory with the largest mtime.
  1110. T}
  1111. T{
  1112. pfrd (percentage free random distribution)
  1113. T}@T{
  1114. Chooses a branch at random with the likelihood of selection based on a
  1115. branch\[cq]s available space relative to the total.
  1116. T}
  1117. T{
  1118. rand (random)
  1119. T}@T{
  1120. Calls \f[B]all\f[R] and then randomizes.
  1121. Returns 1 branch.
  1122. T}
  1123. .TE
  1124. .PP
  1125. \f[B]NOTE:\f[R] If you are using an underlying filesystem that reserves
  1126. blocks such as ext2, ext3, or ext4 be aware that mergerfs respects the
  1127. reservation by using \f[C]f_bavail\f[R] (number of free blocks for
  1128. unprivileged users) rather than \f[C]f_bfree\f[R] (number of free
  1129. blocks) in policy calculations.
  1130. \f[B]df\f[R] does NOT use \f[C]f_bavail\f[R], it uses \f[C]f_bfree\f[R],
  1131. so direct comparisons between \f[B]df\f[R] output and mergerfs\[cq]
  1132. policies is not appropriate.
  1133. .SS Defaults
  1134. .PP
  1135. .TS
  1136. tab(@);
  1137. l l.
  1138. T{
  1139. Category
  1140. T}@T{
  1141. Policy
  1142. T}
  1143. _
  1144. T{
  1145. action
  1146. T}@T{
  1147. epall
  1148. T}
  1149. T{
  1150. create
  1151. T}@T{
  1152. epmfs
  1153. T}
  1154. T{
  1155. search
  1156. T}@T{
  1157. ff
  1158. T}
  1159. .TE
  1160. .SS func.readdir
  1161. .PP
  1162. examples: \f[C]func.readdir=seq\f[R], \f[C]func.readdir=cor:4\f[R]
  1163. .PP
  1164. \f[C]readdir\f[R] has policies to control how it manages reading
  1165. directory content.
  1166. .PP
  1167. .TS
  1168. tab(@);
  1169. lw(26.7n) lw(43.3n).
  1170. T{
  1171. Policy
  1172. T}@T{
  1173. Description
  1174. T}
  1175. _
  1176. T{
  1177. seq
  1178. T}@T{
  1179. \[lq]sequential\[rq] : Iterate over branches in the order defined.
  1180. This is the default and traditional behavior found prior to the readdir
  1181. policy introduction.
  1182. T}
  1183. T{
  1184. cosr
  1185. T}@T{
  1186. \[lq]concurrent open, sequential read\[rq] : Concurrently open branch
  1187. directories using a thread pool and process them in order of definition.
  1188. This keeps memory and CPU usage low while also reducing the time spent
  1189. waiting on branches to respond.
  1190. Number of threads defaults to the number of logical cores.
  1191. Can be overwritten via the syntax \f[C]func.readdir=cosr:N\f[R] where
  1192. \f[C]N\f[R] is the number of threads.
  1193. T}
  1194. T{
  1195. cor
  1196. T}@T{
  1197. \[lq]concurrent open and read\[rq] : Concurrently open branch
  1198. directories and immediately start reading their contents using a thread
  1199. pool.
  1200. This will result in slightly higher memory and CPU usage but reduced
  1201. latency.
  1202. Particularly when using higher latency / slower speed network filesystem
  1203. branches.
  1204. Unlike \f[C]seq\f[R] and \f[C]cosr\f[R] the order of files could change
  1205. due the async nature of the thread pool.
  1206. Number of threads defaults to the number of logical cores.
  1207. Can be overwritten via the syntax \f[C]func.readdir=cor:N\f[R] where
  1208. \f[C]N\f[R] is the number of threads.
  1209. T}
  1210. .TE
  1211. .PP
  1212. Keep in mind that \f[C]readdir\f[R] mostly just provides a list of file
  1213. names in a directory and possibly some basic metadata about said files.
  1214. To know details about the files, as one would see from commands like
  1215. \f[C]find\f[R] or \f[C]ls\f[R], it is required to call \f[C]stat\f[R] on
  1216. the file which is controlled by \f[C]fuse.getattr\f[R].
  1217. .SS ioctl
  1218. .PP
  1219. When \f[C]ioctl\f[R] is used with an open file then it will use the file
  1220. handle which was created at the original \f[C]open\f[R] call.
  1221. However, when using \f[C]ioctl\f[R] with a directory mergerfs will use
  1222. the \f[C]open\f[R] policy to find the directory to act on.
  1223. .SS rename & link
  1224. .PP
  1225. \f[B]NOTE:\f[R] If you\[cq]re receiving errors from software when files
  1226. are moved / renamed / linked then you should consider changing the
  1227. create policy to one which is \f[B]not\f[R] path preserving, enabling
  1228. \f[C]ignorepponrename\f[R], or contacting the author of the offending
  1229. software and requesting that \f[C]EXDEV\f[R] (cross device / improper
  1230. link) be properly handled.
  1231. .PP
  1232. \f[C]rename\f[R] and \f[C]link\f[R] are tricky functions in a union
  1233. filesystem.
  1234. \f[C]rename\f[R] only works within a single filesystem or device.
  1235. If a rename can\[cq]t be done atomically due to the source and
  1236. destination paths existing on different mount points it will return
  1237. \f[B]-1\f[R] with \f[B]errno = EXDEV\f[R] (cross device / improper
  1238. link).
  1239. So if a \f[C]rename\f[R]\[cq]s source and target are on different
  1240. filesystems within the pool it creates an issue.
  1241. .PP
  1242. Originally mergerfs would return EXDEV whenever a rename was requested
  1243. which was cross directory in any way.
  1244. This made the code simple and was technically compliant with POSIX
  1245. requirements.
  1246. However, many applications fail to handle EXDEV at all and treat it as a
  1247. normal error or otherwise handle it poorly.
  1248. Such apps include: gvfsd-fuse v1.20.3 and prior, Finder / CIFS/SMB
  1249. client in Apple OSX 10.9+, NZBGet, Samba\[cq]s recycling bin feature.
  1250. .PP
  1251. As a result a compromise was made in order to get most software to work
  1252. while still obeying mergerfs\[cq] policies.
  1253. Below is the basic logic.
  1254. .IP \[bu] 2
  1255. If using a \f[B]create\f[R] policy which tries to preserve directory
  1256. paths (epff,eplfs,eplus,epmfs)
  1257. .RS 2
  1258. .IP \[bu] 2
  1259. Using the \f[B]rename\f[R] policy get the list of files to rename
  1260. .IP \[bu] 2
  1261. For each file attempt rename:
  1262. .RS 2
  1263. .IP \[bu] 2
  1264. If failure with ENOENT (no such file or directory) run \f[B]create\f[R]
  1265. policy
  1266. .IP \[bu] 2
  1267. If create policy returns the same branch as currently evaluating then
  1268. clone the path
  1269. .IP \[bu] 2
  1270. Re-attempt rename
  1271. .RE
  1272. .IP \[bu] 2
  1273. If \f[B]any\f[R] of the renames succeed the higher level rename is
  1274. considered a success
  1275. .IP \[bu] 2
  1276. If \f[B]no\f[R] renames succeed the first error encountered will be
  1277. returned
  1278. .IP \[bu] 2
  1279. On success:
  1280. .RS 2
  1281. .IP \[bu] 2
  1282. Remove the target from all branches with no source file
  1283. .IP \[bu] 2
  1284. Remove the source from all branches which failed to rename
  1285. .RE
  1286. .RE
  1287. .IP \[bu] 2
  1288. If using a \f[B]create\f[R] policy which does \f[B]not\f[R] try to
  1289. preserve directory paths
  1290. .RS 2
  1291. .IP \[bu] 2
  1292. Using the \f[B]rename\f[R] policy get the list of files to rename
  1293. .IP \[bu] 2
  1294. Using the \f[B]getattr\f[R] policy get the target path
  1295. .IP \[bu] 2
  1296. For each file attempt rename:
  1297. .RS 2
  1298. .IP \[bu] 2
  1299. If the source branch != target branch:
  1300. .RS 2
  1301. .IP \[bu] 2
  1302. Clone target path from target branch to source branch
  1303. .RE
  1304. .IP \[bu] 2
  1305. Rename
  1306. .RE
  1307. .IP \[bu] 2
  1308. If \f[B]any\f[R] of the renames succeed the higher level rename is
  1309. considered a success
  1310. .IP \[bu] 2
  1311. If \f[B]no\f[R] renames succeed the first error encountered will be
  1312. returned
  1313. .IP \[bu] 2
  1314. On success:
  1315. .RS 2
  1316. .IP \[bu] 2
  1317. Remove the target from all branches with no source file
  1318. .IP \[bu] 2
  1319. Remove the source from all branches which failed to rename
  1320. .RE
  1321. .RE
  1322. .PP
  1323. The the removals are subject to normal entitlement checks.
  1324. .PP
  1325. The above behavior will help minimize the likelihood of EXDEV being
  1326. returned but it will still be possible.
  1327. .PP
  1328. \f[B]link\f[R] uses the same strategy but without the removals.
  1329. .SS statfs / statvfs
  1330. .PP
  1331. statvfs (http://linux.die.net/man/2/statvfs) normalizes the source
  1332. filesystems based on the fragment size and sums the number of adjusted
  1333. blocks and inodes.
  1334. This means you will see the combined space of all sources.
  1335. Total, used, and free.
  1336. The sources however are dedupped based on the filesystem so multiple
  1337. sources on the same drive will not result in double counting its space.
  1338. Other filesystems mounted further down the tree of the branch will not
  1339. be included when checking the mount\[cq]s stats.
  1340. .PP
  1341. The options \f[C]statfs\f[R] and \f[C]statfs_ignore\f[R] can be used to
  1342. modify \f[C]statfs\f[R] behavior.
  1343. .SS flush-on-close
  1344. .PP
  1345. https://lkml.kernel.org/linux-fsdevel/20211024132607.1636952-1-amir73il\[at]gmail.com/T/
  1346. .PP
  1347. By default FUSE would issue a flush before the release of a file
  1348. descriptor.
  1349. This was considered a bit aggressive and a feature added to give the
  1350. FUSE server the ability to choose when that happens.
  1351. .PP
  1352. Options: * always * never * opened-for-write
  1353. .PP
  1354. For now it defaults to \[lq]opened-for-write\[rq] which is less
  1355. aggressive than the behavior before this feature was added.
  1356. It should not be a problem because the flush is really only relevant
  1357. when a file is written to.
  1358. Given flush is irrelevant for many filesystems in the future a branch
  1359. specific flag may be added so only files opened on a specific branch
  1360. would be flushed on close.
  1361. .SH ERROR HANDLING
  1362. .PP
  1363. POSIX filesystem functions offer a single return code meaning that there
  1364. is some complication regarding the handling of multiple branches as
  1365. mergerfs does.
  1366. It tries to handle errors in a way that would generally return
  1367. meaningful values for that particular function.
  1368. .SS chmod, chown, removexattr, setxattr, truncate, utimens
  1369. .IP "1)" 3
  1370. if no error: return 0 (success)
  1371. .IP "2)" 3
  1372. if no successes: return first error
  1373. .IP "3)" 3
  1374. if one of the files acted on was the same as the related search
  1375. function: return its value
  1376. .IP "4)" 3
  1377. return 0 (success)
  1378. .PP
  1379. While doing this increases the complexity and cost of error handling,
  1380. particularly step 3, this provides probably the most reasonable return
  1381. value.
  1382. .SS unlink, rmdir
  1383. .IP "1)" 3
  1384. if no errors: return 0 (success)
  1385. .IP "2)" 3
  1386. return first error
  1387. .PP
  1388. Older version of mergerfs would return success if any success occurred
  1389. but for unlink and rmdir there are downstream assumptions that, while
  1390. not impossible to occur, can confuse some software.
  1391. .SS others
  1392. .PP
  1393. For search functions there is always a single thing acted on and as such
  1394. whatever return value that comes from the single function call is
  1395. returned.
  1396. .PP
  1397. For create functions \f[C]mkdir\f[R], \f[C]mknod\f[R], and
  1398. \f[C]symlink\f[R] which don\[cq]t return a file descriptor and therefore
  1399. can have \f[C]all\f[R] or \f[C]epall\f[R] policies it will return
  1400. success if any of the calls succeed and an error otherwise.
  1401. .SH INSTALL
  1402. .PP
  1403. https://github.com/trapexit/mergerfs/releases
  1404. .PP
  1405. If your distribution\[cq]s package manager includes mergerfs check if
  1406. the version is up to date.
  1407. If out of date it is recommended to use the latest release found on the
  1408. release page.
  1409. Details for common distros are below.
  1410. .SS Debian
  1411. .PP
  1412. Most Debian installs are of a stable branch and therefore do not have
  1413. the most up to date software.
  1414. While mergerfs is available via \f[C]apt\f[R] it is suggested that uses
  1415. install the most recent version available from the releases
  1416. page (https://github.com/trapexit/mergerfs/releases).
  1417. .SS prebuilt deb
  1418. .IP
  1419. .nf
  1420. \f[C]
  1421. wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs_<ver>.debian-<rel>_<arch>.deb
  1422. dpkg -i mergerfs_<ver>.debian-<rel>_<arch>.deb
  1423. \f[R]
  1424. .fi
  1425. .SS apt
  1426. .IP
  1427. .nf
  1428. \f[C]
  1429. sudo apt install -y mergerfs
  1430. \f[R]
  1431. .fi
  1432. .SS Ubuntu
  1433. .PP
  1434. Most Ubuntu installs are of a stable branch and therefore do not have
  1435. the most up to date software.
  1436. While mergerfs is available via \f[C]apt\f[R] it is suggested that uses
  1437. install the most recent version available from the releases
  1438. page (https://github.com/trapexit/mergerfs/releases).
  1439. .SS prebuilt deb
  1440. .IP
  1441. .nf
  1442. \f[C]
  1443. wget https://github.com/trapexit/mergerfs/releases/download/<version>/mergerfs_<ver>.ubuntu-<rel>_<arch>.deb
  1444. dpkg -i mergerfs_<ver>.ubuntu-<rel>_<arch>.deb
  1445. \f[R]
  1446. .fi
  1447. .SS apt
  1448. .IP
  1449. .nf
  1450. \f[C]
  1451. sudo apt install -y mergerfs
  1452. \f[R]
  1453. .fi
  1454. .SS Raspberry Pi OS
  1455. .PP
  1456. Effectively the same as Debian or Ubuntu.
  1457. .SS Fedora
  1458. .IP
  1459. .nf
  1460. \f[C]
  1461. wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.fc<rel>.<arch>.rpm
  1462. sudo rpm -i mergerfs-<ver>.fc<rel>.<arch>.rpm
  1463. \f[R]
  1464. .fi
  1465. .SS CentOS / Rocky
  1466. .IP
  1467. .nf
  1468. \f[C]
  1469. wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.el<rel>.<arch>.rpm
  1470. sudo rpm -i mergerfs-<ver>.el<rel>.<arch>.rpm
  1471. \f[R]
  1472. .fi
  1473. .SS ArchLinux
  1474. .IP "1." 3
  1475. Setup AUR
  1476. .IP "2." 3
  1477. Install \f[C]mergerfs\f[R]
  1478. .SS Other
  1479. .PP
  1480. Static binaries are provided for situations where native packages are
  1481. unavailable.
  1482. .IP
  1483. .nf
  1484. \f[C]
  1485. wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-static-linux_<arch>.tar.gz
  1486. sudo tar xvf mergerfs-static-linux_<arch>.tar.gz -C /
  1487. \f[R]
  1488. .fi
  1489. .SH BUILD
  1490. .PP
  1491. \f[B]NOTE:\f[R] Prebuilt packages can be found at and recommended for
  1492. most users: https://github.com/trapexit/mergerfs/releases
  1493. .PP
  1494. \f[B]NOTE:\f[R] Only tagged releases are supported.
  1495. \f[C]master\f[R] and other branches should be considered works in
  1496. progress.
  1497. .PP
  1498. First get the code from github (https://github.com/trapexit/mergerfs).
  1499. .IP
  1500. .nf
  1501. \f[C]
  1502. $ git clone https://github.com/trapexit/mergerfs.git
  1503. $ # or
  1504. $ wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.tar.gz
  1505. \f[R]
  1506. .fi
  1507. .SS Debian / Ubuntu
  1508. .IP
  1509. .nf
  1510. \f[C]
  1511. $ cd mergerfs
  1512. $ sudo tools/install-build-pkgs
  1513. $ make deb
  1514. $ sudo dpkg -i ../mergerfs_<version>_<arch>.deb
  1515. \f[R]
  1516. .fi
  1517. .SS RHEL / CentOS / Rocky / Fedora
  1518. .IP
  1519. .nf
  1520. \f[C]
  1521. $ su -
  1522. # cd mergerfs
  1523. # tools/install-build-pkgs
  1524. # make rpm
  1525. # rpm -i rpmbuild/RPMS/<arch>/mergerfs-<version>.<arch>.rpm
  1526. \f[R]
  1527. .fi
  1528. .SS Generic
  1529. .PP
  1530. Have git, g++, make, python installed.
  1531. .IP
  1532. .nf
  1533. \f[C]
  1534. $ cd mergerfs
  1535. $ make
  1536. $ sudo make install
  1537. \f[R]
  1538. .fi
  1539. .SS Build options
  1540. .IP
  1541. .nf
  1542. \f[C]
  1543. $ make help
  1544. usage: make
  1545. make USE_XATTR=0 - build program without xattrs functionality
  1546. make STATIC=1 - build static binary
  1547. make LTO=1 - build with link time optimization
  1548. \f[R]
  1549. .fi
  1550. .SH UPGRADE
  1551. .PP
  1552. mergerfs can be upgraded live by mounting on top of the previous
  1553. instance.
  1554. Simply install the new version of mergerfs and follow the instructions
  1555. below.
  1556. .PP
  1557. Run mergerfs again or if using \f[C]/etc/fstab\f[R] call for it to mount
  1558. again.
  1559. Existing open files and such will continue to work fine though they
  1560. won\[cq]t see runtime changes since any such change would be the new
  1561. mount.
  1562. If you plan on changing settings with the new mount you should / could
  1563. apply those before mounting the new version.
  1564. .IP
  1565. .nf
  1566. \f[C]
  1567. $ sudo mount /mnt/mergerfs
  1568. $ mount | grep mergerfs
  1569. media on /mnt/mergerfs type mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
  1570. media on /mnt/mergerfs type mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
  1571. \f[R]
  1572. .fi
  1573. .PP
  1574. A problem with this approach is that the underlying instance will
  1575. continue to run even if the software using it stop or are restarted.
  1576. To work around this you can use a \[lq]lazy umount\[rq].
  1577. Before mounting over top the mount point with the new instance of
  1578. mergerfs issue: \f[C]umount -l <mergerfs_mountpoint>\f[R].
  1579. Or you can let mergerfs do it by setting the option
  1580. \f[C]lazy-umount-mountpoint=true\f[R].
  1581. .SH RUNTIME INTERFACES
  1582. .SS RUNTIME CONFIG
  1583. .SS .mergerfs pseudo file
  1584. .IP
  1585. .nf
  1586. \f[C]
  1587. <mountpoint>/.mergerfs
  1588. \f[R]
  1589. .fi
  1590. .PP
  1591. There is a pseudo file available at the mount point which allows for the
  1592. runtime modification of certain \f[B]mergerfs\f[R] options.
  1593. The file will not show up in \f[B]readdir\f[R] but can be
  1594. \f[B]stat\f[R]\[cq]ed and manipulated via
  1595. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls.
  1596. .PP
  1597. Any changes made at runtime are \f[B]not\f[R] persisted.
  1598. If you wish for values to persist they must be included as options
  1599. wherever you configure the mounting of mergerfs (/etc/fstab).
  1600. .SS Keys
  1601. .PP
  1602. Use \f[C]getfattr -d /mountpoint/.mergerfs\f[R] or
  1603. \f[C]xattr -l /mountpoint/.mergerfs\f[R] to see all supported keys.
  1604. Some are informational and therefore read-only.
  1605. \f[C]setxattr\f[R] will return EINVAL (invalid argument) on read-only
  1606. keys.
  1607. .SS Values
  1608. .PP
  1609. Same as the command line.
  1610. .SS user.mergerfs.branches
  1611. .PP
  1612. Used to query or modify the list of branches.
  1613. When modifying there are several shortcuts to easy manipulation of the
  1614. list.
  1615. .PP
  1616. .TS
  1617. tab(@);
  1618. l l.
  1619. T{
  1620. Value
  1621. T}@T{
  1622. Description
  1623. T}
  1624. _
  1625. T{
  1626. [list]
  1627. T}@T{
  1628. set
  1629. T}
  1630. T{
  1631. +<[list]
  1632. T}@T{
  1633. prepend
  1634. T}
  1635. T{
  1636. +>[list]
  1637. T}@T{
  1638. append
  1639. T}
  1640. T{
  1641. -[list]
  1642. T}@T{
  1643. remove all values provided
  1644. T}
  1645. T{
  1646. -<
  1647. T}@T{
  1648. remove first in list
  1649. T}
  1650. T{
  1651. ->
  1652. T}@T{
  1653. remove last in list
  1654. T}
  1655. .TE
  1656. .PP
  1657. \f[C]xattr -w user.mergerfs.branches +</mnt/drive3 /mnt/pool/.mergerfs\f[R]
  1658. .PP
  1659. The \f[C]=NC\f[R], \f[C]=RO\f[R], \f[C]=RW\f[R] syntax works just as on
  1660. the command line.
  1661. .SS Example
  1662. .IP
  1663. .nf
  1664. \f[C]
  1665. [trapexit:/mnt/mergerfs] $ getfattr -d .mergerfs
  1666. user.mergerfs.branches=\[dq]/mnt/a=RW:/mnt/b=RW\[dq]
  1667. user.mergerfs.minfreespace=\[dq]4294967295\[dq]
  1668. user.mergerfs.moveonenospc=\[dq]false\[dq]
  1669. \&...
  1670. [trapexit:/mnt/mergerfs] $ getfattr -n user.mergerfs.category.search .mergerfs
  1671. user.mergerfs.category.search=\[dq]ff\[dq]
  1672. [trapexit:/mnt/mergerfs] $ setfattr -n user.mergerfs.category.search -v newest .mergerfs
  1673. [trapexit:/mnt/mergerfs] $ getfattr -n user.mergerfs.category.search .mergerfs
  1674. user.mergerfs.category.search=\[dq]newest\[dq]
  1675. \f[R]
  1676. .fi
  1677. .SS file / directory xattrs
  1678. .PP
  1679. While they won\[cq]t show up when using \f[C]getfattr\f[R]
  1680. \f[B]mergerfs\f[R] offers a number of special xattrs to query
  1681. information about the files served.
  1682. To access the values you will need to issue a
  1683. getxattr (http://linux.die.net/man/2/getxattr) for one of the following:
  1684. .IP \[bu] 2
  1685. \f[B]user.mergerfs.basepath\f[R]: the base mount point for the file
  1686. given the current getattr policy
  1687. .IP \[bu] 2
  1688. \f[B]user.mergerfs.relpath\f[R]: the relative path of the file from the
  1689. perspective of the mount point
  1690. .IP \[bu] 2
  1691. \f[B]user.mergerfs.fullpath\f[R]: the full path of the original file
  1692. given the getattr policy
  1693. .IP \[bu] 2
  1694. \f[B]user.mergerfs.allpaths\f[R]: a NUL (`\[rs]0') separated list of
  1695. full paths to all files found
  1696. .SS SIGNALS
  1697. .IP \[bu] 2
  1698. USR1: This will cause mergerfs to send invalidation notifications to the
  1699. kernel for all files.
  1700. This will cause all unused files to be released from memory.
  1701. .IP \[bu] 2
  1702. USR2: Trigger a general cleanup of currently unused memory.
  1703. A more thorough version of what happens every \[ti]15 minutes.
  1704. .SS IOCTLS
  1705. .PP
  1706. Found in \f[C]fuse_ioctl.cpp\f[R]:
  1707. .IP
  1708. .nf
  1709. \f[C]
  1710. typedef char IOCTL_BUF[4096];
  1711. #define IOCTL_APP_TYPE 0xDF
  1712. #define IOCTL_FILE_INFO _IOWR(IOCTL_APP_TYPE,0,IOCTL_BUF)
  1713. #define IOCTL_GC _IO(IOCTL_APP_TYPE,1)
  1714. #define IOCTL_GC1 _IO(IOCTL_APP_TYPE,2)
  1715. #define IOCTL_INVALIDATE_ALL_NODES _IO(IOCTL_APP_TYPE,3)
  1716. \f[R]
  1717. .fi
  1718. .IP \[bu] 2
  1719. IOCTL_FILE_INFO: Same as the \[lq]file / directory xattrs\[rq] mentioned
  1720. above.
  1721. Use a buffer size of 4096 bytes.
  1722. Pass in a string of \[lq]basepath\[rq], \[lq]relpath\[rq],
  1723. \[lq]fullpath\[rq], or \[lq]allpaths\[rq].
  1724. Receive details in same buffer.
  1725. .IP \[bu] 2
  1726. IOCTL_GC: Triggers a thorough garbage collection of excess memory.
  1727. Same as SIGUSR2.
  1728. .IP \[bu] 2
  1729. IOCTL_GC1: Triggers a simple garbage collection of excess memory.
  1730. Same as what happens every 15 minutes normally.
  1731. .IP \[bu] 2
  1732. IOCTL_INVALIDATE_ALL_NODES: Same as SIGUSR1.
  1733. Send invalidation notifications to the kernel for all files causing
  1734. unused files to be released from memory.
  1735. .SH TOOLING
  1736. .SS preload.so
  1737. .PP
  1738. EXPERIMENTAL
  1739. .PP
  1740. For some time there has been work to enable passthrough IO in FUSE.
  1741. Passthrough IO would allow for near native performance with regards to
  1742. reads and writes (at the expense of certain mergerfs features.) However,
  1743. there have been several complications which have kept the feature from
  1744. making it into the mainline Linux kernel.
  1745. Until that feature is available there are two methods to provide similar
  1746. functionality.
  1747. One method is using the LD_PRELOAD feature of the dynamic linker.
  1748. The other leveraging ptrace to intercept syscalls.
  1749. Each has their disadvantages.
  1750. At the moment only a preload based tool is available.
  1751. A ptrace based tool may be developed later if there is a need.
  1752. .PP
  1753. \f[C]/usr/lib/mergerfs/preload.so\f[R]
  1754. .PP
  1755. This preloadable
  1756. library (https://man7.org/linux/man-pages/man8/ld.so.8.html#ENVIRONMENT)
  1757. overrides the creation and opening of files in order to simulate
  1758. passthrough file IO.
  1759. It catches the open/creat/fopen calls, has mergerfs do the call, queries
  1760. mergerfs for the branch the file exists on, reopens the file on the
  1761. underlying filesystem and returns that instead.
  1762. Meaning that you will get native read/write performance because mergerfs
  1763. is no longer part of the workflow.
  1764. Keep in mind that this also means certain mergerfs features that work by
  1765. interrupting the read/write workflow, such as \f[C]moveonenospc\f[R],
  1766. will no longer work.
  1767. .PP
  1768. Also understand that this will only work on dynamically linked software.
  1769. Anything statically compiled will not work.
  1770. Many GoLang and Rust apps are statically compiled.
  1771. .PP
  1772. The library will not interfere with non-mergerfs filesystems.
  1773. The library is written to always fallback to returning the mergerfs
  1774. opened file on error.
  1775. .PP
  1776. While the library was written to account for a number of edgecases there
  1777. could be some yet accounted for so please report any oddities.
  1778. .PP
  1779. Thank you to nohajc (https://github.com/nohajc/mergerfs-io-passthrough)
  1780. for prototyping the idea.
  1781. .SS general usage
  1782. .IP
  1783. .nf
  1784. \f[C]
  1785. LD_PRELOAD=/usr/lib/mergerfs/preload.so touch /mnt/mergerfs/filename
  1786. \f[R]
  1787. .fi
  1788. .SS Docker usage
  1789. .PP
  1790. Assume \f[C]/mnt/fs0\f[R] and \f[C]/mnt/fs1\f[R] are pooled with
  1791. mergerfs at \f[C]/media\f[R].
  1792. .PP
  1793. All mergerfs branch paths \f[I]must\f[R] be bind mounted into the
  1794. container at the same path as found on the host so the preload library
  1795. can see them.
  1796. .IP
  1797. .nf
  1798. \f[C]
  1799. docker run \[rs]
  1800. -e LD_PRELOAD=/usr/lib/mergerfs/preload.so \[rs]
  1801. -v /usr/lib/mergerfs/preload.so:/usr/lib/mergerfs/preload.so:ro \[rs]
  1802. -v /media:/data \[rs]
  1803. -v /mnt:/mnt \[rs]
  1804. ubuntu:latest \[rs]
  1805. bash
  1806. \f[R]
  1807. .fi
  1808. .PP
  1809. or more explicitly
  1810. .IP
  1811. .nf
  1812. \f[C]
  1813. docker run \[rs]
  1814. -e LD_PRELOAD=/usr/lib/mergerfs/preload.so \[rs]
  1815. -v /usr/lib/mergerfs/preload.so:/usr/lib/mergerfs/preload.so:ro \[rs]
  1816. -v /media:/data \[rs]
  1817. -v /mnt/fs0:/mnt/fs0 \[rs]
  1818. -v /mnt/fs1:/mnt/fs1 \[rs]
  1819. ubuntu:latest \[rs]
  1820. bash
  1821. \f[R]
  1822. .fi
  1823. .SS systemd unit
  1824. .PP
  1825. Use the \f[C]Environment\f[R] option to set the LD_PRELOAD variable.
  1826. .IP \[bu] 2
  1827. https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Command%20lines
  1828. .IP \[bu] 2
  1829. https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service
  1830. .IP
  1831. .nf
  1832. \f[C]
  1833. [Service]
  1834. Environment=LD_PRELOAD=/usr/lib/mergerfs/preload.so
  1835. \f[R]
  1836. .fi
  1837. .SS Misc
  1838. .IP \[bu] 2
  1839. https://github.com/trapexit/mergerfs-tools
  1840. .RS 2
  1841. .IP \[bu] 2
  1842. mergerfs.ctl: A tool to make it easier to query and configure mergerfs
  1843. at runtime
  1844. .IP \[bu] 2
  1845. mergerfs.fsck: Provides permissions and ownership auditing and the
  1846. ability to fix them
  1847. .IP \[bu] 2
  1848. mergerfs.dedup: Will help identify and optionally remove duplicate files
  1849. .IP \[bu] 2
  1850. mergerfs.dup: Ensure there are at least N copies of a file across the
  1851. pool
  1852. .IP \[bu] 2
  1853. mergerfs.balance: Rebalance files across filesystems by moving them from
  1854. the most filled to the least filled
  1855. .IP \[bu] 2
  1856. mergerfs.consolidate: move files within a single mergerfs directory to
  1857. the filesystem with most free space
  1858. .RE
  1859. .IP \[bu] 2
  1860. https://github.com/trapexit/scorch
  1861. .RS 2
  1862. .IP \[bu] 2
  1863. scorch: A tool to help discover silent corruption of files and keep
  1864. track of files
  1865. .RE
  1866. .IP \[bu] 2
  1867. https://github.com/trapexit/bbf
  1868. .RS 2
  1869. .IP \[bu] 2
  1870. bbf (bad block finder): a tool to scan for and `fix' hard drive bad
  1871. blocks and find the files using those blocks
  1872. .RE
  1873. .SH CACHING
  1874. .SS page caching
  1875. .PP
  1876. https://en.wikipedia.org/wiki/Page_cache
  1877. .IP \[bu] 2
  1878. cache.files=off: Disables page caching.
  1879. Underlying files cached, mergerfs files are not.
  1880. .IP \[bu] 2
  1881. cache.files=partial: Enables page caching.
  1882. Underlying files cached, mergerfs files cached while open.
  1883. .IP \[bu] 2
  1884. cache.files=full: Enables page caching.
  1885. Underlying files cached, mergerfs files cached across opens.
  1886. .IP \[bu] 2
  1887. cache.files=auto-full: Enables page caching.
  1888. Underlying files cached, mergerfs files cached across opens if mtime and
  1889. size are unchanged since previous open.
  1890. .IP \[bu] 2
  1891. cache.files=libfuse: follow traditional libfuse \f[C]direct_io\f[R],
  1892. \f[C]kernel_cache\f[R], and \f[C]auto_cache\f[R] arguments.
  1893. .IP \[bu] 2
  1894. cache.files=per-process: Enable page caching (equivalent to
  1895. \f[C]cache.files=partial\f[R]) only for processes whose `comm' name
  1896. matches one of the values defined in
  1897. \f[C]cache.files.process-names\f[R].
  1898. If the name does not match the file open is equivalent to
  1899. \f[C]cache.files=off\f[R].
  1900. .PP
  1901. FUSE, which mergerfs uses, offers a number of page caching modes.
  1902. mergerfs tries to simplify their use via the \f[C]cache.files\f[R]
  1903. option.
  1904. It can and should replace usage of \f[C]direct_io\f[R],
  1905. \f[C]kernel_cache\f[R], and \f[C]auto_cache\f[R].
  1906. .PP
  1907. Due to mergerfs using FUSE and therefore being a userland process
  1908. proxying existing filesystems the kernel will double cache the content
  1909. being read and written through mergerfs.
  1910. Once from the underlying filesystem and once from mergerfs (it sees them
  1911. as two separate entities).
  1912. Using \f[C]cache.files=off\f[R] will keep the double caching from
  1913. happening by disabling caching of mergerfs but this has the side effect
  1914. that \f[I]all\f[R] read and write calls will be passed to mergerfs which
  1915. may be slower than enabling caching, you lose shared \f[C]mmap\f[R]
  1916. support which can affect apps such as rtorrent, and no read-ahead will
  1917. take place.
  1918. The kernel will still cache the underlying filesystem data but that only
  1919. helps so much given mergerfs will still process all requests.
  1920. .PP
  1921. If you do enable file page caching,
  1922. \f[C]cache.files=partial|full|auto-full\f[R], you should also enable
  1923. \f[C]dropcacheonclose\f[R] which will cause mergerfs to instruct the
  1924. kernel to flush the underlying file\[cq]s page cache when the file is
  1925. closed.
  1926. This behavior is the same as the rsync fadvise / drop cache patch and
  1927. Feh\[cq]s nocache project.
  1928. .PP
  1929. If most files are read once through and closed (like media) it is best
  1930. to enable \f[C]dropcacheonclose\f[R] regardless of caching mode in order
  1931. to minimize buffer bloat.
  1932. .PP
  1933. It is difficult to balance memory usage, cache bloat & duplication, and
  1934. performance.
  1935. Ideally mergerfs would be able to disable caching for the files it
  1936. reads/writes but allow page caching for itself.
  1937. That would limit the FUSE overhead.
  1938. However, there isn\[cq]t a good way to achieve this.
  1939. It would need to open all files with O_DIRECT which places limitations
  1940. on the what underlying filesystems would be supported and complicates
  1941. the code.
  1942. .PP
  1943. kernel documentation:
  1944. https://www.kernel.org/doc/Documentation/filesystems/fuse-io.txt
  1945. .SS entry & attribute caching
  1946. .PP
  1947. Given the relatively high cost of FUSE due to the kernel <-> userspace
  1948. round trips there are kernel side caches for file entries and
  1949. attributes.
  1950. The entry cache limits the \f[C]lookup\f[R] calls to mergerfs which ask
  1951. if a file exists.
  1952. The attribute cache limits the need to make \f[C]getattr\f[R] calls to
  1953. mergerfs which provide file attributes (mode, size, type, etc.).
  1954. As with the page cache these should not be used if the underlying
  1955. filesystems are being manipulated at the same time as it could lead to
  1956. odd behavior or data corruption.
  1957. The options for setting these are \f[C]cache.entry\f[R] and
  1958. \f[C]cache.negative_entry\f[R] for the entry cache and
  1959. \f[C]cache.attr\f[R] for the attributes cache.
  1960. \f[C]cache.negative_entry\f[R] refers to the timeout for negative
  1961. responses to lookups (non-existent files).
  1962. .SS writeback caching
  1963. .PP
  1964. When \f[C]cache.files\f[R] is enabled the default is for it to perform
  1965. writethrough caching.
  1966. This behavior won\[cq]t help improve performance as each write still
  1967. goes one for one through the filesystem.
  1968. By enabling the FUSE writeback cache small writes may be aggregated by
  1969. the kernel and then sent to mergerfs as one larger request.
  1970. This can greatly improve the throughput for apps which write to files
  1971. inefficiently.
  1972. The amount the kernel can aggregate is limited by the size of a FUSE
  1973. message.
  1974. Read the \f[C]fuse_msg_size\f[R] section for more details.
  1975. .PP
  1976. There is a small side effect as a result of enabling writeback caching.
  1977. Underlying files won\[cq]t ever be opened with O_APPEND or O_WRONLY.
  1978. The former because the kernel then manages append mode and the latter
  1979. because the kernel may request file data from mergerfs to populate the
  1980. write cache.
  1981. The O_APPEND change means that if a file is changed outside of mergerfs
  1982. it could lead to corruption as the kernel won\[cq]t know the end of the
  1983. file has changed.
  1984. That said any time you use caching you should keep from using the same
  1985. file outside of mergerfs at the same time.
  1986. .PP
  1987. Note that if an application is properly sizing writes then writeback
  1988. caching will have little or no effect.
  1989. It will only help with writes of sizes below the FUSE message size (128K
  1990. on older kernels, 1M on newer).
  1991. .SS statfs caching
  1992. .PP
  1993. Of the syscalls used by mergerfs in policies the \f[C]statfs\f[R] /
  1994. \f[C]statvfs\f[R] call is perhaps the most expensive.
  1995. It\[cq]s used to find out the available space of a filesystem and
  1996. whether it is mounted read-only.
  1997. Depending on the setup and usage pattern these queries can be relatively
  1998. costly.
  1999. When \f[C]cache.statfs\f[R] is enabled all calls to \f[C]statfs\f[R] by
  2000. a policy will be cached for the number of seconds its set to.
  2001. .PP
  2002. Example: If the create policy is \f[C]mfs\f[R] and the timeout is 60
  2003. then for that 60 seconds the same filesystem will be returned as the
  2004. target for creates because the available space won\[cq]t be updated for
  2005. that time.
  2006. .SS symlink caching
  2007. .PP
  2008. As of version 4.20 Linux supports symlink caching.
  2009. Significant performance increases can be had in workloads which use a
  2010. lot of symlinks.
  2011. Setting \f[C]cache.symlinks=true\f[R] will result in requesting symlink
  2012. caching from the kernel only if supported.
  2013. As a result its safe to enable it on systems prior to 4.20.
  2014. That said it is disabled by default for now.
  2015. You can see if caching is enabled by querying the xattr
  2016. \f[C]user.mergerfs.cache.symlinks\f[R] but given it must be requested at
  2017. startup you can not change it at runtime.
  2018. .SS readdir caching
  2019. .PP
  2020. As of version 4.20 Linux supports readdir caching.
  2021. This can have a significant impact on directory traversal.
  2022. Especially when combined with entry (\f[C]cache.entry\f[R]) and
  2023. attribute (\f[C]cache.attr\f[R]) caching.
  2024. Setting \f[C]cache.readdir=true\f[R] will result in requesting readdir
  2025. caching from the kernel on each \f[C]opendir\f[R].
  2026. If the kernel doesn\[cq]t support readdir caching setting the option to
  2027. \f[C]true\f[R] has no effect.
  2028. This option is configurable at runtime via xattr
  2029. \f[C]user.mergerfs.cache.readdir\f[R].
  2030. .SS tiered caching
  2031. .PP
  2032. Some storage technologies support what some call \[lq]tiered\[rq]
  2033. caching.
  2034. The placing of usually smaller, faster storage as a transparent cache to
  2035. larger, slower storage.
  2036. NVMe, SSD, Optane in front of traditional HDDs for instance.
  2037. .PP
  2038. mergerfs does not natively support any sort of tiered caching.
  2039. Most users have no use for such a feature and its inclusion would
  2040. complicate the code.
  2041. However, there are a few situations where a cache filesystem could help
  2042. with a typical mergerfs setup.
  2043. .IP "1." 3
  2044. Fast network, slow filesystems, many readers: You\[cq]ve a 10+Gbps
  2045. network with many readers and your regular filesystems can\[cq]t keep
  2046. up.
  2047. .IP "2." 3
  2048. Fast network, slow filesystems, small\[cq]ish bursty writes: You have a
  2049. 10+Gbps network and wish to transfer amounts of data less than your
  2050. cache filesystem but wish to do so quickly.
  2051. .PP
  2052. With #1 it\[cq]s arguable if you should be using mergerfs at all.
  2053. RAID would probably be the better solution.
  2054. If you\[cq]re going to use mergerfs there are other tactics that may
  2055. help: spreading the data across filesystems (see the mergerfs.dup tool)
  2056. and setting \f[C]func.open=rand\f[R], using \f[C]symlinkify\f[R], or
  2057. using dm-cache or a similar technology to add tiered cache to the
  2058. underlying device.
  2059. .PP
  2060. With #2 one could use dm-cache as well but there is another solution
  2061. which requires only mergerfs and a cronjob.
  2062. .IP "1." 3
  2063. Create 2 mergerfs pools.
  2064. One which includes just the slow devices and one which has both the fast
  2065. devices (SSD,NVME,etc.) and slow devices.
  2066. .IP "2." 3
  2067. The `cache' pool should have the cache filesystems listed first.
  2068. .IP "3." 3
  2069. The best \f[C]create\f[R] policies to use for the `cache' pool would
  2070. probably be \f[C]ff\f[R], \f[C]epff\f[R], \f[C]lfs\f[R], or
  2071. \f[C]eplfs\f[R].
  2072. The latter two under the assumption that the cache filesystem(s) are far
  2073. smaller than the backing filesystems.
  2074. If using path preserving policies remember that you\[cq]ll need to
  2075. manually create the core directories of those paths you wish to be
  2076. cached.
  2077. Be sure the permissions are in sync.
  2078. Use \f[C]mergerfs.fsck\f[R] to check / correct them.
  2079. You could also set the slow filesystems mode to \f[C]NC\f[R] though
  2080. that\[cq]d mean if the cache filesystems fill you\[cq]d get \[lq]out of
  2081. space\[rq] errors.
  2082. .IP "4." 3
  2083. Enable \f[C]moveonenospc\f[R] and set \f[C]minfreespace\f[R]
  2084. appropriately.
  2085. To make sure there is enough room on the \[lq]slow\[rq] pool you might
  2086. want to set \f[C]minfreespace\f[R] to at least as large as the size of
  2087. the largest cache filesystem if not larger.
  2088. This way in the worst case the whole of the cache filesystem(s) can be
  2089. moved to the other drives.
  2090. .IP "5." 3
  2091. Set your programs to use the cache pool.
  2092. .IP "6." 3
  2093. Save one of the below scripts or create you\[cq]re own.
  2094. .IP "7." 3
  2095. Use \f[C]cron\f[R] (as root) to schedule the command at whatever
  2096. frequency is appropriate for your workflow.
  2097. .SS time based expiring
  2098. .PP
  2099. Move files from cache to backing pool based only on the last time the
  2100. file was accessed.
  2101. Replace \f[C]-atime\f[R] with \f[C]-amin\f[R] if you want minutes rather
  2102. than days.
  2103. May want to use the \f[C]fadvise\f[R] / \f[C]--drop-cache\f[R] version
  2104. of rsync or run rsync with the tool \[lq]nocache\[rq].
  2105. .PP
  2106. \f[I]NOTE:\f[R] The arguments to these scripts include the cache
  2107. \f[B]filesystem\f[R] itself.
  2108. Not the pool with the cache filesystem.
  2109. You could have data loss if the source is the cache pool.
  2110. .PP
  2111. mergerfs.time-based-mover
  2112. .SS percentage full expiring
  2113. .PP
  2114. Move the oldest file from the cache to the backing pool.
  2115. Continue till below percentage threshold.
  2116. .PP
  2117. \f[I]NOTE:\f[R] The arguments to these scripts include the cache
  2118. \f[B]filesystem\f[R] itself.
  2119. Not the pool with the cache filesystem.
  2120. You could have data loss if the source is the cache pool.
  2121. .PP
  2122. mergerfs.percent-full-mover
  2123. .SH PERFORMANCE
  2124. .PP
  2125. mergerfs is at its core just a proxy and therefore its theoretical max
  2126. performance is that of the underlying devices.
  2127. However, given it is a FUSE filesystem working from userspace there is
  2128. an increase in overhead relative to kernel based solutions.
  2129. That said the performance can match the theoretical max but it depends
  2130. greatly on the system\[cq]s configuration.
  2131. Especially when adding network filesystems into the mix there are many
  2132. variables which can impact performance.
  2133. Device speeds and latency, network speeds and latency, general
  2134. concurrency, read/write sizes, etc.
  2135. Unfortunately, given the number of variables it has been difficult to
  2136. find a single set of settings which provide optimal performance.
  2137. If you\[cq]re having performance issues please look over the suggestions
  2138. below (including the benchmarking section.)
  2139. .PP
  2140. NOTE: be sure to read about these features before changing them to
  2141. understand what behaviors it may impact
  2142. .IP \[bu] 2
  2143. disable \f[C]security_capability\f[R] and/or \f[C]xattr\f[R]
  2144. .IP \[bu] 2
  2145. increase cache timeouts \f[C]cache.attr\f[R], \f[C]cache.entry\f[R],
  2146. \f[C]cache.negative_entry\f[R]
  2147. .IP \[bu] 2
  2148. enable (or disable) page caching (\f[C]cache.files\f[R])
  2149. .IP \[bu] 2
  2150. enable \f[C]parallel-direct-writes\f[R]
  2151. .IP \[bu] 2
  2152. enable \f[C]cache.writeback\f[R]
  2153. .IP \[bu] 2
  2154. enable \f[C]cache.statfs\f[R]
  2155. .IP \[bu] 2
  2156. enable \f[C]cache.symlinks\f[R]
  2157. .IP \[bu] 2
  2158. enable \f[C]cache.readdir\f[R]
  2159. .IP \[bu] 2
  2160. change the number of worker threads
  2161. .IP \[bu] 2
  2162. disable \f[C]posix_acl\f[R]
  2163. .IP \[bu] 2
  2164. disable \f[C]async_read\f[R]
  2165. .IP \[bu] 2
  2166. test theoretical performance using \f[C]nullrw\f[R] or mounting a ram
  2167. disk
  2168. .IP \[bu] 2
  2169. use \f[C]symlinkify\f[R] if your data is largely static and read-only
  2170. .IP \[bu] 2
  2171. use tiered cache devices
  2172. .IP \[bu] 2
  2173. use LVM and LVM cache to place a SSD in front of your HDDs
  2174. .IP \[bu] 2
  2175. increase readahead: \f[C]readahead=1024\f[R]
  2176. .PP
  2177. If you come across a setting that significantly impacts performance
  2178. please contact trapexit so he may investigate further.
  2179. Please test both against your normal setup, a singular branch, and with
  2180. \f[C]nullrw=true\f[R]
  2181. .SH BENCHMARKING
  2182. .PP
  2183. Filesystems are complicated.
  2184. They do many things and many of those are interconnected.
  2185. Additionally, the OS, drivers, hardware, etc.
  2186. all can impact performance.
  2187. Therefore, when benchmarking, it is \f[B]necessary\f[R] that the test
  2188. focus as narrowly as possible.
  2189. .PP
  2190. For most throughput is the key benchmark.
  2191. To test throughput \f[C]dd\f[R] is useful but \f[B]must\f[R] be used
  2192. with the correct settings in order to ensure the filesystem or device is
  2193. actually being tested.
  2194. The OS can and will cache data.
  2195. Without forcing synchronous reads and writes and/or disabling caching
  2196. the values returned will not be representative of the device\[cq]s true
  2197. performance.
  2198. .PP
  2199. When benchmarking through mergerfs ensure you only use 1 branch to
  2200. remove any possibility of the policies complicating the situation.
  2201. Benchmark the underlying filesystem first and then mount mergerfs over
  2202. it and test again.
  2203. If you\[cq]re experience speeds below your expectation you will need to
  2204. narrow down precisely which component is leading to the slowdown.
  2205. Preferably test the following in the order listed (but not combined).
  2206. .IP "1." 3
  2207. Enable \f[C]nullrw\f[R] mode with \f[C]nullrw=true\f[R].
  2208. This will effectively make reads and writes no-ops.
  2209. Removing the underlying device / filesystem from the equation.
  2210. This will give us the top theoretical speeds.
  2211. .IP "2." 3
  2212. Mount mergerfs over \f[C]tmpfs\f[R].
  2213. \f[C]tmpfs\f[R] is a RAM disk.
  2214. Extremely high speed and very low latency.
  2215. This is a more realistic best case scenario.
  2216. Example: \f[C]mount -t tmpfs -o size=2G tmpfs /tmp/tmpfs\f[R]
  2217. .IP "3." 3
  2218. Mount mergerfs over a local device.
  2219. NVMe, SSD, HDD, etc.
  2220. If you have more than one I\[cq]d suggest testing each of them as drives
  2221. and/or controllers (their drivers) could impact performance.
  2222. .IP "4." 3
  2223. Finally, if you intend to use mergerfs with a network filesystem, either
  2224. as the source of data or to combine with another through mergerfs, test
  2225. each of those alone as above.
  2226. .PP
  2227. Once you find the component which has the performance issue you can do
  2228. further testing with different options to see if they impact
  2229. performance.
  2230. For reads and writes the most relevant would be: \f[C]cache.files\f[R],
  2231. \f[C]async_read\f[R].
  2232. Less likely but relevant when using NFS or with certain filesystems
  2233. would be \f[C]security_capability\f[R], \f[C]xattr\f[R], and
  2234. \f[C]posix_acl\f[R].
  2235. If you find a specific system, device, filesystem, controller, etc.
  2236. that performs poorly contact trapexit so he may investigate further.
  2237. .PP
  2238. Sometimes the problem is really the application accessing or writing
  2239. data through mergerfs.
  2240. Some software use small buffer sizes which can lead to more requests and
  2241. therefore greater overhead.
  2242. You can test this out yourself by replace \f[C]bs=1M\f[R] in the
  2243. examples below with \f[C]ibs\f[R] or \f[C]obs\f[R] and using a size of
  2244. \f[C]512\f[R] instead of \f[C]1M\f[R].
  2245. In one example test using \f[C]nullrw\f[R] the write speed dropped from
  2246. 4.9GB/s to 69.7MB/s when moving from \f[C]1M\f[R] to \f[C]512\f[R].
  2247. Similar results were had when testing reads.
  2248. Small writes overhead may be improved by leveraging a write cache but in
  2249. casual tests little gain was found.
  2250. More tests will need to be done before this feature would become
  2251. available.
  2252. If you have an app that appears slow with mergerfs it could be due to
  2253. this.
  2254. Contact trapexit so he may investigate further.
  2255. .SS write benchmark
  2256. .IP
  2257. .nf
  2258. \f[C]
  2259. $ dd if=/dev/zero of=/mnt/mergerfs/1GB.file bs=1M count=1024 oflag=nocache conv=fdatasync status=progress
  2260. \f[R]
  2261. .fi
  2262. .SS read benchmark
  2263. .IP
  2264. .nf
  2265. \f[C]
  2266. $ dd if=/mnt/mergerfs/1GB.file of=/dev/null bs=1M count=1024 iflag=nocache conv=fdatasync status=progress
  2267. \f[R]
  2268. .fi
  2269. .SS other benchmarks
  2270. .PP
  2271. If you are attempting to benchmark other behaviors you must ensure you
  2272. clear kernel caches before runs.
  2273. In fact it would be a good deal to run before the read and write
  2274. benchmarks as well just in case.
  2275. .IP
  2276. .nf
  2277. \f[C]
  2278. sync
  2279. echo 3 | sudo tee /proc/sys/vm/drop_caches
  2280. \f[R]
  2281. .fi
  2282. .SH TIPS / NOTES
  2283. .IP \[bu] 2
  2284. This document is literal and thorough.
  2285. If a suspected feature isn\[cq]t mentioned it doesn\[cq]t exist.
  2286. If certain libfuse arguments aren\[cq]t listed they probably
  2287. shouldn\[cq]t be used.
  2288. .IP \[bu] 2
  2289. Ensure you\[cq]re using the latest version.
  2290. .IP \[bu] 2
  2291. Run mergerfs as \f[C]root\f[R].
  2292. mergerfs is designed and intended to be run as \f[C]root\f[R] and may
  2293. exibit incorrect behavior if run otherwise..
  2294. .IP \[bu] 2
  2295. If you don\[cq]t see some directories and files you expect, policies
  2296. seem to skip branches, you get strange permission errors, etc.
  2297. be sure the underlying filesystems\[cq] permissions are all the same.
  2298. Use \f[C]mergerfs.fsck\f[R] to audit the filesystem for out of sync
  2299. permissions.
  2300. .IP \[bu] 2
  2301. If you still have permission issues be sure you are using POSIX ACL
  2302. compliant filesystems.
  2303. mergerfs doesn\[cq]t generally make exceptions for FAT, NTFS, or other
  2304. non-POSIX filesystem.
  2305. .IP \[bu] 2
  2306. Do \f[B]not\f[R] use \f[C]cache.files=off\f[R] if you expect
  2307. applications (such as rtorrent) to use
  2308. mmap (http://linux.die.net/man/2/mmap) files.
  2309. Shared mmap is not currently supported in FUSE w/ page caching disabled.
  2310. Enabling \f[C]dropcacheonclose\f[R] is recommended when
  2311. \f[C]cache.files=partial|full|auto-full\f[R].
  2312. .IP \[bu] 2
  2313. Kodi (http://kodi.tv), Plex (http://plex.tv),
  2314. Subsonic (http://subsonic.org), etc.
  2315. can use directory mtime (http://linux.die.net/man/2/stat) to more
  2316. efficiently determine whether to scan for new content rather than simply
  2317. performing a full scan.
  2318. If using the default \f[B]getattr\f[R] policy of \f[B]ff\f[R] it\[cq]s
  2319. possible those programs will miss an update on account of it returning
  2320. the first directory found\[cq]s \f[B]stat\f[R] info and it\[cq]s a later
  2321. directory on another mount which had the \f[B]mtime\f[R] recently
  2322. updated.
  2323. To fix this you will want to set \f[B]func.getattr=newest\f[R].
  2324. Remember though that this is just \f[B]stat\f[R].
  2325. If the file is later \f[B]open\f[R]\[cq]ed or \f[B]unlink\f[R]\[cq]ed
  2326. and the policy is different for those then a completely different file
  2327. or directory could be acted on.
  2328. .IP \[bu] 2
  2329. Some policies mixed with some functions may result in strange behaviors.
  2330. Not that some of these behaviors and race conditions couldn\[cq]t happen
  2331. outside \f[B]mergerfs\f[R] but that they are far more likely to occur on
  2332. account of the attempt to merge together multiple sources of data which
  2333. could be out of sync due to the different policies.
  2334. .IP \[bu] 2
  2335. For consistency its generally best to set \f[B]category\f[R] wide
  2336. policies rather than individual \f[B]func\f[R]\[cq]s.
  2337. This will help limit the confusion of tools such as
  2338. rsync (http://linux.die.net/man/1/rsync).
  2339. However, the flexibility is there if needed.
  2340. .SH KNOWN ISSUES / BUGS
  2341. .SS kernel issues & bugs
  2342. .PP
  2343. <https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs>
  2344. .SS directory mtime is not being updated
  2345. .PP
  2346. Remember that the default policy for \f[C]getattr\f[R] is \f[C]ff\f[R].
  2347. The information for the first directory found will be returned.
  2348. If it wasn\[cq]t the directory which had been updated then it will
  2349. appear outdated.
  2350. .PP
  2351. The reason this is the default is because any other policy would be more
  2352. expensive and for many applications it is unnecessary.
  2353. To always return the directory with the most recent mtime or a faked
  2354. value based on all found would require a scan of all filesystems.
  2355. .PP
  2356. If you always want the directory information from the one with the most
  2357. recent mtime then use the \f[C]newest\f[R] policy for \f[C]getattr\f[R].
  2358. .SS `mv /mnt/pool/foo /mnt/disk1/foo' removes `foo'
  2359. .PP
  2360. This is not a bug.
  2361. .PP
  2362. Run in verbose mode to better understand what\[cq]s happening:
  2363. .IP
  2364. .nf
  2365. \f[C]
  2366. $ mv -v /mnt/pool/foo /mnt/disk1/foo
  2367. copied \[aq]/mnt/pool/foo\[aq] -> \[aq]/mnt/disk1/foo\[aq]
  2368. removed \[aq]/mnt/pool/foo\[aq]
  2369. $ ls /mnt/pool/foo
  2370. ls: cannot access \[aq]/mnt/pool/foo\[aq]: No such file or directory
  2371. \f[R]
  2372. .fi
  2373. .PP
  2374. \f[C]mv\f[R], when working across devices, is copying the source to
  2375. target and then removing the source.
  2376. Since the source \f[B]is\f[R] the target in this case, depending on the
  2377. unlink policy, it will remove the just copied file and other files
  2378. across the branches.
  2379. .PP
  2380. If you want to move files to one filesystem just copy them there and use
  2381. mergerfs.dedup to clean up the old paths or manually remove them from
  2382. the branches directly.
  2383. .SS cached memory appears greater than it should be
  2384. .PP
  2385. Use \f[C]cache.files=off\f[R] and/or \f[C]dropcacheonclose=true\f[R].
  2386. See the section on page caching.
  2387. .SS NFS clients returning ESTALE / Stale file handle
  2388. .PP
  2389. NFS generally does not like out of band changes.
  2390. Take a look at the section on NFS in the #remote-filesystems for more
  2391. details.
  2392. .SS rtorrent fails with ENODEV (No such device)
  2393. .PP
  2394. Be sure to set \f[C]cache.files=partial|full|auto-full|per-processe\f[R]
  2395. or turn off \f[C]direct_io\f[R].
  2396. rtorrent and some other applications use
  2397. mmap (http://linux.die.net/man/2/mmap) to read and write to files and
  2398. offer no fallback to traditional methods.
  2399. FUSE does not currently support mmap while using \f[C]direct_io\f[R].
  2400. There may be a performance penalty on writes with \f[C]direct_io\f[R]
  2401. off as well as the problem of double caching but it\[cq]s the only way
  2402. to get such applications to work.
  2403. If the performance loss is too high for other apps you can mount
  2404. mergerfs twice.
  2405. Once with \f[C]direct_io\f[R] enabled and one without it.
  2406. Be sure to set \f[C]dropcacheonclose=true\f[R] if not using
  2407. \f[C]direct_io\f[R].
  2408. .SS Plex doesn\[cq]t work with mergerfs
  2409. .PP
  2410. It does.
  2411. If you\[cq]re trying to put Plex\[cq]s config / metadata / database on
  2412. mergerfs you can\[cq]t set \f[C]cache.files=off\f[R] because Plex is
  2413. using sqlite3 with mmap enabled.
  2414. Shared mmap is not supported by Linux\[cq]s FUSE implementation when
  2415. page caching is disabled.
  2416. To fix this place the data elsewhere (preferable) or enable
  2417. \f[C]cache.files\f[R] (with \f[C]dropcacheonclose=true\f[R]).
  2418. Sqlite3 does not need mmap but the developer needs to fall back to
  2419. standard IO if mmap fails.
  2420. .PP
  2421. This applies to other software: Radarr, Sonarr, Lidarr, Jellyfin, etc.
  2422. .PP
  2423. I would recommend reaching out to the developers of the software
  2424. you\[cq]re having troubles with and asking them to add a fallback to
  2425. regular file IO when mmap is unavailable.
  2426. .PP
  2427. If the issue is that scanning doesn\[cq]t seem to pick up media then be
  2428. sure to set \f[C]func.getattr=newest\f[R] though generally a full scan
  2429. will pick up all media anyway.
  2430. .SS When a program tries to move or rename a file it fails
  2431. .PP
  2432. Please read the section above regarding rename & link.
  2433. .PP
  2434. The problem is that many applications do not properly handle
  2435. \f[C]EXDEV\f[R] errors which \f[C]rename\f[R] and \f[C]link\f[R] may
  2436. return even though they are perfectly valid situations which do not
  2437. indicate actual device, filesystem, or OS errors.
  2438. The error will only be returned by mergerfs if using a path preserving
  2439. policy as described in the policy section above.
  2440. If you do not care about path preservation simply change the mergerfs
  2441. policy to the non-path preserving version.
  2442. For example: \f[C]-o category.create=mfs\f[R] Ideally the offending
  2443. software would be fixed and it is recommended that if you run into this
  2444. problem you contact the software\[cq]s author and request proper
  2445. handling of \f[C]EXDEV\f[R] errors.
  2446. .SS my 32bit software has problems
  2447. .PP
  2448. Some software have problems with 64bit inode values.
  2449. The symptoms can include EOVERFLOW errors when trying to list files.
  2450. You can address this by setting \f[C]inodecalc\f[R] to one of the 32bit
  2451. based algos as described in the relevant section.
  2452. .SS Samba: Moving files / directories fails
  2453. .PP
  2454. Workaround: Copy the file/directory and then remove the original rather
  2455. than move.
  2456. .PP
  2457. This isn\[cq]t an issue with Samba but some SMB clients.
  2458. GVFS-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed
  2459. to handle certain error codes correctly.
  2460. Particularly \f[B]STATUS_NOT_SAME_DEVICE\f[R] which comes from the
  2461. \f[B]EXDEV\f[R] which is returned by \f[B]rename\f[R] when the call is
  2462. crossing mount points.
  2463. When a program gets an \f[B]EXDEV\f[R] it needs to explicitly take an
  2464. alternate action to accomplish its goal.
  2465. In the case of \f[B]mv\f[R] or similar it tries \f[B]rename\f[R] and on
  2466. \f[B]EXDEV\f[R] falls back to a manual copying of data between the two
  2467. locations and unlinking the source.
  2468. In these older versions of GVFS-fuse if it received \f[B]EXDEV\f[R] it
  2469. would translate that into \f[B]EIO\f[R].
  2470. This would cause \f[B]mv\f[R] or most any application attempting to move
  2471. files around on that SMB share to fail with a IO error.
  2472. .PP
  2473. GVFS-fuse v1.22.0 (https://bugzilla.gnome.org/show_bug.cgi?id=734568)
  2474. and above fixed this issue but a large number of systems use the older
  2475. release.
  2476. On Ubuntu the version can be checked by issuing
  2477. \f[C]apt-cache showpkg gvfs-fuse\f[R].
  2478. Most distros released in 2015 seem to have the updated release and will
  2479. work fine but older systems may not.
  2480. Upgrading gvfs-fuse or the distro in general will address the problem.
  2481. .PP
  2482. In Apple\[cq]s MacOSX 10.9 they replaced Samba (client and server) with
  2483. their own product.
  2484. It appears their new client does not handle \f[B]EXDEV\f[R] either and
  2485. responds similar to older release of gvfs on Linux.
  2486. .SS Trashing files occasionally fails
  2487. .PP
  2488. This is the same issue as with Samba.
  2489. \f[C]rename\f[R] returns \f[C]EXDEV\f[R] (in our case that will really
  2490. only happen with path preserving policies like \f[C]epmfs\f[R]) and the
  2491. software doesn\[cq]t handle the situation well.
  2492. This is unfortunately a common failure of software which moves files
  2493. around.
  2494. The standard indicates that an implementation \f[C]MAY\f[R] choose to
  2495. support non-user home directory trashing of files (which is a
  2496. \f[C]MUST\f[R]).
  2497. The implementation \f[C]MAY\f[R] also support \[lq]top directory
  2498. trashes\[rq] which many probably do.
  2499. .PP
  2500. To create a \f[C]$topdir/.Trash\f[R] directory as defined in the
  2501. standard use the
  2502. mergerfs-tools (https://github.com/trapexit/mergerfs-tools) tool
  2503. \f[C]mergerfs.mktrash\f[R].
  2504. .SS Supplemental user groups
  2505. .PP
  2506. Due to the overhead of
  2507. getgroups/setgroups (http://linux.die.net/man/2/setgroups) mergerfs
  2508. utilizes a cache.
  2509. This cache is opportunistic and per thread.
  2510. Each thread will query the supplemental groups for a user when that
  2511. particular thread needs to change credentials and will keep that data
  2512. for the lifetime of the thread.
  2513. This means that if a user is added to a group it may not be picked up
  2514. without the restart of mergerfs.
  2515. However, since the high level FUSE API\[cq]s (at least the standard
  2516. version) thread pool dynamically grows and shrinks it\[cq]s possible
  2517. that over time a thread will be killed and later a new thread with no
  2518. cache will start and query the new data.
  2519. .PP
  2520. The gid cache uses fixed storage to simplify the design and be
  2521. compatible with older systems which may not have C++11 compilers.
  2522. There is enough storage for 256 users\[cq] supplemental groups.
  2523. Each user is allowed up to 32 supplemental groups.
  2524. Linux >= 2.6.3 allows up to 65535 groups per user but most other *nixs
  2525. allow far less.
  2526. NFS allowing only 16.
  2527. The system does handle overflow gracefully.
  2528. If the user has more than 32 supplemental groups only the first 32 will
  2529. be used.
  2530. If more than 256 users are using the system when an uncached user is
  2531. found it will evict an existing user\[cq]s cache at random.
  2532. So long as there aren\[cq]t more than 256 active users this should be
  2533. fine.
  2534. If either value is too low for your needs you will have to modify
  2535. \f[C]gidcache.hpp\f[R] to increase the values.
  2536. Note that doing so will increase the memory needed by each thread.
  2537. .PP
  2538. While not a bug some users have found when using containers that
  2539. supplemental groups defined inside the container don\[cq]t work properly
  2540. with regard to permissions.
  2541. This is expected as mergerfs lives outside the container and therefore
  2542. is querying the host\[cq]s group database.
  2543. There might be a hack to work around this (make mergerfs read the
  2544. /etc/group file in the container) but it is not yet implemented and
  2545. would be limited to Linux and the /etc/group DB.
  2546. Preferably users would mount in the host group file into the containers
  2547. or use a standard shared user & groups technology like NIS or LDAP.
  2548. .SH Remote Filesystems
  2549. .PP
  2550. Many users ask about compatibility with remote filesystems.
  2551. This section is to describe any known issues or quirks when using
  2552. mergerfs with common remote filesystems.
  2553. .PP
  2554. Keep in mind that, like with caching, it is not a good idea to change
  2555. the contents of the remote filesystem
  2556. out-of-band (https://en.wikipedia.org/wiki/Out-of-band).
  2557. Meaning that you really shouldn\[cq]t change the contents of the
  2558. underlying filesystems or mergerfs on the server hosting the remote
  2559. filesystem.
  2560. Doing so can lead to weird behavior, inconsistency, errors, and even
  2561. data corruption should multiple programs try to write or read the same
  2562. data at the same time.
  2563. This isn\[cq]t to say you can\[cq]t do it or that data corruption is
  2564. likely but it \f[I]could\f[R] happen.
  2565. It is better to always use the remote filesystem.
  2566. Even on the machine serving it.
  2567. .SS NFS
  2568. .PP
  2569. NFS (https://en.wikipedia.org/wiki/Network_File_System) is a common
  2570. remote filesystem on Unix/POSIX systems.
  2571. Due to how NFS works there are some settings which need to be set in
  2572. order for mergerfs to work with it.
  2573. .PP
  2574. It should be noted that NFS and FUSE (the technology mergerfs uses) do
  2575. not work perfectly with one another due to certain design choices in
  2576. FUSE (and mergerfs.) Due to these issues it is generally recommended to
  2577. use SMB when possible till situations change.
  2578. That said mergerfs should generally work as an export of NFS and issues
  2579. discovered should still be reported.
  2580. .PP
  2581. To ensure compatibility between mergerfs and NFS use the following
  2582. settings.
  2583. .PP
  2584. mergerfs settings: * noforget * inodecalc=path-hash
  2585. .PP
  2586. NFS export settings: * fsid=UUID * no_root_squash
  2587. .PP
  2588. \f[C]noforget\f[R] is needed because NFS uses the
  2589. \f[C]name_to_handle_at\f[R] and \f[C]open_by_handle_at\f[R] functions
  2590. which allow a program to keep a reference to a file without technically
  2591. having it open in the typical sense.
  2592. The problem is that FUSE has no way to know that NFS has a handle that
  2593. it will later use to open the file again.
  2594. As a result it is possible for the kernel to tell mergerfs to forget
  2595. about the node and should NFS ever ask for that node\[cq]s details in
  2596. the future it would have nothing to respond with.
  2597. Keeping nodes around forever is not ideal but at the moment the only way
  2598. to manage the situation.
  2599. .PP
  2600. \f[C]inodecalc=path-hash\f[R] is needed because NFS is sensitive to
  2601. out-of-band changes.
  2602. FUSE doesn\[cq]t care if a file\[cq]s inode value changes but NFS, being
  2603. stateful, does.
  2604. So if you used the default inode calculation algorithm then it is
  2605. possible that if you changed a file or updated a directory the file
  2606. mergerfs will use will be on a different branch and therefore the inode
  2607. would change.
  2608. This isn\[cq]t an ideal solution and others are being considered but it
  2609. works for most situations.
  2610. .PP
  2611. \f[C]fsid=UUID\f[R] is needed because FUSE filesystems don\[cq]t have
  2612. different \f[C]st_dev\f[R] values which can cause issues when exporting.
  2613. The easiest thing to do is set each mergerfs export \f[C]fsid\f[R] to
  2614. some random value.
  2615. An easy way to generate a random value is to use the command line tool
  2616. \f[C]uuid\f[R] or \f[C]uuidgen\f[R] or through a website such as
  2617. uuidgenerator.net (https://www.uuidgenerator.net/).
  2618. .PP
  2619. \f[C]no_root_squash\f[R] is not strictly necessary but can lead to
  2620. confusing permission and ownership issues if root squashing is enabled.
  2621. .SS SMB / CIFS
  2622. .PP
  2623. SMB (https://en.wikipedia.org/wiki/Server_Message_Block) is a protocol
  2624. most used by Microsoft Windows systems to share file shares, printers,
  2625. etc.
  2626. However, due to the popularity for Windows, it is also supported on many
  2627. other platforms including Linux.
  2628. The most popular way of supporting SMB on Linux is via the software
  2629. Samba.
  2630. .PP
  2631. Samba (https://en.wikipedia.org/wiki/Samba_(software)), and other ways
  2632. of serving Linux filesystems, via SMB should work fine with mergerfs.
  2633. The services do not tend to use the same technologies which NFS uses and
  2634. therefore don\[cq]t have the same issues.
  2635. There should not be an special settings required to use mergerfs with
  2636. Samba.
  2637. However, CIFSD (https://en.wikipedia.org/wiki/CIFSD) and other programs
  2638. have not been extensively tested.
  2639. If you use mergerfs with CIFSD or other SMB servers please submit your
  2640. experiences so these docs can be updated.
  2641. .SS SSHFS
  2642. .PP
  2643. SSHFS (https://en.wikipedia.org/wiki/SSHFS) is a FUSE filesystem
  2644. leveraging SSH as the connection and transport layer.
  2645. While often simpler to setup when compared to NFS or Samba the
  2646. performance can be lacking and the project is very much in maintenance
  2647. mode.
  2648. .PP
  2649. There are no known issues using sshfs with mergerfs.
  2650. You may want to use the following arguments to improve performance but
  2651. your millage may vary.
  2652. .IP \[bu] 2
  2653. \f[C]-o Ciphers=arcfour\f[R]
  2654. .IP \[bu] 2
  2655. \f[C]-o Compression=no\f[R]
  2656. .PP
  2657. More info can be found
  2658. here (https://ideatrash.net/2016/08/odds-and-ends-optimizing-sshfs-moving.html).
  2659. .SS Other
  2660. .PP
  2661. There are other remote filesystems but none popularly used to serve
  2662. mergerfs.
  2663. If you use something not listed above feel free to reach out and I will
  2664. add it to the list.
  2665. .SH FAQ
  2666. .SS How well does mergerfs scale? Is it \[lq]production ready?\[rq]
  2667. .PP
  2668. Users have reported running mergerfs on everything from a Raspberry Pi
  2669. to dual socket Xeon systems with >20 cores.
  2670. I\[cq]m aware of at least a few companies which use mergerfs in
  2671. production.
  2672. Open Media Vault (https://www.openmediavault.org) includes mergerfs as
  2673. its sole solution for pooling filesystems.
  2674. The author of mergerfs had it running for over 300 days managing 16+
  2675. devices with reasonably heavy 24/7 read and write usage.
  2676. Stopping only after the machine\[cq]s power supply died.
  2677. .PP
  2678. Most serious issues (crashes or data corruption) have been due to kernel
  2679. bugs (https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs).
  2680. All of which are fixed in stable releases.
  2681. .SS Can mergerfs be used with filesystems which already have data / are in use?
  2682. .PP
  2683. Yes.
  2684. mergerfs is really just a proxy and does \f[B]NOT\f[R] interfere with
  2685. the normal form or function of the filesystems / mounts / paths it
  2686. manages.
  2687. It is just another userland application that is acting as a
  2688. man-in-the-middle.
  2689. It can\[cq]t do anything that any other random piece of software
  2690. can\[cq]t do.
  2691. .PP
  2692. mergerfs is \f[B]not\f[R] a traditional filesystem that takes control
  2693. over the underlying block device.
  2694. mergerfs is \f[B]not\f[R] RAID.
  2695. It does \f[B]not\f[R] manipulate the data that passes through it.
  2696. It does \f[B]not\f[R] shard data across filesystems.
  2697. It merely shards some \f[B]behavior\f[R] and aggregates others.
  2698. .SS Can drives/filesystems be removed from the pool at will?
  2699. .PP
  2700. Yes.
  2701. See previous question\[cq]s answer.
  2702. .SS Can mergerfs be removed without affecting the data?
  2703. .PP
  2704. Yes.
  2705. See the previous question\[cq]s answer.
  2706. .SS Can drives/filesystems be moved to another pool?
  2707. .PP
  2708. Yes.
  2709. See the previous question\[cq]s answer.
  2710. .SS How do I migrate data into or out of the pool when adding/removing drives/filesystems?
  2711. .PP
  2712. You don\[cq]t need to.
  2713. See the previous question\[cq]s answer.
  2714. .SS How do I remove a drive/filesystem but keep the data in the pool?
  2715. .PP
  2716. Nothing special needs to be done.
  2717. Remove the branch from mergerfs\[cq] config and copy (rsync) the data
  2718. from the removed filesystem into the pool.
  2719. Effectively the same as if it were you transfering data from one
  2720. filesystem to another.
  2721. .PP
  2722. If you wish to continue using the pool while performing the transfer
  2723. simply create another, temporary pool without the filesystem in question
  2724. and then copy the data.
  2725. It would probably be a good idea to set the branch to \f[C]RO\f[R] prior
  2726. to doing this to ensure no new content is written to the filesystem
  2727. while performing the copy.
  2728. .SS What policies should I use?
  2729. .PP
  2730. Unless you\[cq]re doing something more niche the average user is
  2731. probably best off using \f[C]mfs\f[R] for \f[C]category.create\f[R].
  2732. It will spread files out across your branches based on available space.
  2733. Use \f[C]mspmfs\f[R] if you want to try to colocate the data a bit more.
  2734. You may want to use \f[C]lus\f[R] if you prefer a slightly different
  2735. distribution of data if you have a mix of smaller and larger
  2736. filesystems.
  2737. Generally though \f[C]mfs\f[R], \f[C]lus\f[R], or even \f[C]rand\f[R]
  2738. are good for the general use case.
  2739. If you are starting with an imbalanced pool you can use the tool
  2740. \f[B]mergerfs.balance\f[R] to redistribute files across the pool.
  2741. .PP
  2742. If you really wish to try to colocate files based on directory you can
  2743. set \f[C]func.create\f[R] to \f[C]epmfs\f[R] or similar and
  2744. \f[C]func.mkdir\f[R] to \f[C]rand\f[R] or \f[C]eprand\f[R] depending on
  2745. if you just want to colocate generally or on specific branches.
  2746. Either way the \f[I]need\f[R] to colocate is rare.
  2747. For instance: if you wish to remove the device regularly and want the
  2748. data to predictably be on that device or if you don\[cq]t use backup at
  2749. all and don\[cq]t wish to replace that data piecemeal.
  2750. In which case using path preservation can help but will require some
  2751. manual attention.
  2752. Colocating after the fact can be accomplished using the
  2753. \f[B]mergerfs.consolidate\f[R] tool.
  2754. If you don\[cq]t need strict colocation which the \f[C]ep\f[R] policies
  2755. provide then you can use the \f[C]msp\f[R] based policies which will
  2756. walk back the path till finding a branch that works.
  2757. .PP
  2758. Ultimately there is no correct answer.
  2759. It is a preference or based on some particular need.
  2760. mergerfs is very easy to test and experiment with.
  2761. I suggest creating a test setup and experimenting to get a sense of what
  2762. you want.
  2763. .PP
  2764. \f[C]epmfs\f[R] is the default \f[C]category.create\f[R] policy because
  2765. \f[C]ep\f[R] policies are not going to change the general layout of the
  2766. branches.
  2767. It won\[cq]t place files/dirs on branches that don\[cq]t already have
  2768. the relative branch.
  2769. So it keeps the system in a known state.
  2770. It\[cq]s much easier to stop using \f[C]epmfs\f[R] or redistribute files
  2771. around the filesystem than it is to consolidate them back.
  2772. .SS What settings should I use?
  2773. .PP
  2774. Depends on what features you want.
  2775. Generally speaking there are no \[lq]wrong\[rq] settings.
  2776. All settings are performance or feature related.
  2777. The best bet is to read over the available options and choose what fits
  2778. your situation.
  2779. If something isn\[cq]t clear from the documentation please reach out and
  2780. the documentation will be improved.
  2781. .PP
  2782. That said, for the average person, the following should be fine:
  2783. .PP
  2784. \f[C]cache.files=off,dropcacheonclose=true,category.create=mfs\f[R]
  2785. .SS Why are all my files ending up on 1 filesystem?!
  2786. .PP
  2787. Did you start with empty filesystems?
  2788. Did you explicitly configure a \f[C]category.create\f[R] policy?
  2789. Are you using an \f[C]existing path\f[R] / \f[C]path preserving\f[R]
  2790. policy?
  2791. .PP
  2792. The default create policy is \f[C]epmfs\f[R].
  2793. That is a path preserving algorithm.
  2794. With such a policy for \f[C]mkdir\f[R] and \f[C]create\f[R] with a set
  2795. of empty filesystems it will select only 1 filesystem when the first
  2796. directory is created.
  2797. Anything, files or directories, created in that first directory will be
  2798. placed on the same branch because it is preserving paths.
  2799. .PP
  2800. This catches a lot of new users off guard but changing the default would
  2801. break the setup for many existing users and this policy is the safest
  2802. policy as it will not change the general layout of the existing
  2803. filesystems.
  2804. If you do not care about path preservation and wish your files to be
  2805. spread across all your filesystems change to \f[C]mfs\f[R] or similar
  2806. policy as described above.
  2807. If you do want path preservation you\[cq]ll need to perform the manual
  2808. act of creating paths on the filesystems you want the data to land on
  2809. before transferring your data.
  2810. Setting \f[C]func.mkdir=epall\f[R] can simplify managing path
  2811. preservation for \f[C]create\f[R].
  2812. Or use \f[C]func.mkdir=rand\f[R] if you\[cq]re interested in just
  2813. grouping together directory content by filesystem.
  2814. .SS Do hardlinks work?
  2815. .PP
  2816. Yes.
  2817. See also the option \f[C]inodecalc\f[R] for how inode values are
  2818. calculated.
  2819. .PP
  2820. What mergerfs does not do is fake hard links across branches.
  2821. Read the section \[lq]rename & link\[rq] for how it works.
  2822. .PP
  2823. Remember that hardlinks will NOT work across devices.
  2824. That includes between the original filesystem and a mergerfs pool,
  2825. between two separate pools of the same underlying filesystems, or bind
  2826. mounts of paths within the mergerfs pool.
  2827. The latter is common when using Docker or Podman.
  2828. Multiple volumes (bind mounts) to the same underlying filesystem are
  2829. considered different devices.
  2830. There is no way to link between them.
  2831. You should mount in the highest directory in the mergerfs pool that
  2832. includes all the paths you need if you want links to work.
  2833. .SS Does FICLONE or FICLONERANGE work?
  2834. .PP
  2835. Unfortunately not.
  2836. FUSE, the technology mergerfs is based on, does not support the
  2837. \f[C]clone_file_range\f[R] feature needed for it to work.
  2838. mergerfs won\[cq]t even know such a request is made.
  2839. The kernel will simply return an error back to the application making
  2840. the request.
  2841. .PP
  2842. Should FUSE gain the ability mergerfs will be updated to support it.
  2843. .SS Can I use mergerfs without SnapRAID? SnapRAID without mergerfs?
  2844. .PP
  2845. Yes.
  2846. They are completely unrelated pieces of software.
  2847. .SS Can mergerfs run via Docker, Podman, Kubernetes, etc.
  2848. .PP
  2849. Yes.
  2850. With Docker you\[cq]ll need to include
  2851. \f[C]--cap-add=SYS_ADMIN --device=/dev/fuse --security-opt=apparmor:unconfined\f[R]
  2852. or similar with other container runtimes.
  2853. You should also be running it as root or given sufficient caps to change
  2854. user and group identity as well as have root like filesystem
  2855. permissions.
  2856. .PP
  2857. Keep in mind that you \f[B]MUST\f[R] consider identity when using
  2858. containers.
  2859. For example: supplemental groups will be picked up from the container
  2860. unless you properly manage users and groups by sharing relevant /etc
  2861. files or by using some other means to share identity across containers.
  2862. Similarly if you use \[lq]rootless\[rq] containers and user namespaces
  2863. to do uid/gid translations you \f[B]MUST\f[R] consider that while
  2864. managing shared files.
  2865. .PP
  2866. Also, as mentioned by hotio (https://hotio.dev/containers/mergerfs),
  2867. with Docker you should probably be mounting with
  2868. \f[C]bind-propagation\f[R] set to \f[C]slave\f[R].
  2869. .SS Does mergerfs support CoW / copy-on-write / writes to read-only filesystems?
  2870. .PP
  2871. Not in the sense of a filesystem like BTRFS or ZFS nor in the overlayfs
  2872. or aufs sense.
  2873. It does offer a
  2874. cow-shell (http://manpages.ubuntu.com/manpages/bionic/man1/cow-shell.1.html)
  2875. like hard link breaking (copy to temp file then rename over original)
  2876. which can be useful when wanting to save space by hardlinking duplicate
  2877. files but wish to treat each name as if it were a unique and separate
  2878. file.
  2879. .PP
  2880. If you want to write to a read-only filesystem you should look at
  2881. overlayfs.
  2882. You can always include the overlayfs mount into a mergerfs pool.
  2883. .SS Why can\[cq]t I see my files / directories?
  2884. .PP
  2885. It\[cq]s almost always a permissions issue.
  2886. Unlike mhddfs and unionfs-fuse, which runs as root and attempts to
  2887. access content as such, mergerfs always changes its credentials to that
  2888. of the caller.
  2889. This means that if the user does not have access to a file or directory
  2890. than neither will mergerfs.
  2891. However, because mergerfs is creating a union of paths it may be able to
  2892. read some files and directories on one filesystem but not another
  2893. resulting in an incomplete set.
  2894. .PP
  2895. Whenever you run into a split permission issue (seeing some but not all
  2896. files) try using
  2897. mergerfs.fsck (https://github.com/trapexit/mergerfs-tools) tool to check
  2898. for and fix the mismatch.
  2899. If you aren\[cq]t seeing anything at all be sure that the basic
  2900. permissions are correct.
  2901. The user and group values are correct and that directories have their
  2902. executable bit set.
  2903. A common mistake by users new to Linux is to \f[C]chmod -R 644\f[R] when
  2904. they should have \f[C]chmod -R u=rwX,go=rX\f[R].
  2905. .PP
  2906. If using a network filesystem such as NFS or SMB (Samba) be sure to pay
  2907. close attention to anything regarding permissioning and users.
  2908. Root squashing and user translation for instance has bitten a few
  2909. mergerfs users.
  2910. Some of these also affect the use of mergerfs from container platforms
  2911. such as Docker.
  2912. .SS Why use FUSE? Why not a kernel based solution?
  2913. .PP
  2914. As with any solutions to a problem there are advantages and
  2915. disadvantages to each one.
  2916. .PP
  2917. A FUSE based solution has all the downsides of FUSE:
  2918. .IP \[bu] 2
  2919. Higher IO latency due to the trips in and out of kernel space
  2920. .IP \[bu] 2
  2921. Higher general overhead due to trips in and out of kernel space
  2922. .IP \[bu] 2
  2923. Double caching when using page caching
  2924. .IP \[bu] 2
  2925. Misc limitations due to FUSE\[cq]s design
  2926. .PP
  2927. But FUSE also has a lot of upsides:
  2928. .IP \[bu] 2
  2929. Easier to offer a cross platform solution
  2930. .IP \[bu] 2
  2931. Easier forward and backward compatibility
  2932. .IP \[bu] 2
  2933. Easier updates for users
  2934. .IP \[bu] 2
  2935. Easier and faster release cadence
  2936. .IP \[bu] 2
  2937. Allows more flexibility in design and features
  2938. .IP \[bu] 2
  2939. Overall easier to write, secure, and maintain
  2940. .IP \[bu] 2
  2941. Much lower barrier to entry (getting code into the kernel takes a lot of
  2942. time and effort initially)
  2943. .PP
  2944. FUSE was chosen because of all the advantages listed above.
  2945. The negatives of FUSE do not outweigh the positives.
  2946. .SS Is my OS\[cq]s libfuse needed for mergerfs to work?
  2947. .PP
  2948. No.\ Normally \f[C]mount.fuse\f[R] is needed to get mergerfs (or any
  2949. FUSE filesystem to mount using the \f[C]mount\f[R] command but in
  2950. vendoring the libfuse library the \f[C]mount.fuse\f[R] app has been
  2951. renamed to \f[C]mount.mergerfs\f[R] meaning the filesystem type in
  2952. \f[C]fstab\f[R] can simply be \f[C]mergerfs\f[R].
  2953. That said there should be no harm in having it installed and continuing
  2954. to using \f[C]fuse.mergerfs\f[R] as the type in \f[C]/etc/fstab\f[R].
  2955. .PP
  2956. If \f[C]mergerfs\f[R] doesn\[cq]t work as a type it could be due to how
  2957. the \f[C]mount.mergerfs\f[R] tool was installed.
  2958. Must be in \f[C]/sbin/\f[R] with proper permissions.
  2959. .SS Why was splice support removed?
  2960. .PP
  2961. After a lot of testing over the years splicing always appeared to be at
  2962. best provide equivalent performance and in cases worse performance.
  2963. Splice is not supported on other platforms forcing a traditional
  2964. read/write fallback to be provided.
  2965. The splice code was removed to simplify the codebase.
  2966. .SS What should mergerfs NOT be used for?
  2967. .IP \[bu] 2
  2968. databases: Even if the database stored data in separate files (mergerfs
  2969. wouldn\[cq]t offer much otherwise) the higher latency of the indirection
  2970. will kill performance.
  2971. If it is a lightly used SQLITE database then it may be fine but
  2972. you\[cq]ll need to test.
  2973. .IP \[bu] 2
  2974. VM images: For the same reasons as databases.
  2975. VM images are accessed very aggressively and mergerfs will introduce too
  2976. much latency (if it works at all).
  2977. .IP \[bu] 2
  2978. As replacement for RAID: mergerfs is just for pooling branches.
  2979. If you need that kind of device performance aggregation or high
  2980. availability you should stick with RAID.
  2981. .SS Can filesystems be written to directly? Outside of mergerfs while pooled?
  2982. .PP
  2983. Yes, however it\[cq]s not recommended to use the same file from within
  2984. the pool and from without at the same time (particularly writing).
  2985. Especially if using caching of any kind (cache.files, cache.entry,
  2986. cache.attr, cache.negative_entry, cache.symlinks, cache.readdir, etc.)
  2987. as there could be a conflict between cached data and not.
  2988. .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?
  2989. .PP
  2990. First make sure you\[cq]ve read the sections above about policies, path
  2991. preservation, branch filtering, and the options \f[B]minfreespace\f[R],
  2992. \f[B]moveonenospc\f[R], \f[B]statfs\f[R], and \f[B]statfs_ignore\f[R].
  2993. .PP
  2994. mergerfs is simply presenting a union of the content within multiple
  2995. branches.
  2996. The reported free space is an aggregate of space available within the
  2997. pool (behavior modified by \f[B]statfs\f[R] and
  2998. \f[B]statfs_ignore\f[R]).
  2999. It does not represent a contiguous space.
  3000. In the same way that read-only filesystems, those with quotas, or
  3001. reserved space report the full theoretical space available.
  3002. .PP
  3003. Due to path preservation, branch tagging, read-only status, and
  3004. \f[B]minfreespace\f[R] settings it is perfectly valid that
  3005. \f[C]ENOSPC\f[R] / \[lq]out of space\[rq] / \[lq]no space left on
  3006. device\[rq] be returned.
  3007. It is doing what was asked of it: filtering possible branches due to
  3008. those settings.
  3009. Only one error can be returned and if one of the reasons for filtering a
  3010. branch was \f[B]minfreespace\f[R] then it will be returned as such.
  3011. \f[B]moveonenospc\f[R] is only relevant to writing a file which is too
  3012. large for the filesystem it\[cq]s currently on.
  3013. .PP
  3014. It is also possible that the filesystem selected has run out of inodes.
  3015. Use \f[C]df -i\f[R] to list the total and available inodes per
  3016. filesystem.
  3017. .PP
  3018. If you don\[cq]t care about path preservation then simply change the
  3019. \f[C]create\f[R] policy to one which isn\[cq]t.
  3020. \f[C]mfs\f[R] is probably what most are looking for.
  3021. The reason it\[cq]s not default is because it was originally set to
  3022. \f[C]epmfs\f[R] and changing it now would change people\[cq]s setup.
  3023. Such a setting change will likely occur in mergerfs 3.
  3024. .SS Why does the total available space in mergerfs not equal outside?
  3025. .PP
  3026. Are you using ext2/3/4?
  3027. With reserve for root?
  3028. mergerfs uses available space for statfs calculations.
  3029. If you\[cq]ve reserved space for root then it won\[cq]t show up.
  3030. .PP
  3031. You can remove the reserve by running: \f[C]tune2fs -m 0 <device>\f[R]
  3032. .SS I notice massive slowdowns of writes when enabling cache.files.
  3033. .PP
  3034. When file caching is enabled in any form (\f[C]cache.files!=off\f[R]) it
  3035. will issue \f[C]getxattr\f[R] requests for \f[C]security.capability\f[R]
  3036. prior to \f[I]every single write\f[R].
  3037. This will usually result in a performance degradation, especially when
  3038. using a network filesystem (such as NFS or SMB.) Unfortunately at this
  3039. moment the kernel is not caching the response.
  3040. .PP
  3041. To work around this situation mergerfs offers a few solutions.
  3042. .IP "1." 3
  3043. Set \f[C]security_capability=false\f[R].
  3044. It will short circuit any call and return \f[C]ENOATTR\f[R].
  3045. This still means though that mergerfs will receive the request before
  3046. every write but at least it doesn\[cq]t get passed through to the
  3047. underlying filesystem.
  3048. .IP "2." 3
  3049. Set \f[C]xattr=noattr\f[R].
  3050. Same as above but applies to \f[I]all\f[R] calls to getxattr.
  3051. Not just \f[C]security.capability\f[R].
  3052. This will not be cached by the kernel either but mergerfs\[cq] runtime
  3053. config system will still function.
  3054. .IP "3." 3
  3055. Set \f[C]xattr=nosys\f[R].
  3056. Results in mergerfs returning \f[C]ENOSYS\f[R] which \f[I]will\f[R] be
  3057. cached by the kernel.
  3058. No future xattr calls will be forwarded to mergerfs.
  3059. The downside is that also means the xattr based config and query
  3060. functionality won\[cq]t work either.
  3061. .IP "4." 3
  3062. Disable file caching.
  3063. If you aren\[cq]t using applications which use \f[C]mmap\f[R] it\[cq]s
  3064. probably simpler to just disable it all together.
  3065. The kernel won\[cq]t send the requests when caching is disabled.
  3066. .SS It\[cq]s mentioned that there are some security issues with mhddfs. What are they? How does mergerfs address them?
  3067. .PP
  3068. mhddfs (https://github.com/trapexit/mhddfs) manages running as
  3069. \f[B]root\f[R] by calling
  3070. getuid() (https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  3071. and if it returns \f[B]0\f[R] then it will
  3072. chown (http://linux.die.net/man/1/chown) the file.
  3073. Not only is that a race condition but it doesn\[cq]t handle other
  3074. situations.
  3075. Rather than attempting to simulate POSIX ACL behavior the proper way to
  3076. manage this is to use seteuid (http://linux.die.net/man/2/seteuid) and
  3077. setegid (http://linux.die.net/man/2/setegid), in effect becoming the
  3078. user making the original call, and perform the action as them.
  3079. This is what mergerfs does and why mergerfs should always run as root.
  3080. .PP
  3081. In Linux setreuid syscalls apply only to the thread.
  3082. GLIBC hides this away by using realtime signals to inform all threads to
  3083. change credentials.
  3084. Taking after \f[B]Samba\f[R], mergerfs uses
  3085. \f[B]syscall(SYS_setreuid,\&...)\f[R] to set the callers credentials for
  3086. that thread only.
  3087. Jumping back to \f[B]root\f[R] as necessary should escalated privileges
  3088. be needed (for instance: to clone paths between filesystems).
  3089. .PP
  3090. For non-Linux systems mergerfs uses a read-write lock and changes
  3091. credentials only when necessary.
  3092. If multiple threads are to be user X then only the first one will need
  3093. to change the processes credentials.
  3094. So long as the other threads need to be user X they will take a readlock
  3095. allowing multiple threads to share the credentials.
  3096. Once a request comes in to run as user Y that thread will attempt a
  3097. write lock and change to Y\[cq]s credentials when it can.
  3098. If the ability to give writers priority is supported then that flag will
  3099. be used so threads trying to change credentials don\[cq]t starve.
  3100. This isn\[cq]t the best solution but should work reasonably well
  3101. assuming there are few users.
  3102. .SH mergerfs versus X
  3103. .SS mhddfs
  3104. .PP
  3105. mhddfs had not been maintained for some time and has some known
  3106. stability and security issues.
  3107. mergerfs provides a superset of mhddfs\[cq] features and should offer
  3108. the same or better performance.
  3109. .PP
  3110. Below is an example of mhddfs and mergerfs setup to work similarly.
  3111. .PP
  3112. \f[C]mhddfs -o mlimit=4G,allow_other /mnt/drive1,/mnt/drive2 /mnt/pool\f[R]
  3113. .PP
  3114. \f[C]mergerfs -o minfreespace=4G,category.create=ff /mnt/drive1:/mnt/drive2 /mnt/pool\f[R]
  3115. .SS aufs
  3116. .PP
  3117. aufs is mostly abandoned and no longer available in most Linux distros.
  3118. .PP
  3119. While aufs can offer better peak performance mergerfs provides more
  3120. configurability and is generally easier to use.
  3121. mergerfs however does not offer the overlay / copy-on-write (CoW)
  3122. features which aufs has.
  3123. .SS unionfs-fuse
  3124. .PP
  3125. unionfs-fuse is more like aufs than mergerfs in that it offers overlay /
  3126. copy-on-write (CoW) features.
  3127. If you\[cq]re just looking to create a union of filesystems and want
  3128. flexibility in file/directory placement then mergerfs offers that
  3129. whereas unionfs is more for overlaying read/write filesystems over
  3130. read-only ones.
  3131. .SS overlayfs
  3132. .PP
  3133. overlayfs is similar to aufs and unionfs-fuse in that it also is
  3134. primarily used to layer a read/write filesystem over one or more
  3135. read-only filesystems.
  3136. It does not have the ability to spread files/directories across numerous
  3137. filesystems.
  3138. .SS RAID0, JBOD, drive concatenation, striping
  3139. .PP
  3140. With simple JBOD / drive concatenation / stripping / RAID0 a single
  3141. drive failure will result in full pool failure.
  3142. mergerfs performs a similar function without the possibility of
  3143. catastrophic failure and the difficulties in recovery.
  3144. Drives may fail but all other filesystems and their data will continue
  3145. to be accessible.
  3146. .PP
  3147. The main practical difference with mergerfs is the fact you don\[cq]t
  3148. actually have contiguous space as large as if you used those other
  3149. technologies.
  3150. Meaning you can\[cq]t create a 2TB file on a pool of 2 1TB filesystems.
  3151. .PP
  3152. When combined with something like SnapRaid (http://www.snapraid.it)
  3153. and/or an offsite backup solution you can have the flexibility of JBOD
  3154. without the single point of failure.
  3155. .SS UnRAID
  3156. .PP
  3157. UnRAID is a full OS and its storage layer, as I understand, is
  3158. proprietary and closed source.
  3159. Users who have experience with both have often said they prefer the
  3160. flexibility offered by mergerfs and for some the fact it is open source
  3161. is important.
  3162. .PP
  3163. There are a number of UnRAID users who use mergerfs as well though
  3164. I\[cq]m not entirely familiar with the use case.
  3165. .PP
  3166. For semi-static data mergerfs + SnapRaid (http://www.snapraid.it)
  3167. provides a similar solution.
  3168. .SS ZFS
  3169. .PP
  3170. mergerfs is very different from ZFS.
  3171. mergerfs is intended to provide flexible pooling of arbitrary
  3172. filesystems (local or remote), of arbitrary sizes, and arbitrary
  3173. filesystems.
  3174. For \f[C]write once, read many\f[R] usecases such as bulk media storage.
  3175. Where data integrity and backup is managed in other ways.
  3176. In those usecases ZFS can introduce a number of costs and limitations as
  3177. described
  3178. here (http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html),
  3179. here (https://markmcb.com/2020/01/07/five-years-of-btrfs/), and
  3180. here (https://utcc.utoronto.ca/~cks/space/blog/solaris/ZFSWhyNoRealReshaping).
  3181. .SS StableBit\[cq]s DrivePool
  3182. .PP
  3183. DrivePool works only on Windows so not as common an alternative as other
  3184. Linux solutions.
  3185. If you want to use Windows then DrivePool is a good option.
  3186. Functionally the two projects work a bit differently.
  3187. DrivePool always writes to the filesystem with the most free space and
  3188. later rebalances.
  3189. mergerfs does not offer rebalance but chooses a branch at file/directory
  3190. create time.
  3191. DrivePool\[cq]s rebalancing can be done differently in any directory and
  3192. has file pattern matching to further customize the behavior.
  3193. mergerfs, not having rebalancing does not have these features, but
  3194. similar features are planned for mergerfs v3.
  3195. DrivePool has builtin file duplication which mergerfs does not natively
  3196. support (but can be done via an external script.)
  3197. .PP
  3198. There are a lot of misc differences between the two projects but most
  3199. features in DrivePool can be replicated with external tools in
  3200. combination with mergerfs.
  3201. .PP
  3202. Additionally DrivePool is a closed source commercial product vs mergerfs
  3203. a ISC licensed OSS project.
  3204. .SH SUPPORT
  3205. .PP
  3206. Filesystems are complex and difficult to debug.
  3207. mergerfs, while being just a proxy of sorts, can be difficult to debug
  3208. given the large number of possible settings it can have itself and the
  3209. number of environments it can run in.
  3210. When reporting on a suspected issue \f[B]please\f[R] include as much of
  3211. the below information as possible otherwise it will be difficult or
  3212. impossible to diagnose.
  3213. Also please read the above documentation as it provides details on many
  3214. previously encountered questions/issues.
  3215. .PP
  3216. \f[B]Please make sure you are using the latest
  3217. release (https://github.com/trapexit/mergerfs/releases) or have tried it
  3218. in comparison. Old versions, which are often included in distros like
  3219. Debian and Ubuntu, are not ever going to be updated and the issue you
  3220. are encountering may have been addressed already.\f[R]
  3221. .PP
  3222. \f[B]For commercial support or feature requests please contact me
  3223. directly. (mailto:support@spawn.link)\f[R]
  3224. .SS Information to include in bug reports
  3225. .IP \[bu] 2
  3226. Information about the broader problem along with any attempted
  3227. solutions. (https://xyproblem.info)
  3228. .IP \[bu] 2
  3229. Solution already ruled out and why.
  3230. .IP \[bu] 2
  3231. Version of mergerfs: \f[C]mergerfs --version\f[R]
  3232. .IP \[bu] 2
  3233. mergerfs settings / arguments: from fstab, systemd unit, command line,
  3234. OMV plugin, etc.
  3235. .IP \[bu] 2
  3236. Version of the OS: \f[C]uname -a\f[R] and \f[C]lsb_release -a\f[R]
  3237. .IP \[bu] 2
  3238. List of branches, their filesystem types, sizes (before and after
  3239. issue): \f[C]df -h\f[R]
  3240. .IP \[bu] 2
  3241. \f[B]All\f[R] information about the relevant paths and files:
  3242. permissions, ownership, etc.
  3243. .IP \[bu] 2
  3244. \f[B]All\f[R] information about the client app making the requests:
  3245. version, uid/gid
  3246. .IP \[bu] 2
  3247. Runtime environment:
  3248. .RS 2
  3249. .IP \[bu] 2
  3250. Is mergerfs running within a container?
  3251. .IP \[bu] 2
  3252. Are the client apps using mergerfs running in a container?
  3253. .RE
  3254. .IP \[bu] 2
  3255. A \f[C]strace\f[R] of the app having problems:
  3256. .RS 2
  3257. .IP \[bu] 2
  3258. \f[C]strace -fvTtt -s 256 -o /tmp/app.strace.txt <cmd>\f[R]
  3259. .RE
  3260. .IP \[bu] 2
  3261. A \f[C]strace\f[R] of mergerfs while the program is trying to do
  3262. whatever it is failing to do:
  3263. .RS 2
  3264. .IP \[bu] 2
  3265. \f[C]strace -fvTtt -s 256 -p <mergerfsPID> -o /tmp/mergerfs.strace.txt\f[R]
  3266. .RE
  3267. .IP \[bu] 2
  3268. \f[B]Precise\f[R] directions on replicating the issue.
  3269. Do not leave \f[B]anything\f[R] out.
  3270. .IP \[bu] 2
  3271. Try to recreate the problem in the simplest way using standard programs:
  3272. \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],
  3273. etc.
  3274. .SS Contact / Issue submission
  3275. .IP \[bu] 2
  3276. github.com: https://github.com/trapexit/mergerfs/issues
  3277. .IP \[bu] 2
  3278. discord: https://discord.gg/MpAr69V
  3279. .IP \[bu] 2
  3280. reddit: https://www.reddit.com/r/mergerfs
  3281. .SS Donations
  3282. .PP
  3283. https://github.com/trapexit/support
  3284. .PP
  3285. Development and support of a project like mergerfs requires a
  3286. significant amount of time and effort.
  3287. The software is released under the very liberal ISC license and is
  3288. therefore free to use for personal or commercial uses.
  3289. .PP
  3290. If you are a personal user and find mergerfs and its support valuable
  3291. and would like to support the project financially it would be very much
  3292. appreciated.
  3293. .PP
  3294. If you are using mergerfs commercially please consider sponsoring the
  3295. project to ensure it continues to be maintained and receive updates.
  3296. If custom features are needed feel free to contact me
  3297. directly (mailto:support@spawn.link).
  3298. .SH LINKS
  3299. .IP \[bu] 2
  3300. https://spawn.link
  3301. .IP \[bu] 2
  3302. https://github.com/trapexit/mergerfs
  3303. .IP \[bu] 2
  3304. https://github.com/trapexit/mergerfs/wiki
  3305. .IP \[bu] 2
  3306. https://github.com/trapexit/mergerfs-tools
  3307. .IP \[bu] 2
  3308. https://github.com/trapexit/scorch
  3309. .IP \[bu] 2
  3310. https://github.com/trapexit/bbf