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.

2553 lines
98 KiB

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