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.

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