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.

3328 lines
122 KiB

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