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.

1778 lines
66 KiB

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