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.

2153 lines
82 KiB

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