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.

2729 lines
102 KiB

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