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.

3054 lines
112 KiB

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