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.

2823 lines
105 KiB

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