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.

2118 lines
80 KiB

8 years ago
8 years ago
8 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
8 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
8 years ago
6 years ago
6 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
6 years ago
6 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
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
  1. .\"t
  2. .\" Automatically generated by Pandoc 1.19.2.4
  3. .\"
  4. .TH "mergerfs" "1" "2019\-05\-23" "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[] 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[], \f[B]unionfs\f[], and \f[B]aufs\f[].
  18. .SH FEATURES
  19. .IP \[bu] 2
  20. Runs in userspace (FUSE)
  21. .IP \[bu] 2
  22. Configurable behaviors / file placement
  23. .IP \[bu] 2
  24. Support for extended attributes (xattrs)
  25. .IP \[bu] 2
  26. Support for file attributes (chattr)
  27. .IP \[bu] 2
  28. Runtime configurable (via xattrs)
  29. .IP \[bu] 2
  30. Safe to run as root
  31. .IP \[bu] 2
  32. Opportunistic credential caching
  33. .IP \[bu] 2
  34. Works with heterogeneous filesystem types
  35. .IP \[bu] 2
  36. Handling of writes to full drives (transparently move file to drive with
  37. capacity)
  38. .IP \[bu] 2
  39. Handles pool of read\-only and read/write drives
  40. .IP \[bu] 2
  41. Can turn read\-only files into symlinks to underlying file
  42. .IP \[bu] 2
  43. Hard link copy\-on\-write / CoW
  44. .IP \[bu] 2
  45. supports POSIX ACLs
  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[]
  75. .fi
  76. .PP
  77. mergerfs does \f[B]not\f[] support the copy\-on\-write (CoW) behavior
  78. found in \f[B]aufs\f[] and \f[B]overlayfs\f[].
  79. You can \f[B]not\f[] mount a read\-only filesystem and write to it.
  80. However, mergerfs will ignore read\-only drives when creating new files
  81. so you can mix read\-write and read\-only drives.
  82. .SH OPTIONS
  83. .SS mount options
  84. .IP \[bu] 2
  85. \f[B]allow_other\f[]: A libfuse option which allows users besides the
  86. one which ran mergerfs to see the filesystem.
  87. This is required for most use\-cases.
  88. .IP \[bu] 2
  89. \f[B]minfreespace=value\f[]: The minimum space value used for creation
  90. policies.
  91. Understands \[aq]K\[aq], \[aq]M\[aq], and \[aq]G\[aq] to represent
  92. kilobyte, megabyte, and gigabyte respectively.
  93. (default: 4G)
  94. .IP \[bu] 2
  95. \f[B]moveonenospc=true|false\f[]: When enabled if a \f[B]write\f[] fails
  96. with \f[B]ENOSPC\f[] or \f[B]EDQUOT\f[] a scan of all drives will be
  97. done looking for the drive with the most free space which is at least
  98. the size of the file plus the amount which failed to write.
  99. An attempt to move the file to that drive will occur (keeping all
  100. metadata possible) and if successful the original is unlinked and the
  101. write retried.
  102. (default: false)
  103. .IP \[bu] 2
  104. \f[B]use_ino\f[]: Causes mergerfs to supply file/directory inodes rather
  105. than libfuse.
  106. While not a default it is recommended it be enabled so that linked files
  107. share the same inode value.
  108. .IP \[bu] 2
  109. \f[B]dropcacheonclose=true|false\f[]: When a file is requested to be
  110. closed call \f[C]posix_fadvise\f[] on it first to instruct the kernel
  111. that we no longer need the data and it can drop its cache.
  112. Recommended when \f[B]cache.files=partial|full|auto\-full\f[] to limit
  113. double caching.
  114. (default: false)
  115. .IP \[bu] 2
  116. \f[B]symlinkify=true|false\f[]: When enabled and a file is not writable
  117. and its mtime or ctime is older than \f[B]symlinkify_timeout\f[] files
  118. will be reported as symlinks to the original files.
  119. Please read more below before using.
  120. (default: false)
  121. .IP \[bu] 2
  122. \f[B]symlinkify_timeout=value\f[]: Time to wait, in seconds, to activate
  123. the \f[B]symlinkify\f[] behavior.
  124. (default: 3600)
  125. .IP \[bu] 2
  126. \f[B]nullrw=true|false\f[]: Turns reads and writes into no\-ops.
  127. The request will succeed but do nothing.
  128. Useful for benchmarking mergerfs.
  129. (default: false)
  130. .IP \[bu] 2
  131. \f[B]ignorepponrename=true|false\f[]: Ignore path preserving on rename.
  132. Typically rename and link act differently depending on the policy of
  133. \f[C]create\f[] (read below).
  134. Enabling this will cause rename and link to always use the non\-path
  135. preserving behavior.
  136. This means files, when renamed or linked, will stay on the same drive.
  137. (default: false)
  138. .IP \[bu] 2
  139. \f[B]security_capability=true|false\f[]: If false return ENOATTR when
  140. xattr security.capability is queried.
  141. (default: true)
  142. .IP \[bu] 2
  143. \f[B]xattr=passthrough|noattr|nosys\f[]: Runtime control of xattrs.
  144. Default is to passthrough xattr requests.
  145. \[aq]noattr\[aq] will short circuit as if nothing exists.
  146. \[aq]nosys\[aq] will respond with ENOSYS as if xattrs are not supported
  147. or disabled.
  148. (default: passthrough)
  149. .IP \[bu] 2
  150. \f[B]link_cow=true|false\f[]: When enabled if a regular file is opened
  151. which has a link count > 1 it will copy the file to a temporary file and
  152. rename over the original.
  153. Breaking the link and providing a basic copy\-on\-write function similar
  154. to cow\-shell.
  155. (default: false)
  156. .IP \[bu] 2
  157. \f[B]statfs=base|full\f[]: Controls how statfs works.
  158. \[aq]base\[aq] means it will always use all branches in statfs
  159. calculations.
  160. \[aq]full\[aq] is in effect path preserving and only includes drives
  161. where the path exists.
  162. (default: base)
  163. .IP \[bu] 2
  164. \f[B]statfs_ignore=none|ro|nc\f[]: \[aq]ro\[aq] will cause statfs
  165. calculations to ignore available space for branches mounted or tagged as
  166. \[aq]read\-only\[aq] or \[aq]no create\[aq].
  167. \[aq]nc\[aq] will ignore available space for branches tagged as \[aq]no
  168. create\[aq].
  169. (default: none)
  170. .IP \[bu] 2
  171. \f[B]posix_acl=true|false:\f[] Enable POSIX ACL support (if supported by
  172. kernel and underlying filesystem).
  173. (default: false)
  174. .IP \[bu] 2
  175. \f[B]async_read=true|false:\f[] Perform reads asynchronously.
  176. If disabled or unavailable the kernel will ensure there is at most one
  177. pending read request per file handle and will attempt to order requests
  178. by offset.
  179. (default: true)
  180. .IP \[bu] 2
  181. \f[B]threads=num\f[]: Number of threads to use in multithreaded mode.
  182. When set to zero it will attempt to discover and use the number of
  183. logical cores.
  184. If the lookup fails it will fall back to using 4.
  185. If the thread count is set negative it will look up the number of cores
  186. then divide by the absolute value.
  187. ie.
  188. threads=\-2 on an 8 core machine will result in 8 / 2 = 4 threads.
  189. There will always be at least 1 thread.
  190. NOTE: higher number of threads increases parallelism but usually
  191. decreases throughput.
  192. (default: 0)
  193. .IP \[bu] 2
  194. \f[B]fsname=name\f[]: Sets the name of the filesystem as seen in
  195. \f[B]mount\f[], \f[B]df\f[], etc.
  196. Defaults to a list of the source paths concatenated together with the
  197. longest common prefix removed.
  198. .IP \[bu] 2
  199. \f[B]func.<func>=<policy>\f[]: Sets the specific FUSE function\[aq]s
  200. policy.
  201. See below for the list of value types.
  202. Example: \f[B]func.getattr=newest\f[]
  203. .IP \[bu] 2
  204. \f[B]category.<category>=<policy>\f[]: Sets policy of all FUSE functions
  205. in the provided category.
  206. Example: \f[B]category.create=mfs\f[]
  207. .IP \[bu] 2
  208. \f[B]cache.open=<int>\f[]: \[aq]open\[aq] policy cache timeout in
  209. seconds.
  210. (default: 0)
  211. .IP \[bu] 2
  212. \f[B]cache.statfs=<int>\f[]: \[aq]statfs\[aq] cache timeout in seconds.
  213. (default: 0)
  214. .IP \[bu] 2
  215. \f[B]cache.attr=<int>\f[]: File attribute cache timeout in seconds.
  216. (default: 1)
  217. .IP \[bu] 2
  218. \f[B]cache.entry=<int>\f[]: File name lookup cache timeout in seconds.
  219. (default: 1)
  220. .IP \[bu] 2
  221. \f[B]cache.negative_entry=<int>\f[]: Negative file name lookup cache
  222. timeout in seconds.
  223. (default: 0)
  224. .IP \[bu] 2
  225. \f[B]cache.files=libfuse|off|partial|full|auto\-full\f[]: File page
  226. caching mode (default: libfuse)
  227. .IP \[bu] 2
  228. \f[B]cache.symlinks=<bool>\f[]: Cache symlinks (if supported by kernel)
  229. (default: false)
  230. .IP \[bu] 2
  231. \f[B]cache.readdir=<bool>\f[]: Cache readdir (if supported by kernel)
  232. (default: false)
  233. .IP \[bu] 2
  234. \f[B]direct_io\f[]: deprecated \- Bypass page cache.
  235. Use \f[C]cache.files=off\f[] instead.
  236. (default: false)
  237. .IP \[bu] 2
  238. \f[B]kernel_cache\f[]: deprecated \- Do not invalidate data cache on
  239. file open.
  240. Use \f[C]cache.files=full\f[] instead.
  241. (default: false)
  242. .IP \[bu] 2
  243. \f[B]auto_cache\f[]: deprecated \- Invalidate data cache if file mtime
  244. or size change.
  245. Use \f[C]cache.files=auto\-full\f[] instead.
  246. (default: false)
  247. .IP \[bu] 2
  248. \f[B]async_read\f[]: deprecated \- Perform reads asynchronously.
  249. Use \f[C]async_read=true\f[] instead.
  250. .IP \[bu] 2
  251. \f[B]sync_read\f[]: deprecated \- Perform reads synchronously.
  252. Use \f[C]async_read=false\f[] instead.
  253. .PP
  254. \f[B]NOTE:\f[] Options are evaluated in the order listed so if the
  255. options are \f[B]func.rmdir=rand,category.action=ff\f[] the
  256. \f[B]action\f[] category setting will override the \f[B]rmdir\f[]
  257. setting.
  258. .SS branches
  259. .PP
  260. The \[aq]branches\[aq] (formerly \[aq]srcmounts\[aq]) argument is a
  261. colon (\[aq]:\[aq]) delimited list of paths to be pooled together.
  262. It does not matter if the paths are on the same or different drives nor
  263. does it matter the filesystem.
  264. Used and available space will not be duplicated for paths on the same
  265. device and any features which aren\[aq]t supported by the underlying
  266. filesystem (such as file attributes or extended attributes) will return
  267. the appropriate errors.
  268. .PP
  269. To make it easier to include multiple branches mergerfs supports
  270. globbing (http://linux.die.net/man/7/glob).
  271. \f[B]The globbing tokens MUST be escaped when using via the shell else
  272. the shell itself will apply the glob itself.\f[]
  273. .PP
  274. Each branch can have a suffix of \f[C]=RW\f[] (read / write),
  275. \f[C]=RO\f[] (read\-only), or \f[C]=NC\f[] (no create).
  276. These suffixes work with globs as well and will apply to each path
  277. found.
  278. \f[C]RW\f[] is the default behavior and those paths will be eligible for
  279. all policy categories.
  280. \f[C]RO\f[] will exclude those paths from \f[C]create\f[] and
  281. \f[C]action\f[] policies (just as a filesystem being mounted \f[C]ro\f[]
  282. would).
  283. \f[C]NC\f[] will exclude those paths from \f[C]create\f[] policies (you
  284. can\[aq]t create but you can change / delete).
  285. .IP
  286. .nf
  287. \f[C]
  288. #\ mergerfs\ \-o\ allow_other,use_ino\ /mnt/disk\\*:/mnt/cdrom\ /media/drives
  289. \f[]
  290. .fi
  291. .PP
  292. The above line will use all mount points in /mnt prefixed with
  293. \f[B]disk\f[] and the \f[B]cdrom\f[].
  294. .PP
  295. To have the pool mounted at boot or otherwise accessable from related
  296. tools use \f[B]/etc/fstab\f[].
  297. .IP
  298. .nf
  299. \f[C]
  300. #\ <file\ system>\ \ \ \ \ \ \ \ <mount\ point>\ \ <type>\ \ \ \ \ \ \ \ \ <options>\ \ \ \ \ \ \ \ \ \ \ \ \ <dump>\ \ <pass>
  301. /mnt/disk*:/mnt/cdrom\ \ /media/drives\ \ fuse.mergerfs\ \ allow_other,use_ino\ \ \ 0\ \ \ \ \ \ \ 0
  302. \f[]
  303. .fi
  304. .PP
  305. \f[B]NOTE:\f[] the globbing is done at mount or xattr update time (see
  306. below).
  307. If a new directory is added matching the glob after the fact it will not
  308. be automatically included.
  309. .PP
  310. \f[B]NOTE:\f[] for mounting via \f[B]fstab\f[] to work you must have
  311. \f[B]mount.fuse\f[] installed.
  312. For Ubuntu/Debian it is included in the \f[B]fuse\f[] package.
  313. .SS symlinkify
  314. .PP
  315. Due to the levels of indirection introduced by mergerfs and the
  316. underlying technology FUSE there can be varying levels of performance
  317. degredation.
  318. This feature will turn non\-directories which are not writable into
  319. symlinks to the original file found by the \f[C]readlink\f[] policy
  320. after the mtime and ctime are older than the timeout.
  321. .PP
  322. \f[B]WARNING:\f[] The current implementation has a known issue in which
  323. if the file is open and being used when the file is converted to a
  324. symlink then the application which has that file open will receive an
  325. error when using it.
  326. This is unlikely to occur in practice but is something to keep in mind.
  327. .PP
  328. \f[B]WARNING:\f[] Some backup solutions, such as CrashPlan, do not
  329. backup the target of a symlink.
  330. If using this feature it will be necessary to point any backup software
  331. to the original drives or configure the software to follow symlinks if
  332. such an option is available.
  333. Alternatively create two mounts.
  334. One for backup and one for general consumption.
  335. .SS nullrw
  336. .PP
  337. Due to how FUSE works there is an overhead to all requests made to a
  338. FUSE filesystem.
  339. Meaning that even a simple passthrough will have some slowdown.
  340. However, generally the overhead is minimal in comparison to the cost of
  341. the underlying I/O.
  342. By disabling the underlying I/O we can test the theoretical performance
  343. boundries.
  344. .PP
  345. By enabling \f[C]nullrw\f[] mergerfs will work as it always does
  346. \f[B]except\f[] that all reads and writes will be no\-ops.
  347. A write will succeed (the size of the write will be returned as if it
  348. were successful) but mergerfs does nothing with the data it was given.
  349. Similarly a read will return the size requested but won\[aq]t touch the
  350. buffer.
  351. .PP
  352. Example:
  353. .IP
  354. .nf
  355. \f[C]
  356. $\ dd\ if=/dev/zero\ of=/path/to/mergerfs/mount/benchmark\ ibs=1M\ obs=512\ count=1024\ conv=fdatasync
  357. 1024+0\ records\ in
  358. 2097152+0\ records\ out
  359. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 15.4067\ s,\ 69.7\ MB/s
  360. $\ dd\ if=/dev/zero\ of=/path/to/mergerfs/mount/benchmark\ ibs=1M\ obs=1M\ count=1024\ conv=fdatasync
  361. 1024+0\ records\ in
  362. 1024+0\ records\ out
  363. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 0.219585\ s,\ 4.9\ GB/s
  364. $\ dd\ if=/path/to/mergerfs/mount/benchmark\ of=/dev/null\ bs=512\ count=102400\ conv=fdatasync
  365. 102400+0\ records\ in
  366. 102400+0\ records\ out
  367. 52428800\ bytes\ (52\ MB,\ 50\ MiB)\ copied,\ 0.757991\ s,\ 69.2\ MB/s
  368. $\ dd\ if=/path/to/mergerfs/mount/benchmark\ of=/dev/null\ bs=1M\ count=1024\ conv=fdatasync
  369. 1024+0\ records\ in
  370. 1024+0\ records\ out
  371. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 0.18405\ s,\ 5.8\ GB/s
  372. \f[]
  373. .fi
  374. .PP
  375. It\[aq]s important to test with different \f[C]obs\f[] (output block
  376. size) values since the relative overhead is greater with smaller values.
  377. As you can see above the size of a read or write can massively impact
  378. theoretical performance.
  379. If an application performs much worse through mergerfs it could very
  380. well be that it doesn\[aq]t optimally size its read and write requests.
  381. In such cases contact the mergerfs author so it can be investigated.
  382. .SS xattr
  383. .PP
  384. Runtime extended attribute support can be managed via the \f[C]xattr\f[]
  385. option.
  386. By default it will passthrough any xattr calls.
  387. Given xattr support is rarely used and can have significant performance
  388. implications mergerfs allows it to be disabled at runtime.
  389. .PP
  390. \f[C]noattr\f[] will cause mergerfs to short circuit all xattr calls and
  391. return ENOATTR where appropriate.
  392. mergerfs still gets all the requests but they will not be forwarded on
  393. to the underlying filesystems.
  394. The runtime control will still function in this mode.
  395. .PP
  396. \f[C]nosys\f[] will cause mergerfs to return ENOSYS for any xattr call.
  397. The difference with \f[C]noattr\f[] is that the kernel will cache this
  398. fact and itself short circuit future calls.
  399. This will be more efficient than \f[C]noattr\f[] but will cause
  400. mergerfs\[aq] runtime control via the hidden file to stop working.
  401. .SH FUNCTIONS / POLICIES / CATEGORIES
  402. .PP
  403. The POSIX filesystem API is made up of a number of functions.
  404. \f[B]creat\f[], \f[B]stat\f[], \f[B]chown\f[], etc.
  405. In mergerfs most of the core functions are grouped into 3 categories:
  406. \f[B]action\f[], \f[B]create\f[], and \f[B]search\f[].
  407. These functions and categories can be assigned a policy which dictates
  408. what file or directory is chosen when performing that behavior.
  409. Any policy can be assigned to a function or category though some may not
  410. be very useful in practice.
  411. For instance: \f[B]rand\f[] (random) may be useful for file creation
  412. (create) but could lead to very odd behavior if used for \f[C]chmod\f[]
  413. if there were more than one copy of the file.
  414. .PP
  415. Some functions, listed in the category \f[C]N/A\f[] below, can not be
  416. assigned the normal policies.
  417. All functions which work on file handles use the handle which was
  418. acquired by \f[C]open\f[] or \f[C]create\f[].
  419. \f[C]readdir\f[] has no real need for a policy given the purpose is
  420. merely to return a list of entries in a directory.
  421. \f[C]statfs\f[]\[aq]s behavior can be modified via other options.
  422. That said many times the current FUSE kernel driver will not always
  423. provide the file handle when a client calls \f[C]fgetattr\f[],
  424. \f[C]fchown\f[], \f[C]fchmod\f[], \f[C]futimens\f[], \f[C]ftruncate\f[],
  425. etc.
  426. This means it will call the regular, path based, versions.
  427. .PP
  428. When using policies which are based on a branch\[aq]s available space
  429. the base path provided is used.
  430. Not the full path to the file in question.
  431. Meaning that sub mounts won\[aq]t be considered in the space
  432. calculations.
  433. The reason is that it doesn\[aq]t really work for non\-path preserving
  434. policies and can lead to non\-obvious behaviors.
  435. .SS Function / Category classifications
  436. .PP
  437. .TS
  438. tab(@);
  439. lw(7.9n) lw(62.1n).
  440. T{
  441. Category
  442. T}@T{
  443. FUSE Functions
  444. T}
  445. _
  446. T{
  447. action
  448. T}@T{
  449. chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate,
  450. unlink, utimens
  451. T}
  452. T{
  453. create
  454. T}@T{
  455. create, mkdir, mknod, symlink
  456. T}
  457. T{
  458. search
  459. T}@T{
  460. access, getattr, getxattr, ioctl (directories), listxattr, open,
  461. readlink
  462. T}
  463. T{
  464. N/A
  465. T}@T{
  466. fchmod, fchown, futimens, ftruncate, fallocate, fgetattr, fsync, ioctl
  467. (files), read, readdir, release, statfs, write, copy_file_range
  468. T}
  469. .TE
  470. .PP
  471. In cases where something may be searched (to confirm a directory exists
  472. across all source mounts) \f[B]getattr\f[] will be used.
  473. .SS Path Preservation
  474. .PP
  475. Policies, as described below, are of two basic types.
  476. \f[C]path\ preserving\f[] and \f[C]non\-path\ preserving\f[].
  477. .PP
  478. All policies which start with \f[C]ep\f[] (\f[B]epff\f[],
  479. \f[B]eplfs\f[], \f[B]eplus\f[], \f[B]epmfs\f[], \f[B]eprand\f[]) are
  480. \f[C]path\ preserving\f[].
  481. \f[C]ep\f[] stands for \f[C]existing\ path\f[].
  482. .PP
  483. A path preserving policy will only consider drives where the relative
  484. path being accessed already exists.
  485. .PP
  486. When using non\-path preserving policies paths will be cloned to target
  487. drives as necessary.
  488. .SS Filters
  489. .PP
  490. Policies basically search branches and create a list of files / paths
  491. for functions to work on.
  492. The policy is responsible for filtering and sorting.
  493. The policy type defines the sorting but filtering is mostly uniform as
  494. described below.
  495. .IP \[bu] 2
  496. No \f[B]search\f[] policies filter.
  497. .IP \[bu] 2
  498. All \f[B]action\f[] policies will filter out branches which are mounted
  499. \f[B]read\-only\f[] or tagged as \f[B]RO (read\-only)\f[].
  500. .IP \[bu] 2
  501. All \f[B]create\f[] policies will filter out branches which are mounted
  502. \f[B]read\-only\f[], tagged \f[B]RO (read\-only)\f[] or \f[B]NC (no
  503. create)\f[], or has available space less than \f[C]minfreespace\f[].
  504. .PP
  505. If all branches are filtered an error will be returned.
  506. Typically \f[B]EROFS\f[] or \f[B]ENOSPC\f[] depending on the reasons.
  507. .SS Policy descriptions
  508. .PP
  509. .TS
  510. tab(@);
  511. lw(16.6n) lw(53.4n).
  512. T{
  513. Policy
  514. T}@T{
  515. Description
  516. T}
  517. _
  518. T{
  519. all
  520. T}@T{
  521. Search category: same as \f[B]epall\f[].
  522. Action category: same as \f[B]epall\f[].
  523. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  524. \f[B]symlink\f[] it will apply to all branches.
  525. \f[B]create\f[] works like \f[B]ff\f[].
  526. T}
  527. T{
  528. epall (existing path, all)
  529. T}@T{
  530. Search category: same as \f[B]epff\f[] (but more expensive because it
  531. doesn\[aq]t stop after finding a valid branch).
  532. Action category: apply to all found.
  533. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  534. \f[B]symlink\f[] it will apply to all found.
  535. \f[B]create\f[] works like \f[B]epff\f[] (but more expensive because it
  536. doesn\[aq]t stop after finding a valid branch).
  537. T}
  538. T{
  539. epff (existing path, first found)
  540. T}@T{
  541. Given the order of the branches, as defined at mount time or configured
  542. at runtime, act on the first one found where the relative path exists.
  543. T}
  544. T{
  545. eplfs (existing path, least free space)
  546. T}@T{
  547. Of all the branches on which the relative path exists choose the drive
  548. with the least free space.
  549. T}
  550. T{
  551. eplus (existing path, least used space)
  552. T}@T{
  553. Of all the branches on which the relative path exists choose the drive
  554. with the least used space.
  555. T}
  556. T{
  557. epmfs (existing path, most free space)
  558. T}@T{
  559. Of all the branches on which the relative path exists choose the drive
  560. with the most free space.
  561. T}
  562. T{
  563. eprand (existing path, random)
  564. T}@T{
  565. Calls \f[B]epall\f[] and then randomizes.
  566. T}
  567. T{
  568. erofs
  569. T}@T{
  570. Exclusively return \f[B]\-1\f[] with \f[B]errno\f[] set to
  571. \f[B]EROFS\f[] (read\-only filesystem).
  572. T}
  573. T{
  574. ff (first found)
  575. T}@T{
  576. Search category: same as \f[B]epff\f[].
  577. Action category: same as \f[B]epff\f[].
  578. Create category: Given the order of the drives, as defined at mount time
  579. or configured at runtime, act on the first one found.
  580. T}
  581. T{
  582. lfs (least free space)
  583. T}@T{
  584. Search category: same as \f[B]eplfs\f[].
  585. Action category: same as \f[B]eplfs\f[].
  586. Create category: Pick the drive with the least available free space.
  587. T}
  588. T{
  589. lus (least used space)
  590. T}@T{
  591. Search category: same as \f[B]eplus\f[].
  592. Action category: same as \f[B]eplus\f[].
  593. Create category: Pick the drive with the least used space.
  594. T}
  595. T{
  596. mfs (most free space)
  597. T}@T{
  598. Search category: same as \f[B]epmfs\f[].
  599. Action category: same as \f[B]epmfs\f[].
  600. Create category: Pick the drive with the most available free space.
  601. T}
  602. T{
  603. newest
  604. T}@T{
  605. Pick the file / directory with the largest mtime.
  606. T}
  607. T{
  608. rand (random)
  609. T}@T{
  610. Calls \f[B]all\f[] and then randomizes.
  611. T}
  612. .TE
  613. .SS Defaults
  614. .PP
  615. .TS
  616. tab(@);
  617. l l.
  618. T{
  619. Category
  620. T}@T{
  621. Policy
  622. T}
  623. _
  624. T{
  625. action
  626. T}@T{
  627. epall
  628. T}
  629. T{
  630. create
  631. T}@T{
  632. epmfs
  633. T}
  634. T{
  635. search
  636. T}@T{
  637. ff
  638. T}
  639. .TE
  640. .SS ioctl
  641. .PP
  642. When \f[C]ioctl\f[] is used with an open file then it will use the file
  643. handle which was created at the original \f[C]open\f[] call.
  644. However, when using \f[C]ioctl\f[] with a directory mergerfs will use
  645. the \f[C]open\f[] policy to find the directory to act on.
  646. .SS unlink
  647. .PP
  648. In FUSE there is an opaque "file handle" which is created by
  649. \f[C]open\f[], \f[C]create\f[], or \f[C]opendir\f[], passed to the
  650. kernel, and then is passed back to the FUSE userland application by the
  651. kernel.
  652. Unfortunately, the FUSE kernel driver does not always send the file
  653. handle when it theoretically could/should.
  654. This complicates certain behaviors / workflows particularly in the high
  655. level API.
  656. As a result mergerfs is currently doing a few hacky things.
  657. .PP
  658. libfuse2 and libfuse3, when using the high level API, will rename names
  659. to \f[C]\&.fuse_hiddenXXXXXX\f[] if the file is open when unlinked or
  660. renamed over.
  661. It does this so the file is still available when a request referencing
  662. the now missing file is made.
  663. This file however keeps a \f[C]rmdir\f[] from succeeding and can be
  664. picked up by software reading directories.
  665. .PP
  666. The change mergerfs has done is that if a file is open when an unlink or
  667. rename happens it will open the file and keep it open till closed by all
  668. those who opened it prior.
  669. When a request comes in referencing that file and it doesn\[aq]t include
  670. a file handle it will instead use the file handle created at
  671. unlink/rename time.
  672. .PP
  673. This won\[aq]t result in technically proper behavior but close enough
  674. for many usecases.
  675. .PP
  676. The plan is to rewrite mergerfs to use the low level API so these
  677. invasive libfuse changes are no longer necessary.
  678. .SS rename & link
  679. .PP
  680. \f[B]NOTE:\f[] If you\[aq]re receiving errors from software when files
  681. are moved / renamed / linked then you should consider changing the
  682. create policy to one which is \f[B]not\f[] path preserving, enabling
  683. \f[C]ignorepponrename\f[], or contacting the author of the offending
  684. software and requesting that \f[C]EXDEV\f[] be properly handled.
  685. .PP
  686. \f[C]rename\f[] and \f[C]link\f[] are tricky functions in a union
  687. filesystem.
  688. \f[C]rename\f[] only works within a single filesystem or device.
  689. If a rename can\[aq]t be done atomically due to the source and
  690. destination paths existing on different mount points it will return
  691. \f[B]\-1\f[] with \f[B]errno = EXDEV\f[] (cross device).
  692. So if a \f[C]rename\f[]\[aq]s source and target are on different drives
  693. within the pool it creates an issue.
  694. .PP
  695. Originally mergerfs would return EXDEV whenever a rename was requested
  696. which was cross directory in any way.
  697. This made the code simple and was technically complient with POSIX
  698. requirements.
  699. However, many applications fail to handle EXDEV at all and treat it as a
  700. normal error or otherwise handle it poorly.
  701. Such apps include: gvfsd\-fuse v1.20.3 and prior, Finder / CIFS/SMB
  702. client in Apple OSX 10.9+, NZBGet, Samba\[aq]s recycling bin feature.
  703. .PP
  704. As a result a compromise was made in order to get most software to work
  705. while still obeying mergerfs\[aq] policies.
  706. Below is the basic logic.
  707. .IP \[bu] 2
  708. If using a \f[B]create\f[] policy which tries to preserve directory
  709. paths (epff,eplfs,eplus,epmfs)
  710. .IP \[bu] 2
  711. Using the \f[B]rename\f[] policy get the list of files to rename
  712. .IP \[bu] 2
  713. For each file attempt rename:
  714. .RS 2
  715. .IP \[bu] 2
  716. If failure with ENOENT run \f[B]create\f[] policy
  717. .IP \[bu] 2
  718. If create policy returns the same drive as currently evaluating then
  719. clone the path
  720. .IP \[bu] 2
  721. Re\-attempt rename
  722. .RE
  723. .IP \[bu] 2
  724. If \f[B]any\f[] of the renames succeed the higher level rename is
  725. considered a success
  726. .IP \[bu] 2
  727. If \f[B]no\f[] renames succeed the first error encountered will be
  728. returned
  729. .IP \[bu] 2
  730. On success:
  731. .RS 2
  732. .IP \[bu] 2
  733. Remove the target from all drives with no source file
  734. .IP \[bu] 2
  735. Remove the source from all drives which failed to rename
  736. .RE
  737. .IP \[bu] 2
  738. If using a \f[B]create\f[] policy which does \f[B]not\f[] try to
  739. preserve directory paths
  740. .IP \[bu] 2
  741. Using the \f[B]rename\f[] policy get the list of files to rename
  742. .IP \[bu] 2
  743. Using the \f[B]getattr\f[] policy get the target path
  744. .IP \[bu] 2
  745. For each file attempt rename:
  746. .RS 2
  747. .IP \[bu] 2
  748. If the source drive != target drive:
  749. .IP \[bu] 2
  750. Clone target path from target drive to source drive
  751. .IP \[bu] 2
  752. Rename
  753. .RE
  754. .IP \[bu] 2
  755. If \f[B]any\f[] of the renames succeed the higher level rename is
  756. considered a success
  757. .IP \[bu] 2
  758. If \f[B]no\f[] renames succeed the first error encountered will be
  759. returned
  760. .IP \[bu] 2
  761. On success:
  762. .RS 2
  763. .IP \[bu] 2
  764. Remove the target from all drives with no source file
  765. .IP \[bu] 2
  766. Remove the source from all drives which failed to rename
  767. .RE
  768. .PP
  769. The the removals are subject to normal entitlement checks.
  770. .PP
  771. The above behavior will help minimize the likelihood of EXDEV being
  772. returned but it will still be possible.
  773. .PP
  774. \f[B]link\f[] uses the same strategy but without the removals.
  775. .SS readdir
  776. .PP
  777. readdir (http://linux.die.net/man/3/readdir) is different from all other
  778. filesystem functions.
  779. While it could have it\[aq]s own set of policies to tweak its behavior
  780. at this time it provides a simple union of files and directories found.
  781. Remember that any action or information queried about these files and
  782. directories come from the respective function.
  783. For instance: an \f[B]ls\f[] is a \f[B]readdir\f[] and for each
  784. file/directory returned \f[B]getattr\f[] is called.
  785. Meaning the policy of \f[B]getattr\f[] is responsible for choosing the
  786. file/directory which is the source of the metadata you see in an
  787. \f[B]ls\f[].
  788. .SS statfs / statvfs
  789. .PP
  790. statvfs (http://linux.die.net/man/2/statvfs) normalizes the source
  791. drives based on the fragment size and sums the number of adjusted blocks
  792. and inodes.
  793. This means you will see the combined space of all sources.
  794. Total, used, and free.
  795. The sources however are dedupped based on the drive so multiple sources
  796. on the same drive will not result in double counting it\[aq]s space.
  797. Filesystems mounted further down the tree of the branch will not be
  798. included when checking the mount\[aq]s stats.
  799. .PP
  800. The options \f[C]statfs\f[] and \f[C]statfs_ignore\f[] can be used to
  801. modify \f[C]statfs\f[] behavior.
  802. .SH BUILDING
  803. .PP
  804. \f[B]NOTE:\f[] Prebuilt packages can be found at:
  805. https://github.com/trapexit/mergerfs/releases
  806. .PP
  807. First get the code from github (https://github.com/trapexit/mergerfs).
  808. .IP
  809. .nf
  810. \f[C]
  811. $\ git\ clone\ https://github.com/trapexit/mergerfs.git
  812. $\ #\ or
  813. $\ wget\ https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs\-<ver>.tar.gz
  814. \f[]
  815. .fi
  816. .SS Debian / Ubuntu
  817. .IP
  818. .nf
  819. \f[C]
  820. $\ cd\ mergerfs
  821. $\ sudo\ tools/install\-build\-pkgs
  822. $\ make\ deb
  823. $\ sudo\ dpkg\ \-i\ ../mergerfs_version_arch.deb
  824. \f[]
  825. .fi
  826. .SS Fedora
  827. .IP
  828. .nf
  829. \f[C]
  830. $\ su\ \-
  831. #\ cd\ mergerfs
  832. #\ tools/install\-build\-pkgs
  833. #\ make\ rpm
  834. #\ rpm\ \-i\ rpmbuild/RPMS/<arch>/mergerfs\-<verion>.<arch>.rpm
  835. \f[]
  836. .fi
  837. .SS Generically
  838. .PP
  839. Have git, g++, make, python installed.
  840. .IP
  841. .nf
  842. \f[C]
  843. $\ cd\ mergerfs
  844. $\ make
  845. $\ sudo\ make\ install
  846. \f[]
  847. .fi
  848. .SS Build options
  849. .IP
  850. .nf
  851. \f[C]
  852. $\ make\ help
  853. usage:\ make
  854. make\ USE_XATTR=0\ \ \ \ \ \ \-\ build\ program\ without\ xattrs\ functionality
  855. make\ STATIC=1\ \ \ \ \ \ \ \ \ \-\ build\ static\ binary
  856. make\ LTO=1\ \ \ \ \ \ \ \ \ \ \ \ \-\ build\ with\ link\ time\ optimization
  857. \f[]
  858. .fi
  859. .SH RUNTIME CONFIG
  860. .SS .mergerfs pseudo file
  861. .IP
  862. .nf
  863. \f[C]
  864. <mountpoint>/.mergerfs
  865. \f[]
  866. .fi
  867. .PP
  868. There is a pseudo file available at the mount point which allows for the
  869. runtime modification of certain \f[B]mergerfs\f[] options.
  870. The file will not show up in \f[B]readdir\f[] but can be
  871. \f[B]stat\f[]\[aq]ed and manipulated via
  872. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls.
  873. .PP
  874. Any changes made at runtime are \f[B]not\f[] persisted.
  875. If you wish for values to persist they must be included as options
  876. wherever you configure the mounting of mergerfs (/etc/fstab).
  877. .SS Keys
  878. .PP
  879. Use \f[C]xattr\ \-l\ /mountpoint/.mergerfs\f[] to see all supported
  880. keys.
  881. Some are informational and therefore read\-only.
  882. .SS user.mergerfs.branches
  883. .PP
  884. \f[B]NOTE:\f[] formerly \f[C]user.mergerfs.srcmounts\f[] but said key is
  885. still supported.
  886. .PP
  887. Used to query or modify the list of branches.
  888. When modifying there are several shortcuts to easy manipulation of the
  889. list.
  890. .PP
  891. .TS
  892. tab(@);
  893. l l.
  894. T{
  895. Value
  896. T}@T{
  897. Description
  898. T}
  899. _
  900. T{
  901. [list]
  902. T}@T{
  903. set
  904. T}
  905. T{
  906. +<[list]
  907. T}@T{
  908. prepend
  909. T}
  910. T{
  911. +>[list]
  912. T}@T{
  913. append
  914. T}
  915. T{
  916. \-[list]
  917. T}@T{
  918. remove all values provided
  919. T}
  920. T{
  921. \-<
  922. T}@T{
  923. remove first in list
  924. T}
  925. T{
  926. \->
  927. T}@T{
  928. remove last in list
  929. T}
  930. .TE
  931. .PP
  932. \f[C]xattr\ \-w\ user.mergerfs.branches\ +</mnt/drive3\ /mnt/pool/.mergerfs\f[]
  933. .PP
  934. The \f[C]=NC\f[], \f[C]=RO\f[], \f[C]=RW\f[] syntax works just as on the
  935. command line.
  936. .SS minfreespace
  937. .PP
  938. Input: interger with an optional multiplier suffix.
  939. \f[B]K\f[], \f[B]M\f[], or \f[B]G\f[].
  940. .PP
  941. Output: value in bytes
  942. .SS moveonenospc
  943. .PP
  944. Input: \f[B]true\f[] and \f[B]false\f[]
  945. .PP
  946. Ouput: \f[B]true\f[] or \f[B]false\f[]
  947. .SS categories / funcs
  948. .PP
  949. Input: short policy string as described elsewhere in this document
  950. .PP
  951. Output: the policy string except for categories where its funcs have
  952. multiple types.
  953. In that case it will be a comma separated list
  954. .SS Example
  955. .IP
  956. .nf
  957. \f[C]
  958. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-l\ .mergerfs
  959. user.mergerfs.branches:\ /mnt/a:/mnt/b
  960. user.mergerfs.minfreespace:\ 4294967295
  961. user.mergerfs.moveonenospc:\ false
  962. \&...
  963. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  964. ff
  965. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.category.search\ newest\ .mergerfs
  966. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  967. newest
  968. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.branches\ +/mnt/c\ .mergerfs
  969. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.branches\ .mergerfs
  970. /mnt/a:/mnt/b:/mnt/c
  971. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.branches\ =/mnt/c\ .mergerfs
  972. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.branches\ .mergerfs
  973. /mnt/c
  974. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.branches\ \[aq]+</mnt/a:/mnt/b\[aq]\ .mergerfs
  975. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.branches\ .mergerfs
  976. /mnt/a:/mnt/b:/mnt/c
  977. \f[]
  978. .fi
  979. .SS file / directory xattrs
  980. .PP
  981. While they won\[aq]t show up when using
  982. listxattr (http://linux.die.net/man/2/listxattr) \f[B]mergerfs\f[]
  983. offers a number of special xattrs to query information about the files
  984. served.
  985. To access the values you will need to issue a
  986. getxattr (http://linux.die.net/man/2/getxattr) for one of the following:
  987. .IP \[bu] 2
  988. \f[B]user.mergerfs.basepath:\f[] the base mount point for the file given
  989. the current getattr policy
  990. .IP \[bu] 2
  991. \f[B]user.mergerfs.relpath:\f[] the relative path of the file from the
  992. perspective of the mount point
  993. .IP \[bu] 2
  994. \f[B]user.mergerfs.fullpath:\f[] the full path of the original file
  995. given the getattr policy
  996. .IP \[bu] 2
  997. \f[B]user.mergerfs.allpaths:\f[] a NUL (\[aq]\[aq]) separated list of
  998. full paths to all files found
  999. .IP
  1000. .nf
  1001. \f[C]
  1002. [trapexit:/mnt/mergerfs]\ $\ ls
  1003. A\ B\ C
  1004. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.fullpath\ A
  1005. /mnt/a/full/path/to/A
  1006. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.basepath\ A
  1007. /mnt/a
  1008. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.relpath\ A
  1009. /full/path/to/A
  1010. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.allpaths\ A\ |\ tr\ \[aq]\\0\[aq]\ \[aq]\\n\[aq]
  1011. /mnt/a/full/path/to/A
  1012. /mnt/b/full/path/to/A
  1013. \f[]
  1014. .fi
  1015. .SH TOOLING
  1016. .IP \[bu] 2
  1017. https://github.com/trapexit/mergerfs\-tools
  1018. .IP \[bu] 2
  1019. mergerfs.ctl: A tool to make it easier to query and configure mergerfs
  1020. at runtime
  1021. .IP \[bu] 2
  1022. mergerfs.fsck: Provides permissions and ownership auditing and the
  1023. ability to fix them
  1024. .IP \[bu] 2
  1025. mergerfs.dedup: Will help identify and optionally remove duplicate files
  1026. .IP \[bu] 2
  1027. mergerfs.dup: Ensure there are at least N copies of a file across the
  1028. pool
  1029. .IP \[bu] 2
  1030. mergerfs.balance: Rebalance files across drives by moving them from the
  1031. most filled to the least filled
  1032. .IP \[bu] 2
  1033. mergerfs.mktrash: Creates FreeDesktop.org Trash specification compatible
  1034. directories on a mergerfs mount
  1035. .IP \[bu] 2
  1036. https://github.com/trapexit/scorch
  1037. .IP \[bu] 2
  1038. scorch: A tool to help discover silent corruption of files and keep
  1039. track of files
  1040. .IP \[bu] 2
  1041. https://github.com/trapexit/bbf
  1042. .IP \[bu] 2
  1043. bbf (bad block finder): a tool to scan for and \[aq]fix\[aq] hard drive
  1044. bad blocks and find the files using those blocks
  1045. .SH CACHING
  1046. .SS page caching
  1047. .PP
  1048. https://en.wikipedia.org/wiki/Page_cache
  1049. .PP
  1050. tl;dr: * cache.files=off: Disables page caching.
  1051. Underlying files cached, mergerfs files are not.
  1052. * cache.files=partial: Enables page caching.
  1053. Underlying files cached, mergerfs files cached while open.
  1054. * cache.files=full: Enables page caching.
  1055. Underlying files cached, mergerfs files cached across opens.
  1056. * cache.files=auto\-full: Enables page caching.
  1057. Underlying files cached, mergerfs files cached across opens if mtime and
  1058. size are unchanged since previous open.
  1059. * cache.files=libfuse: follow traditional libfuse \f[C]direct_io\f[],
  1060. \[aq]kernel_cache\f[C],\ and\f[]auto_cache` arguments.
  1061. .PP
  1062. FUSE, which mergerfs uses, offers a number of page caching modes.
  1063. mergerfs tries to simplify their use via the \f[C]cache.files\f[]
  1064. option.
  1065. It can and should replace usage of \f[C]direct_io\f[],
  1066. \f[C]kernel_cache\f[], and \f[C]auto_cache\f[].
  1067. .PP
  1068. Due to mergerfs using FUSE and therefore being a userland process
  1069. proxying existing filesystems the kernel will double cache the content
  1070. being read and written through mergerfs.
  1071. Once from the underlying filesystem and once from mergerfs (it sees them
  1072. as two separate entities).
  1073. Using \f[C]cache.files=off\f[] will keep the double caching from
  1074. happening by disabling caching of mergerfs but this has the side effect
  1075. that \f[I]all\f[] read and write calls will be passed to mergerfs which
  1076. may be slower than enabling caching, you lose shared \f[C]mmap\f[]
  1077. support which can affect apps such as rtorrent, and no read\-ahead will
  1078. take place.
  1079. The kernel will still cache the underlying filesystem data but that only
  1080. helps so much given mergerfs will still process all requests.
  1081. .PP
  1082. If you do enable file page caching,
  1083. \f[C]cache.files=partial|full|auto\-full\f[], you should also enable
  1084. \f[C]dropcacheonclose\f[] which will cause mergerfs to instruct the
  1085. kernel to flush the underlying file\[aq]s page cache when the file is
  1086. closed.
  1087. This behavior is the same as the rsync fadvise / drop cache patch and
  1088. Feh\[aq]s nocache project.
  1089. .PP
  1090. If most files are read once through and closed (like media) it is best
  1091. to enable \f[C]dropcacheonclose\f[] regardless of caching mode in order
  1092. to minimize buffer bloat.
  1093. .PP
  1094. It is difficult to balance memory usage, cache bloat & duplication, and
  1095. performance.
  1096. Ideally mergerfs would be able to disable caching for the files it
  1097. reads/writes but allow page caching for itself.
  1098. That would limit the FUSE overhead.
  1099. However, there isn\[aq]t a good way to achieve this.
  1100. It would need to open all files with O_DIRECT which places limitations
  1101. on the what underlying filesystems would be supported and complicates
  1102. the code.
  1103. .PP
  1104. kernel documenation:
  1105. https://www.kernel.org/doc/Documentation/filesystems/fuse\-io.txt
  1106. .SS entry & attribute caching
  1107. .PP
  1108. Given the relatively high cost of FUSE due to the kernel <\-> userspace
  1109. round trips there are kernel side caches for file entries and
  1110. attributes.
  1111. The entry cache limits the \f[C]lookup\f[] calls to mergerfs which ask
  1112. if a file exists.
  1113. The attribute cache limits the need to make \f[C]getattr\f[] calls to
  1114. mergerfs which provide file attributes (mode, size, type, etc.).
  1115. As with the page cache these should not be used if the underlying
  1116. filesystems are being manipulated at the same time as it could lead to
  1117. odd behavior or data corruption.
  1118. The options for setting these are \f[C]cache.entry\f[] and
  1119. \f[C]cache.negative_entry\f[] for the entry cache and
  1120. \f[C]cache.attr\f[] for the attributes cache.
  1121. \f[C]cache.negative_entry\f[] refers to the timeout for negative
  1122. responses to lookups (non\-existant files).
  1123. .SS policy caching
  1124. .PP
  1125. Policies are run every time a function (with a policy as mentioned
  1126. above) is called.
  1127. These policies can be expensive depending on mergerfs\[aq] setup and
  1128. client usage patterns.
  1129. Generally we wouldn\[aq]t want to cache policy results because it may
  1130. result in stale responses if the underlying drives are used directly.
  1131. .PP
  1132. The \f[C]open\f[] policy cache will cache the result of an \f[C]open\f[]
  1133. policy for a particular input for \f[C]cache.open\f[] seconds or until
  1134. the file is unlinked.
  1135. Each file close (release) will randomly chose to clean up the cache of
  1136. expired entries.
  1137. .PP
  1138. This cache is really only useful in cases where you have a large number
  1139. of branches and \f[C]open\f[] is called on the same files repeatedly
  1140. (like \f[B]Transmission\f[] which opens and closes a file on every
  1141. read/write presumably to keep file handle usage low).
  1142. .SS statfs caching
  1143. .PP
  1144. Of the syscalls used by mergerfs in policies the \f[C]statfs\f[] /
  1145. \f[C]statvfs\f[] call is perhaps the most expensive.
  1146. It\[aq]s used to find out the available space of a drive and whether it
  1147. is mounted read\-only.
  1148. Depending on the setup and usage pattern these queries can be relatively
  1149. costly.
  1150. When \f[C]cache.statfs\f[] is enabled all calls to \f[C]statfs\f[] by a
  1151. policy will be cached for the number of seconds its set to.
  1152. .PP
  1153. Example: If the create policy is \f[C]mfs\f[] and the timeout is 60 then
  1154. for that 60 seconds the same drive will be returned as the target for
  1155. creates because the available space won\[aq]t be updated for that time.
  1156. .SS symlink caching
  1157. .PP
  1158. As of version 4.20 Linux supports symlink caching.
  1159. Significant performance increases can be had in workloads which use a
  1160. lot of symlinks.
  1161. Setting \f[C]cache.symlinks=true\f[] will result in requesting symlink
  1162. caching from the kernel only if supported.
  1163. As a result its safe to enable it on systems prior to 4.20.
  1164. That said it is disabled by default for now.
  1165. You can see if caching is enabled by querying the xattr
  1166. \f[C]user.mergerfs.cache.symlinks\f[] but given it must be requested at
  1167. startup you can not change it at runtime.
  1168. .SS readdir caching
  1169. .PP
  1170. As of version 4.20 Linux supports readdir caching.
  1171. This can have a significant impact on directory traversal.
  1172. Especially when combined with entry (\f[C]cache.entry\f[]) and attribute
  1173. (\f[C]cache.attr\f[]) caching.
  1174. Setting \f[C]cache.readdir=true\f[] will result in requesting readdir
  1175. caching from the kernel on each \f[C]opendir\f[].
  1176. If the kernel doesn\[aq]t support readdir caching setting the option to
  1177. \f[C]true\f[] has no effect.
  1178. This option is configuarable at runtime via xattr
  1179. \f[C]user.mergerfs.cache.readdir\f[].
  1180. .SS writeback caching
  1181. .PP
  1182. writeback caching is a technique for improving write speeds by batching
  1183. writes at a faster device and then bulk writing to the slower device.
  1184. With FUSE the kernel will wait for a number of writes to be made and
  1185. then send it to the filesystem as one request.
  1186. mergerfs currently uses a slightly modified and vendored libfuse 2.9.7
  1187. which does not support writeback caching.
  1188. However, a prototype port to libfuse 3.x has been made and the writeback
  1189. cache appears to work as expected (though performance improvements
  1190. greatly depend on the way the client app writes data).
  1191. Once the port is complete and thoroughly tested writeback caching will
  1192. be available.
  1193. .SS tiered caching
  1194. .PP
  1195. Some storage technologies support what some call "tiered" caching.
  1196. The placing of usually smaller, faster storage as a transparent cache to
  1197. larger, slower storage.
  1198. NVMe, SSD, Optane in front of traditional HDDs for instance.
  1199. .PP
  1200. MergerFS does not natively support any sort of tiered caching.
  1201. Most users have no use for such a feature and its inclusion would
  1202. complicate the code.
  1203. However, there are a few situations where a cache drive could help with
  1204. a typical mergerfs setup.
  1205. .IP "1." 3
  1206. Fast network, slow drives, many readers: You\[aq]ve a 10+Gbps network
  1207. with many readers and your regular drives can\[aq]t keep up.
  1208. .IP "2." 3
  1209. Fast network, slow drives, small\[aq]ish bursty writes: You have a
  1210. 10+Gbps network and wish to transfer amounts of data less than your
  1211. cache drive but wish to do so quickly.
  1212. .PP
  1213. With #1 its arguable if you should be using mergerfs at all.
  1214. RAID would probably be the better solution.
  1215. If you\[aq]re going to use mergerfs there are other tactics that may
  1216. help: spreading the data across drives (see the mergerfs.dup tool) and
  1217. setting \f[C]func.open=rand\f[], using \f[C]symlinkify\f[], or using
  1218. dm\-cache or a similar technology to add tiered cache to the underlying
  1219. device.
  1220. .PP
  1221. With #2 one could use dm\-cache as well but there is another solution
  1222. which requires only mergerfs and a cronjob.
  1223. .IP "1." 3
  1224. Create 2 mergerfs pools.
  1225. One which includes just the slow drives and one which has both the fast
  1226. drives (SSD,NVME,etc.) and slow drives.
  1227. .IP "2." 3
  1228. The \[aq]cache\[aq] pool should have the cache drives listed first.
  1229. .IP "3." 3
  1230. The best \f[C]create\f[] policies to use for the \[aq]cache\[aq] pool
  1231. would probably be \f[C]ff\f[], \f[C]epff\f[], \f[C]lfs\f[], or
  1232. \f[C]eplfs\f[].
  1233. The latter two under the assumption that the cache drive(s) are far
  1234. smaller than the backing drives.
  1235. If using path preserving policies remember that you\[aq]ll need to
  1236. manually create the core directories of those paths you wish to be
  1237. cached.
  1238. Be sure the permissions are in sync.
  1239. Use \f[C]mergerfs.fsck\f[] to check / correct them.
  1240. You could also tag the slow drives as \f[C]=NC\f[] though that\[aq]d
  1241. mean if the cache drives fill you\[aq]d get "out of space" errors.
  1242. .IP "4." 3
  1243. Enable \f[C]moveonenospc\f[] and set \f[C]minfreespace\f[]
  1244. appropriately.
  1245. Perhaps setting \f[C]minfreespace\f[] to the size of the largest cache
  1246. drive.
  1247. .IP "5." 3
  1248. Set your programs to use the cache pool.
  1249. .IP "6." 3
  1250. Save one of the below scripts or create you\[aq]re own.
  1251. .IP "7." 3
  1252. Use \f[C]cron\f[] (as root) to schedule the command at whatever
  1253. frequency is appropriate for your workflow.
  1254. .SS time based expiring
  1255. .PP
  1256. Move files from cache to backing pool based only on the last time the
  1257. file was accessed.
  1258. Replace \f[C]\-atime\f[] with \f[C]\-amin\f[] if you want minutes rather
  1259. than days.
  1260. May want to use the \f[C]fadvise\f[] / \f[C]\-\-drop\-cache\f[] version
  1261. of rsync or run rsync with the tool "nocache".
  1262. .IP
  1263. .nf
  1264. \f[C]
  1265. #!/bin/bash
  1266. if\ [\ $#\ !=\ 3\ ];\ then
  1267. \ \ echo\ "usage:\ $0\ <cache\-drive>\ <backing\-pool>\ <days\-old>"
  1268. \ \ exit\ 1
  1269. fi
  1270. CACHE="${1}"
  1271. BACKING="${2}"
  1272. N=${3}
  1273. find\ "${CACHE}"\ \-type\ f\ \-atime\ +${N}\ \-printf\ \[aq]%P\\n\[aq]\ |\ \\
  1274. \ \ rsync\ \-\-files\-from=\-\ \-axqHAXWES\ \-\-preallocate\ \-\-remove\-source\-files\ "${CACHE}/"\ "${BACKING}/"
  1275. \f[]
  1276. .fi
  1277. .SS percentage full expiring
  1278. .PP
  1279. Move the oldest file from the cache to the backing pool.
  1280. Continue till below percentage threshold.
  1281. .IP
  1282. .nf
  1283. \f[C]
  1284. #!/bin/bash
  1285. if\ [\ $#\ !=\ 3\ ];\ then
  1286. \ \ echo\ "usage:\ $0\ <cache\-drive>\ <backing\-pool>\ <percentage>"
  1287. \ \ exit\ 1
  1288. fi
  1289. CACHE="${1}"
  1290. BACKING="${2}"
  1291. PERCENTAGE=${3}
  1292. set\ \-o\ errexit
  1293. while\ [\ $(df\ \-\-output=pcent\ "${CACHE}"\ |\ grep\ \-v\ Use\ |\ cut\ \-d\[aq]%\[aq]\ \-f1)\ \-gt\ ${PERCENTAGE}\ ]
  1294. do
  1295. \ \ \ \ FILE=$(find\ "${CACHE}"\ \-type\ f\ \-printf\ \[aq]%A\@\ %P\\n\[aq]\ |\ \\
  1296. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sort\ |\ \\
  1297. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ head\ \-n\ 1\ |\ \\
  1298. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cut\ \-d\[aq]\ \[aq]\ \-f2\-)
  1299. \ \ \ \ test\ \-n\ "${FILE}"
  1300. \ \ \ \ rsync\ \-axqHAXWES\ \-\-preallocate\ \-\-remove\-source\-files\ "${CACHE}/./${FILE}"\ "${BACKING}/"
  1301. done
  1302. \f[]
  1303. .fi
  1304. .SH TIPS / NOTES
  1305. .IP \[bu] 2
  1306. \f[B]use_ino\f[] will only work when used with mergerfs 2.18.0 and
  1307. above.
  1308. .IP \[bu] 2
  1309. Run mergerfs as \f[C]root\f[] (with \f[B]allow_other\f[]) unless
  1310. you\[aq]re merging paths which are owned by the same user otherwise
  1311. strange permission issues may arise.
  1312. .IP \[bu] 2
  1313. https://github.com/trapexit/backup\-and\-recovery\-howtos : A set of
  1314. guides / howtos on creating a data storage system, backing it up,
  1315. maintaining it, and recovering from failure.
  1316. .IP \[bu] 2
  1317. If you don\[aq]t see some directories and files you expect in a merged
  1318. point or policies seem to skip drives be sure the user has permission to
  1319. all the underlying directories.
  1320. Use \f[C]mergerfs.fsck\f[] to audit the drive for out of sync
  1321. permissions.
  1322. .IP \[bu] 2
  1323. Do \f[B]not\f[] use \f[C]cache.files=off\f[] or \f[C]direct_io\f[] if
  1324. you expect applications (such as rtorrent) to
  1325. mmap (http://linux.die.net/man/2/mmap) files.
  1326. Shared mmap is not currently supported in FUSE w/ \f[C]direct_io\f[]
  1327. enabled.
  1328. Enabling \f[C]dropcacheonclose\f[] is recommended when
  1329. \f[C]cache.files=partial|full|auto\-full\f[] or
  1330. \f[C]direct_io=false\f[].
  1331. .IP \[bu] 2
  1332. Since POSIX functions give only a singular error or success its
  1333. difficult to determine the proper behavior when applying the function to
  1334. multiple targets.
  1335. \f[B]mergerfs\f[] will return an error only if all attempts of an action
  1336. fail.
  1337. Any success will lead to a success returned.
  1338. This means however that some odd situations may arise.
  1339. .IP \[bu] 2
  1340. Kodi (http://kodi.tv), Plex (http://plex.tv),
  1341. Subsonic (http://subsonic.org), etc.
  1342. can use directory mtime (http://linux.die.net/man/2/stat) to more
  1343. efficiently determine whether to scan for new content rather than simply
  1344. performing a full scan.
  1345. If using the default \f[B]getattr\f[] policy of \f[B]ff\f[] its possible
  1346. those programs will miss an update on account of it returning the first
  1347. directory found\[aq]s \f[B]stat\f[] info and its a later directory on
  1348. another mount which had the \f[B]mtime\f[] recently updated.
  1349. To fix this you will want to set \f[B]func.getattr=newest\f[].
  1350. Remember though that this is just \f[B]stat\f[].
  1351. If the file is later \f[B]open\f[]\[aq]ed or \f[B]unlink\f[]\[aq]ed and
  1352. the policy is different for those then a completely different file or
  1353. directory could be acted on.
  1354. .IP \[bu] 2
  1355. Some policies mixed with some functions may result in strange behaviors.
  1356. Not that some of these behaviors and race conditions couldn\[aq]t happen
  1357. outside \f[B]mergerfs\f[] but that they are far more likely to occur on
  1358. account of the attempt to merge together multiple sources of data which
  1359. could be out of sync due to the different policies.
  1360. .IP \[bu] 2
  1361. For consistency its generally best to set \f[B]category\f[] wide
  1362. policies rather than individual \f[B]func\f[]\[aq]s.
  1363. This will help limit the confusion of tools such as
  1364. rsync (http://linux.die.net/man/1/rsync).
  1365. However, the flexibility is there if needed.
  1366. .SH KNOWN ISSUES / BUGS
  1367. .SS directory mtime is not being updated
  1368. .PP
  1369. Remember that the default policy for \f[C]getattr\f[] is \f[C]ff\f[].
  1370. The information for the first directory found will be returned.
  1371. If it wasn\[aq]t the directory which had been updated then it will
  1372. appear outdated.
  1373. .PP
  1374. The reason this is the default is because any other policy would be more
  1375. expensive and for many applications it is unnecessary.
  1376. To always return the directory with the most recent mtime or a faked
  1377. value based on all found would require a scan of all drives.
  1378. .PP
  1379. If you always want the directory information from the one with the most
  1380. recent mtime then use the \f[C]newest\f[] policy for \f[C]getattr\f[].
  1381. .SS \f[C]mv\ /mnt/pool/foo\ /mnt/disk1/foo\f[] removes \f[C]foo\f[]
  1382. .PP
  1383. This is not a bug.
  1384. .PP
  1385. Run in verbose mode to better undertand what\[aq]s happening:
  1386. .IP
  1387. .nf
  1388. \f[C]
  1389. $\ mv\ \-v\ /mnt/pool/foo\ /mnt/disk1/foo
  1390. copied\ \[aq]/mnt/pool/foo\[aq]\ \->\ \[aq]/mnt/disk1/foo\[aq]
  1391. removed\ \[aq]/mnt/pool/foo\[aq]
  1392. $\ ls\ /mnt/pool/foo
  1393. ls:\ cannot\ access\ \[aq]/mnt/pool/foo\[aq]:\ No\ such\ file\ or\ directory
  1394. \f[]
  1395. .fi
  1396. .PP
  1397. \f[C]mv\f[], when working across devices, is copying the source to
  1398. target and then removing the source.
  1399. Since the source \f[B]is\f[] the target in this case, depending on the
  1400. unlink policy, it will remove the just copied file and other files
  1401. across the branches.
  1402. .PP
  1403. If you want to move files to one drive just copy them there and use
  1404. mergerfs.dedup to clean up the old paths or manually remove them from
  1405. the branches directly.
  1406. .SS cached memory appears greater than it should be
  1407. .PP
  1408. Use \f[C]cache.files=off\f[] or \f[C]direct_io=true\f[].
  1409. See the section on page caching.
  1410. .SS NFS clients returning ESTALE / Stale file handle
  1411. .PP
  1412. Be sure to use \f[C]noforget\f[] and \f[C]use_ino\f[] arguments.
  1413. .SS NFS clients don\[aq]t work
  1414. .PP
  1415. Some NFS clients appear to fail when a mergerfs mount is exported.
  1416. Kodi in particular seems to have issues.
  1417. .PP
  1418. Try enabling the \f[C]use_ino\f[] option.
  1419. Some have reported that it fixes the issue.
  1420. .SS rtorrent fails with ENODEV (No such device)
  1421. .PP
  1422. Be sure to set \f[C]cache.files=partial|full|auto\-full\f[] or turn off
  1423. \f[C]direct_io\f[].
  1424. rtorrent and some other applications use
  1425. mmap (http://linux.die.net/man/2/mmap) to read and write to files and
  1426. offer no failback to traditional methods.
  1427. FUSE does not currently support mmap while using \f[C]direct_io\f[].
  1428. There may be a performance penalty on writes with \f[C]direct_io\f[] off
  1429. as well as the problem of double caching but it\[aq]s the only way to
  1430. get such applications to work.
  1431. If the performance loss is too high for other apps you can mount
  1432. mergerfs twice.
  1433. Once with \f[C]direct_io\f[] enabled and one without it.
  1434. Be sure to set \f[C]dropcacheonclose=true\f[] if not using
  1435. \f[C]direct_io\f[].
  1436. .SS rtorrent fails with files >= 4GiB
  1437. .PP
  1438. This is a kernel bug with mmap and FUSE on 32bit platforms.
  1439. A fix should become available for all LTS releases.
  1440. .PP
  1441. https://marc.info/?l=linux\-fsdevel&m=155550785230874&w=2
  1442. .SS Plex doesn\[aq]t work with mergerfs
  1443. .PP
  1444. It does.
  1445. If you\[aq]re trying to put Plex\[aq]s config / metadata on mergerfs you
  1446. have to leave \f[C]direct_io\f[] off because Plex is using sqlite which
  1447. apparently needs mmap.
  1448. mmap doesn\[aq]t work with \f[C]direct_io\f[].
  1449. To fix this place the data elsewhere or disable \f[C]direct_io\f[] (with
  1450. \f[C]dropcacheonclose=true\f[]).
  1451. .PP
  1452. If the issue is that scanning doesn\[aq]t seem to pick up media then be
  1453. sure to set \f[C]func.getattr=newest\f[] as mentioned above.
  1454. .SS mmap performance is really bad
  1455. .PP
  1456. There is a bug (https://lkml.org/lkml/2016/3/16/260) in caching which
  1457. affects overall performance of mmap through FUSE in Linux 4.x kernels.
  1458. It is fixed in 4.4.10 and 4.5.4 (https://lkml.org/lkml/2016/5/11/59).
  1459. .SS When a program tries to move or rename a file it fails
  1460. .PP
  1461. Please read the section above regarding rename & link (#rename--link).
  1462. .PP
  1463. The problem is that many applications do not properly handle
  1464. \f[C]EXDEV\f[] errors which \f[C]rename\f[] and \f[C]link\f[] may return
  1465. even though they are perfectly valid situations which do not indicate
  1466. actual drive or OS errors.
  1467. The error will only be returned by mergerfs if using a path preserving
  1468. policy as described in the policy section above.
  1469. If you do not care about path preservation simply change the mergerfs
  1470. policy to the non\-path preserving version.
  1471. For example: \f[C]\-o\ category.create=mfs\f[]
  1472. .PP
  1473. Ideally the offending software would be fixed and it is recommended that
  1474. if you run into this problem you contact the software\[aq]s author and
  1475. request proper handling of \f[C]EXDEV\f[] errors.
  1476. .SS Samba: Moving files / directories fails
  1477. .PP
  1478. Workaround: Copy the file/directory and then remove the original rather
  1479. than move.
  1480. .PP
  1481. This isn\[aq]t an issue with Samba but some SMB clients.
  1482. GVFS\-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed
  1483. to handle certain error codes correctly.
  1484. Particularly \f[B]STATUS_NOT_SAME_DEVICE\f[] which comes from the
  1485. \f[B]EXDEV\f[] which is returned by \f[B]rename\f[] when the call is
  1486. crossing mount points.
  1487. When a program gets an \f[B]EXDEV\f[] it needs to explicitly take an
  1488. alternate action to accomplish it\[aq]s goal.
  1489. In the case of \f[B]mv\f[] or similar it tries \f[B]rename\f[] and on
  1490. \f[B]EXDEV\f[] falls back to a manual copying of data between the two
  1491. locations and unlinking the source.
  1492. In these older versions of GVFS\-fuse if it received \f[B]EXDEV\f[] it
  1493. would translate that into \f[B]EIO\f[].
  1494. This would cause \f[B]mv\f[] or most any application attempting to move
  1495. files around on that SMB share to fail with a IO error.
  1496. .PP
  1497. GVFS\-fuse v1.22.0 (https://bugzilla.gnome.org/show_bug.cgi?id=734568)
  1498. and above fixed this issue but a large number of systems use the older
  1499. release.
  1500. On Ubuntu the version can be checked by issuing
  1501. \f[C]apt\-cache\ showpkg\ gvfs\-fuse\f[].
  1502. Most distros released in 2015 seem to have the updated release and will
  1503. work fine but older systems may not.
  1504. Upgrading gvfs\-fuse or the distro in general will address the problem.
  1505. .PP
  1506. In Apple\[aq]s MacOSX 10.9 they replaced Samba (client and server) with
  1507. their own product.
  1508. It appears their new client does not handle \f[B]EXDEV\f[] either and
  1509. responds similar to older release of gvfs on Linux.
  1510. .SS Trashing files occasionally fails
  1511. .PP
  1512. This is the same issue as with Samba.
  1513. \f[C]rename\f[] returns \f[C]EXDEV\f[] (in our case that will really
  1514. only happen with path preserving policies like \f[C]epmfs\f[]) and the
  1515. software doesn\[aq]t handle the situtation well.
  1516. This is unfortunately a common failure of software which moves files
  1517. around.
  1518. The standard indicates that an implementation \f[C]MAY\f[] choose to
  1519. support non\-user home directory trashing of files (which is a
  1520. \f[C]MUST\f[]).
  1521. The implementation \f[C]MAY\f[] also support "top directory trashes"
  1522. which many probably do.
  1523. .PP
  1524. To create a \f[C]$topdir/.Trash\f[] directory as defined in the standard
  1525. use the mergerfs\-tools (https://github.com/trapexit/mergerfs-tools)
  1526. tool \f[C]mergerfs.mktrash\f[].
  1527. .SS tar: Directory renamed before its status could be extracted
  1528. .PP
  1529. Make sure to use the \f[C]use_ino\f[] option.
  1530. .SS Supplemental user groups
  1531. .PP
  1532. Due to the overhead of
  1533. getgroups/setgroups (http://linux.die.net/man/2/setgroups) mergerfs
  1534. utilizes a cache.
  1535. This cache is opportunistic and per thread.
  1536. Each thread will query the supplemental groups for a user when that
  1537. particular thread needs to change credentials and will keep that data
  1538. for the lifetime of the thread.
  1539. This means that if a user is added to a group it may not be picked up
  1540. without the restart of mergerfs.
  1541. However, since the high level FUSE API\[aq]s (at least the standard
  1542. version) thread pool dynamically grows and shrinks it\[aq]s possible
  1543. that over time a thread will be killed and later a new thread with no
  1544. cache will start and query the new data.
  1545. .PP
  1546. The gid cache uses fixed storage to simplify the design and be
  1547. compatible with older systems which may not have C++11 compilers.
  1548. There is enough storage for 256 users\[aq] supplemental groups.
  1549. Each user is allowed upto 32 supplemental groups.
  1550. Linux >= 2.6.3 allows upto 65535 groups per user but most other *nixs
  1551. allow far less.
  1552. NFS allowing only 16.
  1553. The system does handle overflow gracefully.
  1554. If the user has more than 32 supplemental groups only the first 32 will
  1555. be used.
  1556. If more than 256 users are using the system when an uncached user is
  1557. found it will evict an existing user\[aq]s cache at random.
  1558. So long as there aren\[aq]t more than 256 active users this should be
  1559. fine.
  1560. If either value is too low for your needs you will have to modify
  1561. \f[C]gidcache.hpp\f[] to increase the values.
  1562. Note that doing so will increase the memory needed by each thread.
  1563. .SS mergerfs or libfuse crashing
  1564. .PP
  1565. \f[B]NOTE:\f[] as of mergerfs 2.22.0 it includes the most recent version
  1566. of libfuse (or requires libfuse\-2.9.7) so any crash should be reported.
  1567. For older releases continue reading...
  1568. .PP
  1569. If suddenly the mergerfs mount point disappears and
  1570. \f[C]Transport\ endpoint\ is\ not\ connected\f[] is returned when
  1571. attempting to perform actions within the mount directory \f[B]and\f[]
  1572. the version of libfuse (use \f[C]mergerfs\ \-v\f[] to find the version)
  1573. is older than \f[C]2.9.4\f[] its likely due to a bug in libfuse.
  1574. Affected versions of libfuse can be found in Debian Wheezy, Ubuntu
  1575. Precise and others.
  1576. .PP
  1577. In order to fix this please install newer versions of libfuse.
  1578. If using a Debian based distro (Debian,Ubuntu,Mint) you can likely just
  1579. install newer versions of
  1580. libfuse (https://packages.debian.org/unstable/libfuse2) and
  1581. fuse (https://packages.debian.org/unstable/fuse) from the repo of a
  1582. newer release.
  1583. .SS mergerfs appears to be crashing or exiting
  1584. .PP
  1585. There seems to be an issue with Linux version \f[C]4.9.0\f[] and above
  1586. in which an invalid message appears to be transmitted to libfuse (used
  1587. by mergerfs) causing it to exit.
  1588. No messages will be printed in any logs as its not a proper crash.
  1589. Debugging of the issue is still ongoing and can be followed via the
  1590. fuse\-devel
  1591. thread (https://sourceforge.net/p/fuse/mailman/message/35662577).
  1592. .SS mergerfs under heavy load and memory preasure leads to kernel panic
  1593. .PP
  1594. https://lkml.org/lkml/2016/9/14/527
  1595. .IP
  1596. .nf
  1597. \f[C]
  1598. [25192.515454]\ kernel\ BUG\ at\ /build/linux\-a2WvEb/linux\-4.4.0/mm/workingset.c:346!
  1599. [25192.517521]\ invalid\ opcode:\ 0000\ [#1]\ SMP
  1600. [25192.519602]\ Modules\ linked\ in:\ netconsole\ ip6t_REJECT\ nf_reject_ipv6\ ipt_REJECT\ nf_reject_ipv4\ configfs\ binfmt_misc\ veth\ bridge\ stp\ llc\ nf_conntrack_ipv6\ nf_defrag_ipv6\ xt_conntrack\ ip6table_filter\ ip6_tables\ xt_multiport\ iptable_filter\ ipt_MASQUERADE\ nf_nat_masquerade_ipv4\ xt_comment\ xt_nat\ iptable_nat\ nf_conntrack_ipv4\ nf_defrag_ipv4\ nf_nat_ipv4\ nf_nat\ nf_conntrack\ xt_CHECKSUM\ xt_tcpudp\ iptable_mangle\ ip_tables\ x_tables\ intel_rapl\ x86_pkg_temp_thermal\ intel_powerclamp\ eeepc_wmi\ asus_wmi\ coretemp\ sparse_keymap\ kvm_intel\ ppdev\ kvm\ irqbypass\ mei_me\ 8250_fintek\ input_leds\ serio_raw\ parport_pc\ tpm_infineon\ mei\ shpchp\ mac_hid\ parport\ lpc_ich\ autofs4\ drbg\ ansi_cprng\ dm_crypt\ algif_skcipher\ af_alg\ btrfs\ raid456\ async_raid6_recov\ async_memcpy\ async_pq\ async_xor\ async_tx\ xor\ raid6_pq\ libcrc32c\ raid0\ multipath\ linear\ raid10\ raid1\ i915\ crct10dif_pclmul\ crc32_pclmul\ aesni_intel\ i2c_algo_bit\ aes_x86_64\ drm_kms_helper\ lrw\ gf128mul\ glue_helper\ ablk_helper\ syscopyarea\ cryptd\ sysfillrect\ sysimgblt\ fb_sys_fops\ drm\ ahci\ r8169\ libahci\ mii\ wmi\ fjes\ video\ [last\ unloaded:\ netconsole]
  1601. [25192.540910]\ CPU:\ 2\ PID:\ 63\ Comm:\ kswapd0\ Not\ tainted\ 4.4.0\-36\-generic\ #55\-Ubuntu
  1602. [25192.543411]\ Hardware\ name:\ System\ manufacturer\ System\ Product\ Name/P8H67\-M\ PRO,\ BIOS\ 3904\ 04/27/2013
  1603. [25192.545840]\ task:\ ffff88040cae6040\ ti:\ ffff880407488000\ task.ti:\ ffff880407488000
  1604. [25192.548277]\ RIP:\ 0010:[<ffffffff811ba501>]\ \ [<ffffffff811ba501>]\ shadow_lru_isolate+0x181/0x190
  1605. [25192.550706]\ RSP:\ 0018:ffff88040748bbe0\ \ EFLAGS:\ 00010002
  1606. [25192.553127]\ RAX:\ 0000000000001c81\ RBX:\ ffff8802f91ee928\ RCX:\ ffff8802f91eeb38
  1607. [25192.555544]\ RDX:\ ffff8802f91ee938\ RSI:\ ffff8802f91ee928\ RDI:\ ffff8804099ba2c0
  1608. [25192.557914]\ RBP:\ ffff88040748bc08\ R08:\ 000000000001a7b6\ R09:\ 000000000000003f
  1609. [25192.560237]\ R10:\ 000000000001a750\ R11:\ 0000000000000000\ R12:\ ffff8804099ba2c0
  1610. [25192.562512]\ R13:\ ffff8803157e9680\ R14:\ ffff8803157e9668\ R15:\ ffff8804099ba2c8
  1611. [25192.564724]\ FS:\ \ 0000000000000000(0000)\ GS:ffff88041f280000(0000)\ knlGS:0000000000000000
  1612. [25192.566990]\ CS:\ \ 0010\ DS:\ 0000\ ES:\ 0000\ CR0:\ 0000000080050033
  1613. [25192.569201]\ CR2:\ 00007ffabb690000\ CR3:\ 0000000001e0a000\ CR4:\ 00000000000406e0
  1614. [25192.571419]\ Stack:
  1615. [25192.573550]\ \ ffff8804099ba2c0\ ffff88039e4f86f0\ ffff8802f91ee928\ ffff8804099ba2c8
  1616. [25192.575695]\ \ ffff88040748bd08\ ffff88040748bc58\ ffffffff811b99bf\ 0000000000000052
  1617. [25192.577814]\ \ 0000000000000000\ ffffffff811ba380\ 000000000000008a\ 0000000000000080
  1618. [25192.579947]\ Call\ Trace:
  1619. [25192.582022]\ \ [<ffffffff811b99bf>]\ __list_lru_walk_one.isra.3+0x8f/0x130
  1620. [25192.584137]\ \ [<ffffffff811ba380>]\ ?\ memcg_drain_all_list_lrus+0x190/0x190
  1621. [25192.586165]\ \ [<ffffffff811b9a83>]\ list_lru_walk_one+0x23/0x30
  1622. [25192.588145]\ \ [<ffffffff811ba544>]\ scan_shadow_nodes+0x34/0x50
  1623. [25192.590074]\ \ [<ffffffff811a0e9d>]\ shrink_slab.part.40+0x1ed/0x3d0
  1624. [25192.591985]\ \ [<ffffffff811a53da>]\ shrink_zone+0x2ca/0x2e0
  1625. [25192.593863]\ \ [<ffffffff811a64ce>]\ kswapd+0x51e/0x990
  1626. [25192.595737]\ \ [<ffffffff811a5fb0>]\ ?\ mem_cgroup_shrink_node_zone+0x1c0/0x1c0
  1627. [25192.597613]\ \ [<ffffffff810a0808>]\ kthread+0xd8/0xf0
  1628. [25192.599495]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  1629. [25192.601335]\ \ [<ffffffff8182e34f>]\ ret_from_fork+0x3f/0x70
  1630. [25192.603193]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  1631. \f[]
  1632. .fi
  1633. .PP
  1634. There is a bug in the kernel.
  1635. A work around appears to be turning off \f[C]splice\f[].
  1636. Don\[aq]t add the \f[C]splice_*\f[] arguments or add
  1637. \f[C]no_splice_write,no_splice_move,no_splice_read\f[].
  1638. This, however, is not guaranteed to work.
  1639. .SS rm: fts_read failed: No such file or directory
  1640. .PP
  1641. NOTE: This is only relevant to mergerfs versions at or below v2.25.x and
  1642. should not occur in more recent versions.
  1643. See the notes on \f[C]unlink\f[].
  1644. .PP
  1645. Not \f[I]really\f[] a bug.
  1646. The FUSE library will move files when asked to delete them as a way to
  1647. deal with certain edge cases and then later delete that file when its
  1648. clear the file is no longer needed.
  1649. This however can lead to two issues.
  1650. One is that these hidden files are noticed by \f[C]rm\ \-rf\f[] or
  1651. \f[C]find\f[] when scanning directories and they may try to remove them
  1652. and they might have disappeared already.
  1653. There is nothing \f[I]wrong\f[] about this happening but it can be
  1654. annoying.
  1655. The second issue is that a directory might not be able to removed on
  1656. account of the hidden file being still there.
  1657. .PP
  1658. Using the \f[B]hard_remove\f[] option will make it so these temporary
  1659. files are not used and files are deleted immedately.
  1660. That has a side effect however.
  1661. Files which are unlinked and then they are still used (in certain forms)
  1662. will result in an error (ENOENT).
  1663. .SH FAQ
  1664. .SS How well does mergerfs scale? Is it "production ready?"
  1665. .PP
  1666. Users have reported running mergerfs on everything from a Raspberry Pi
  1667. to dual socket Xeon systems with >20 cores.
  1668. I\[aq]m aware of at least a few companies which use mergerfs in
  1669. production.
  1670. Open Media Vault (https://www.openmediavault.org) includes mergerfs is
  1671. it\[aq]s sole solution for pooling drives.
  1672. .SS Can mergerfs be used with drives which already have data / are in
  1673. use?
  1674. .PP
  1675. Yes.
  1676. MergerFS is a proxy and does \f[B]NOT\f[] interfere with the normal form
  1677. or function of the drives / mounts / paths it manages.
  1678. .PP
  1679. MergerFS is \f[B]not\f[] a traditional filesystem.
  1680. MergerFS is \f[B]not\f[] RAID.
  1681. It does \f[B]not\f[] manipulate the data that passes through it.
  1682. It does \f[B]not\f[] shard data across drives.
  1683. It merely shards some \f[B]behavior\f[] and aggregates others.
  1684. .SS Can mergerfs be removed without affecting the data?
  1685. .PP
  1686. See the previous question\[aq]s answer.
  1687. .SS Do hard links work?
  1688. .PP
  1689. Yes.
  1690. You need to use \f[C]use_ino\f[] to support proper reporting of inodes.
  1691. .PP
  1692. What mergerfs does not do is fake hard links across branches.
  1693. Read the section "rename & link" for how it works.
  1694. .SS Does mergerfs support CoW / copy\-on\-write?
  1695. .PP
  1696. Not in the sense of a filesystem like BTRFS or ZFS nor in the overlayfs
  1697. or aufs sense.
  1698. It does offer a
  1699. cow\-shell (http://manpages.ubuntu.com/manpages/bionic/man1/cow-shell.1.html)
  1700. like hard link breaking (copy to temp file then rename over original)
  1701. which can be useful when wanting to save space by hardlinking duplicate
  1702. files but wish to treat each name as if it were a unique and separate
  1703. file.
  1704. .SS Why can\[aq]t I see my files / directories?
  1705. .PP
  1706. It\[aq]s almost always a permissions issue.
  1707. Unlike mhddfs, which runs as root and attempts to access content as
  1708. such, mergerfs always changes it\[aq]s credentials to that of the
  1709. caller.
  1710. This means that if the user does not have access to a file or directory
  1711. than neither will mergerfs.
  1712. However, because mergerfs is creating a union of paths it may be able to
  1713. read some files and directories on one drive but not another resulting
  1714. in an incomplete set.
  1715. .PP
  1716. Whenever you run into a split permission issue (seeing some but not all
  1717. files) try using
  1718. mergerfs.fsck (https://github.com/trapexit/mergerfs-tools) tool to check
  1719. for and fix the mismatch.
  1720. If you aren\[aq]t seeing anything at all be sure that the basic
  1721. permissions are correct.
  1722. The user and group values are correct and that directories have their
  1723. executable bit set.
  1724. A common mistake by users new to Linux is to \f[C]chmod\ \-R\ 644\f[]
  1725. when they should have \f[C]chmod\ \-R\ u=rwX,go=rX\f[].
  1726. .PP
  1727. If using a network filesystem such as NFS, SMB, CIFS (Samba) be sure to
  1728. pay close attention to anything regarding permissioning and users.
  1729. Root squashing and user translation for instance has bitten a few
  1730. mergerfs users.
  1731. Some of these also affect the use of mergerfs from container platforms
  1732. such as Docker.
  1733. .SS Why is only one drive being used?
  1734. .PP
  1735. Are you using a path preserving policy?
  1736. The default policy for file creation is \f[C]epmfs\f[].
  1737. That means only the drives with the path preexisting will be considered
  1738. when creating a file.
  1739. If you don\[aq]t care about where files and directories are created you
  1740. likely shouldn\[aq]t be using a path preserving policy and instead
  1741. something like \f[C]mfs\f[].
  1742. .PP
  1743. This can be especially apparent when filling an empty pool from an
  1744. external source.
  1745. If you do want path preservation you\[aq]ll need to perform the manual
  1746. act of creating paths on the drives you want the data to land on before
  1747. transfering your data.
  1748. Setting \f[C]func.mkdir=epall\f[] can simplify managing path
  1749. perservation for \f[C]create\f[].
  1750. .SS Why was libfuse embedded into mergerfs?
  1751. .IP "1." 3
  1752. A significant number of users use mergerfs on distros with old versions
  1753. of libfuse which have serious bugs.
  1754. Requiring updated versions of libfuse on those distros isn\[aq]t
  1755. pratical (no package offered, user inexperience, etc.).
  1756. The only practical way to provide a stable runtime on those systems was
  1757. to "vendor" / embed the library into the project.
  1758. .IP "2." 3
  1759. mergerfs was written to use the high level API.
  1760. There are a number of limitations in the HLAPI that make certain
  1761. features difficult or impossible to implement.
  1762. While some of these features could be patched into newer versions of
  1763. libfuse without breaking the public API some of them would require hacky
  1764. code to provide backwards compatibility.
  1765. While it may still be worth working with upstream to address these
  1766. issues in future versions, since the library needs to be vendored for
  1767. stability and compatibility reasons it is preferable / easier to modify
  1768. the API.
  1769. Longer term the plan is to rewrite mergerfs to use the low level API.
  1770. .SS Why did support for system libfuse get removed?
  1771. .PP
  1772. See above first.
  1773. .PP
  1774. If/when mergerfs is rewritten to use the low\-level API then it\[aq]ll
  1775. be plausible to support system libfuse but till then its simply too much
  1776. work to manage the differences across the versions.
  1777. .SS Why use mergerfs over mhddfs?
  1778. .PP
  1779. mhddfs is no longer maintained and has some known stability and security
  1780. issues (see below).
  1781. MergerFS provides a superset of mhddfs\[aq] features and should offer
  1782. the same or maybe better performance.
  1783. .PP
  1784. Below is an example of mhddfs and mergerfs setup to work similarly.
  1785. .PP
  1786. \f[C]mhddfs\ \-o\ mlimit=4G,allow_other\ /mnt/drive1,/mnt/drive2\ /mnt/pool\f[]
  1787. .PP
  1788. \f[C]mergerfs\ \-o\ minfreespace=4G,allow_other,category.create=ff\ /mnt/drive1:/mnt/drive2\ /mnt/pool\f[]
  1789. .SS Why use mergerfs over aufs?
  1790. .PP
  1791. aufs is mostly abandoned and no longer available in many distros.
  1792. .PP
  1793. While aufs can offer better peak performance mergerfs provides more
  1794. configurability and is generally easier to use.
  1795. mergerfs however does not offer the overlay / copy\-on\-write (CoW)
  1796. features which aufs and overlayfs have.
  1797. .SS Why use mergerfs over unionfs?
  1798. .PP
  1799. UnionFS is more like aufs then mergerfs in that it offers overlay / CoW
  1800. features.
  1801. If you\[aq]re just looking to create a union of drives and want
  1802. flexibility in file/directory placement then mergerfs offers that
  1803. whereas unionfs is more for overlaying RW filesystems over RO ones.
  1804. .SS Why use mergerfs over LVM/ZFS/BTRFS/RAID0 drive concatenation /
  1805. striping?
  1806. .PP
  1807. With simple JBOD / drive concatenation / stripping / RAID0 a single
  1808. drive failure will result in full pool failure.
  1809. mergerfs performs a similar behavior without the possibility of
  1810. catastrophic failure and the difficulties in recovery.
  1811. Drives may fail however all other data will continue to be accessable.
  1812. .PP
  1813. When combined with something like SnapRaid (http://www.snapraid.it)
  1814. and/or an offsite backup solution you can have the flexibilty of JBOD
  1815. without the single point of failure.
  1816. .SS Why use mergerfs over ZFS?
  1817. .PP
  1818. MergerFS is not intended to be a replacement for ZFS.
  1819. MergerFS is intended to provide flexible pooling of arbitrary drives
  1820. (local or remote), of arbitrary sizes, and arbitrary filesystems.
  1821. For \f[C]write\ once,\ read\ many\f[] usecases such as bulk media
  1822. storage.
  1823. Where data integrity and backup is managed in other ways.
  1824. In that situation ZFS can introduce major maintance and cost burdens as
  1825. described
  1826. here (http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html).
  1827. .SS Can drives be written to directly? Outside of mergerfs while pooled?
  1828. .PP
  1829. Yes, however its not recommended to use the same file from within the
  1830. pool and from without at the same time.
  1831. Especially if using caching of any kind (cache.files, cache.entry,
  1832. cache.attr, cache.negative_entry, cache.symlinks, cache.readdir, etc.).
  1833. .SS Why do I get an "out of space" / "no space left on device" / ENOSPC
  1834. error even though there appears to be lots of space available?
  1835. .PP
  1836. First make sure you\[aq]ve read the sections above about policies, path
  1837. preservation, branch filtering, and the options \f[B]minfreespace\f[],
  1838. \f[B]moveonenospc\f[], \f[B]statfs\f[], and \f[B]statfs_ignore\f[].
  1839. .PP
  1840. mergerfs is simply presenting a union of the content within multiple
  1841. branches.
  1842. The reported free space is an aggregate of space available within the
  1843. pool (behavior modified by \f[B]statfs\f[] and \f[B]statfs_ignore\f[]).
  1844. It does not represent a contiguous space.
  1845. In the same way that read\-only filesystems, those with quotas, or
  1846. reserved space report the full theoretical space available.
  1847. .PP
  1848. Due to path preservation, branch tagging, read\-only status, and
  1849. \f[B]minfreespace\f[] settings it is perfectly valid that
  1850. \f[C]ENOSPC\f[] / "out of space" / "no space left on device" be
  1851. returned.
  1852. It is doing what was asked of it: filtering possible branches due to
  1853. those settings.
  1854. Only one error can be returned and if one of the reasons for filtering a
  1855. branch was \f[B]minfreespace\f[] then it will be returned as such.
  1856. \f[B]moveonenospc\f[] is only relevant to writing a file which is too
  1857. large for the drive its currently on.
  1858. .PP
  1859. It is also possible that the filesystem selected has run out of inodes.
  1860. Use \f[C]df\ \-i\f[] to list the total and available inodes per
  1861. filesystem.
  1862. .PP
  1863. If you don\[aq]t care about path preservation then simply change the
  1864. \f[C]create\f[] policy to one which isn\[aq]t.
  1865. \f[C]mfs\f[] is probably what most are looking for.
  1866. The reason its not default is because it was originally set to
  1867. \f[C]epmfs\f[] and changing it now would change people\[aq]s setup.
  1868. Such a setting change will likely occur in mergerfs 3.
  1869. .SS Can mergerfs mounts be exported over NFS?
  1870. .PP
  1871. Yes.
  1872. Due to current usage of libfuse by mergerfs and how NFS interacts with
  1873. it it is necessary to add \f[C]noforget\f[] to mergerfs options to keep
  1874. from getting "stale file handle" errors.
  1875. .PP
  1876. Some clients (Kodi) have issues in which the contents of the NFS mount
  1877. will not be presented but users have found that enabling the
  1878. \f[C]use_ino\f[] option often fixes that problem.
  1879. .SS Can mergerfs mounts be exported over Samba / SMB?
  1880. .PP
  1881. Yes.
  1882. While some users have reported problems it appears to always be related
  1883. to how Samba is setup in relation to permissions.
  1884. .SS How are inodes calculated?
  1885. .PP
  1886. mergerfs\-inode = (original\-inode | (device\-id << 32))
  1887. .PP
  1888. While \f[C]ino_t\f[] is 64 bits only a few filesystems use more than 32.
  1889. Similarly, while \f[C]dev_t\f[] is also 64 bits it was traditionally 16
  1890. bits.
  1891. Bitwise or\[aq]ing them together should work most of the time.
  1892. While totally unique inodes are preferred the overhead which would be
  1893. needed does not seem to outweighted by the benefits.
  1894. .PP
  1895. While atypical, yes, inodes can be reused and not refer to the same
  1896. file.
  1897. The internal id used to reference a file in FUSE is different from the
  1898. inode value presented.
  1899. The former is the \f[C]nodeid\f[] and is actually a tuple of
  1900. (nodeid,generation).
  1901. That tuple is not user facing.
  1902. The inode is merely metadata passed through the kernel and found using
  1903. the \f[C]stat\f[] family of calls or \f[C]readdir\f[].
  1904. .PP
  1905. From FUSE docs regarding \f[C]use_ino\f[]:
  1906. .IP
  1907. .nf
  1908. \f[C]
  1909. Honor\ the\ st_ino\ field\ in\ the\ functions\ getattr()\ and
  1910. fill_dir().\ This\ value\ is\ used\ to\ fill\ in\ the\ st_ino\ field
  1911. in\ the\ stat(2),\ lstat(2),\ fstat(2)\ functions\ and\ the\ d_ino
  1912. field\ in\ the\ readdir(2)\ function.\ The\ filesystem\ does\ not
  1913. have\ to\ guarantee\ uniqueness,\ however\ some\ applications
  1914. rely\ on\ this\ value\ being\ unique\ for\ the\ whole\ filesystem.
  1915. Note\ that\ this\ does\ *not*\ affect\ the\ inode\ that\ libfuse
  1916. and\ the\ kernel\ use\ internally\ (also\ called\ the\ "nodeid").
  1917. \f[]
  1918. .fi
  1919. .SS I notice massive slowdowns of writes over NFS
  1920. .PP
  1921. Due to how NFS works and interacts with FUSE when not using
  1922. \f[C]cache.files=off\f[] or \f[C]direct_io\f[] its possible that a
  1923. getxattr for \f[C]security.capability\f[] will be issued prior to any
  1924. write.
  1925. This will usually result in a massive slowdown for writes.
  1926. Using \f[C]cache.files=off\f[] or \f[C]direct_io\f[] will keep this from
  1927. happening (and generally good to enable unless you need the features it
  1928. disables) but the \f[C]security_capability\f[] option can also help by
  1929. short circuiting the call and returning \f[C]ENOATTR\f[].
  1930. .PP
  1931. You could also set \f[C]xattr\f[] to \f[C]noattr\f[] or \f[C]nosys\f[]
  1932. to short circuit or stop all xattr requests.
  1933. .SS What are these .fuse_hidden files?
  1934. .PP
  1935. NOTE: mergerfs >= 2.26.0 will not have these temporary files.
  1936. See the notes on \f[C]unlink\f[].
  1937. .PP
  1938. When not using \f[B]hard_remove\f[] libfuse will create
  1939. \&.fuse_hiddenXXXXXXXX files when an opened file is unlinked.
  1940. This is to simplify "use after unlink" usecases.
  1941. There is a possibility these files end up being picked up by software
  1942. scanning directories and not ignoring hidden files.
  1943. This is rarely a problem but a solution is in the works.
  1944. .PP
  1945. The files are cleaned up once the file is finally closed.
  1946. Only if mergerfs crashes or is killed would they be left around.
  1947. They are safe to remove as they are already unlinked files.
  1948. .SS It\[aq]s mentioned that there are some security issues with mhddfs.
  1949. What are they? How does mergerfs address them?
  1950. .PP
  1951. mhddfs (https://github.com/trapexit/mhddfs) manages running as
  1952. \f[B]root\f[] by calling
  1953. getuid() (https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  1954. and if it returns \f[B]0\f[] then it will
  1955. chown (http://linux.die.net/man/1/chown) the file.
  1956. Not only is that a race condition but it doesn\[aq]t handle other
  1957. situations.
  1958. Rather than attempting to simulate POSIX ACL behavior the proper way to
  1959. manage this is to use seteuid (http://linux.die.net/man/2/seteuid) and
  1960. setegid (http://linux.die.net/man/2/setegid), in effect becoming the
  1961. user making the original call, and perform the action as them.
  1962. This is what mergerfs does and why mergerfs should always run as root.
  1963. .PP
  1964. In Linux setreuid syscalls apply only to the thread.
  1965. GLIBC hides this away by using realtime signals to inform all threads to
  1966. change credentials.
  1967. Taking after \f[B]Samba\f[], mergerfs uses
  1968. \f[B]syscall(SYS_setreuid,...)\f[] to set the callers credentials for
  1969. that thread only.
  1970. Jumping back to \f[B]root\f[] as necessary should escalated privileges
  1971. be needed (for instance: to clone paths between drives).
  1972. .PP
  1973. For non\-Linux systems mergerfs uses a read\-write lock and changes
  1974. credentials only when necessary.
  1975. If multiple threads are to be user X then only the first one will need
  1976. to change the processes credentials.
  1977. So long as the other threads need to be user X they will take a readlock
  1978. allowing multiple threads to share the credentials.
  1979. Once a request comes in to run as user Y that thread will attempt a
  1980. write lock and change to Y\[aq]s credentials when it can.
  1981. If the ability to give writers priority is supported then that flag will
  1982. be used so threads trying to change credentials don\[aq]t starve.
  1983. This isn\[aq]t the best solution but should work reasonably well
  1984. assuming there are few users.
  1985. .SH PERFORMANCE TWEAKING
  1986. .PP
  1987. NOTE: be sure to read about these features before changing them
  1988. .IP \[bu] 2
  1989. enable (or disable) \f[C]splice_move\f[], \f[C]splice_read\f[], and
  1990. \f[C]splice_write\f[]
  1991. .IP \[bu] 2
  1992. increase cache timeouts \f[C]cache.attr\f[], \f[C]cache.entry\f[],
  1993. \f[C]cache.negative_entry\f[]
  1994. .IP \[bu] 2
  1995. enable (or disable) page caching (\f[C]cache.files\f[])
  1996. .IP \[bu] 2
  1997. enable \f[C]cache.open\f[]
  1998. .IP \[bu] 2
  1999. enable \f[C]cache.statfs\f[]
  2000. .IP \[bu] 2
  2001. enable \f[C]cache.symlinks\f[]
  2002. .IP \[bu] 2
  2003. enable \f[C]cache.readdir\f[]
  2004. .IP \[bu] 2
  2005. change the number of worker threads
  2006. .IP \[bu] 2
  2007. disable \f[C]security_capability\f[] and/or \f[C]xattr\f[]
  2008. .IP \[bu] 2
  2009. disable \f[C]posix_acl\f[]
  2010. .IP \[bu] 2
  2011. disable \f[C]async_read\f[]
  2012. .IP \[bu] 2
  2013. test theoretical performance using \f[C]nullrw\f[] or mounting a ram
  2014. disk
  2015. .IP \[bu] 2
  2016. use \f[C]symlinkify\f[] if your data is largely static
  2017. .IP \[bu] 2
  2018. use tiered cache drives
  2019. .IP \[bu] 2
  2020. use lvm and lvm cache to place a SSD in front of your HDDs (howto
  2021. coming)
  2022. .SH SUPPORT
  2023. .PP
  2024. Filesystems are very complex and difficult to debug.
  2025. mergerfs, while being just a proxy of sorts, is also very difficult to
  2026. debug given the large number of possible settings it can have itself and
  2027. the massive number of environments it can run in.
  2028. When reporting on a suspected issue \f[B]please, please\f[] include as
  2029. much of the below information as possible otherwise it will be difficult
  2030. or impossible to diagnose.
  2031. Also please make sure to read all of the above documentation as it
  2032. includes nearly every known system or user issue previously encountered.
  2033. .SS Information to include in bug reports
  2034. .IP \[bu] 2
  2035. Version of mergerfs: \f[C]mergerfs\ \-V\f[]
  2036. .IP \[bu] 2
  2037. mergerfs settings: from \f[C]/etc/fstab\f[] or command line execution
  2038. .IP \[bu] 2
  2039. Version of Linux: \f[C]uname\ \-a\f[]
  2040. .IP \[bu] 2
  2041. Versions of any additional software being used
  2042. .IP \[bu] 2
  2043. List of drives, their filesystems, and sizes (before and after issue):
  2044. \f[C]df\ \-h\f[]
  2045. .IP \[bu] 2
  2046. A \f[C]strace\f[] of the app having problems:
  2047. .IP \[bu] 2
  2048. \f[C]strace\ \-f\ \-o\ /tmp/app.strace.txt\ <cmd>\f[]
  2049. .IP \[bu] 2
  2050. A \f[C]strace\f[] of mergerfs while the program is trying to do whatever
  2051. it\[aq]s failing to do:
  2052. .IP \[bu] 2
  2053. \f[C]strace\ \-f\ \-p\ <mergerfsPID>\ \-o\ /tmp/mergerfs.strace.txt\f[]
  2054. .IP \[bu] 2
  2055. \f[B]Precise\f[] directions on replicating the issue.
  2056. Do not leave \f[B]anything\f[] out.
  2057. .IP \[bu] 2
  2058. Try to recreate the problem in the simplist way using standard programs.
  2059. .SS Contact / Issue submission
  2060. .IP \[bu] 2
  2061. github.com: https://github.com/trapexit/mergerfs/issues
  2062. .IP \[bu] 2
  2063. email: trapexit\@spawn.link
  2064. .IP \[bu] 2
  2065. twitter: https://twitter.com/_trapexit
  2066. .IP \[bu] 2
  2067. reddit: https://www.reddit.com/user/trapexit
  2068. .IP \[bu] 2
  2069. discord: https://discord.gg/MpAr69V
  2070. .SS Support development
  2071. .PP
  2072. This software is free to use and released under a very liberal license.
  2073. That said if you like this software and would like to support its
  2074. development donations are welcome.
  2075. .IP \[bu] 2
  2076. PayPal: https://paypal.me/trapexit
  2077. .IP \[bu] 2
  2078. Patreon: https://www.patreon.com/trapexit
  2079. .IP \[bu] 2
  2080. SubscribeStar: https://www.subscribestar.com/trapexit
  2081. .IP \[bu] 2
  2082. Bitcoin (BTC): 12CdMhEPQVmjz3SSynkAEuD5q9JmhTDCZA
  2083. .IP \[bu] 2
  2084. Bitcoin Cash (BCH): 1AjPqZZhu7GVEs6JFPjHmtsvmDL4euzMzp
  2085. .IP \[bu] 2
  2086. Ethereum (ETH): 0x09A166B11fCC127324C7fc5f1B572255b3046E94
  2087. .IP \[bu] 2
  2088. Litecoin (LTC): LXAsq6yc6zYU3EbcqyWtHBrH1Ypx4GjUjm
  2089. .SH LINKS
  2090. .IP \[bu] 2
  2091. https://spawn.link
  2092. .IP \[bu] 2
  2093. https://github.com/trapexit/mergerfs
  2094. .IP \[bu] 2
  2095. https://github.com/trapexit/mergerfs\-tools
  2096. .IP \[bu] 2
  2097. https://github.com/trapexit/scorch
  2098. .IP \[bu] 2
  2099. https://github.com/trapexit/bbf
  2100. .IP \[bu] 2
  2101. https://github.com/trapexit/backup\-and\-recovery\-howtos
  2102. .SH AUTHORS
  2103. Antonio SJ Musumeci <trapexit@spawn.link>.