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.

2830 lines
105 KiB

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