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.

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