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.

2880 lines
107 KiB

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