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.

1284 lines
47 KiB

9 years ago
9 years ago
8 years ago
8 years ago
9 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. .\"t
  2. .\" Automatically generated by Pandoc 1.16.0.2
  3. .\"
  4. .TH "mergerfs" "1" "2017\-05\-26" "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> <srcmounts> <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 OPTIONS
  43. .SS mount options
  44. .IP \[bu] 2
  45. \f[B]defaults\f[]: a shortcut for FUSE\[aq]s \f[B]atomic_o_trunc\f[],
  46. \f[B]auto_cache\f[], \f[B]big_writes\f[], \f[B]default_permissions\f[],
  47. \f[B]splice_move\f[], \f[B]splice_read\f[], and \f[B]splice_write\f[].
  48. These options seem to provide the best performance.
  49. .IP \[bu] 2
  50. \f[B]direct_io\f[]: causes FUSE to bypass caching which can increase
  51. write speeds at the detriment of reads.
  52. Note that not enabling \f[C]direct_io\f[] will cause double caching of
  53. files and therefore less memory for caching generally.
  54. However, \f[C]mmap\f[] does not work when \f[C]direct_io\f[] is enabled.
  55. .IP \[bu] 2
  56. \f[B]minfreespace\f[]: the minimum space value used for creation
  57. policies.
  58. Understands \[aq]K\[aq], \[aq]M\[aq], and \[aq]G\[aq] to represent
  59. kilobyte, megabyte, and gigabyte respectively.
  60. (default: 4G)
  61. .IP \[bu] 2
  62. \f[B]moveonenospc\f[]: when enabled (set to \f[B]true\f[]) if a
  63. \f[B]write\f[] fails with \f[B]ENOSPC\f[] or \f[B]EDQUOT\f[] a scan of
  64. all drives will be done looking for the drive with most free space which
  65. is at least the size of the file plus the amount which failed to write.
  66. An attempt to move the file to that drive will occur (keeping all
  67. metadata possible) and if successful the original is unlinked and the
  68. write retried.
  69. (default: false)
  70. .IP \[bu] 2
  71. \f[B]use_ino\f[]: causes mergerfs to supply file/directory inodes rather
  72. than libfuse.
  73. While not a default it is generally recommended it be enabled so that
  74. hard linked files share the same inode value.
  75. .IP \[bu] 2
  76. \f[B]dropcacheonclose\f[]: when a file is requested to be closed call
  77. \f[C]posix_fadvise\f[] on it first to instruct the kernel that we no
  78. longer need the data and it can drop its cache.
  79. Recommended when \f[B]direct_io\f[] is not enabled to limit double
  80. caching.
  81. (default: false)
  82. .IP \[bu] 2
  83. \f[B]symlinkify\f[]: when enabled (set to \f[B]true\f[]) and a file is
  84. not writable and its mtime or ctime is older than
  85. \f[B]symlinkify_timeout\f[] files will be reported as symlinks to the
  86. original files.
  87. Please read more below before using.
  88. (default: false)
  89. .IP \[bu] 2
  90. \f[B]symlinkify_timeout\f[]: time to wait, in seconds, to activate the
  91. \f[B]symlinkify\f[] behavior.
  92. (default: 3600)
  93. .IP \[bu] 2
  94. \f[B]nullrw\f[]: turns reads and writes into no\-ops.
  95. The request will succeed but do nothing.
  96. Useful for benchmarking mergerfs.
  97. (default: false)
  98. .IP \[bu] 2
  99. \f[B]ignorepponrename\f[]: ignore path preserving on rename.
  100. Typically rename and link act differently depending on the policy of
  101. \f[C]create\f[] (read below).
  102. Enabling this will cause rename and link to always use the non\-path
  103. preserving behavior.
  104. This means files, when renamed or linked, will stay on the same drive.
  105. .IP \[bu] 2
  106. \f[B]threads\f[]: number of threads to use in multithreaded mode.
  107. When set to zero (the default) it will attempt to discover and use the
  108. number of logical cores.
  109. If the lookup fails it will fall back to using 4.
  110. If the thread count is set negative it will look up the number of cores
  111. then divide by the absolute value.
  112. ie.
  113. threads=\-2 on an 8 core machine will result in 8 / 2 = 4 threads.
  114. There will always be at least 1 thread.
  115. NOTE: higher number of threads increases parallelism but usually
  116. decreases throughput.
  117. .IP \[bu] 2
  118. \f[B]fsname\f[]: sets the name of the filesystem as seen in
  119. \f[B]mount\f[], \f[B]df\f[], etc.
  120. Defaults to a list of the source paths concatenated together with the
  121. longest common prefix removed.
  122. .IP \[bu] 2
  123. \f[B]func.<func>=<policy>\f[]: sets the specific FUSE function\[aq]s
  124. policy.
  125. See below for the list of value types.
  126. Example: \f[B]func.getattr=newest\f[]
  127. .IP \[bu] 2
  128. \f[B]category.<category>=<policy>\f[]: Sets policy of all FUSE functions
  129. in the provided category.
  130. Example: \f[B]category.create=mfs\f[]
  131. .PP
  132. \f[B]NOTE:\f[] Options are evaluated in the order listed so if the
  133. options are \f[B]func.rmdir=rand,category.action=ff\f[] the
  134. \f[B]action\f[] category setting will override the \f[B]rmdir\f[]
  135. setting.
  136. .SS srcmounts
  137. .PP
  138. The srcmounts (source mounts) argument is a colon (\[aq]:\[aq])
  139. delimited list of paths to be included in the pool.
  140. It does not matter if the paths are on the same or different drives nor
  141. does it matter the filesystem.
  142. Used and available space will not be duplicated for paths on the same
  143. device and any features which aren\[aq]t supported by the underlying
  144. filesystem (such as file attributes or extended attributes) will return
  145. the appropriate errors.
  146. .PP
  147. To make it easier to include multiple source mounts mergerfs supports
  148. globbing (http://linux.die.net/man/7/glob).
  149. \f[B]The globbing tokens MUST be escaped when using via the shell else
  150. the shell itself will expand it.\f[]
  151. .IP
  152. .nf
  153. \f[C]
  154. $\ mergerfs\ \-o\ defaults,allow_other,use_ino\ /mnt/disk\\*:/mnt/cdrom\ /media/drives
  155. \f[]
  156. .fi
  157. .PP
  158. The above line will use all mount points in /mnt prefixed with
  159. \f[B]disk\f[] and the \f[B]cdrom\f[].
  160. .PP
  161. To have the pool mounted at boot or otherwise accessable from related
  162. tools use \f[B]/etc/fstab\f[].
  163. .IP
  164. .nf
  165. \f[C]
  166. #\ <file\ system>\ \ \ \ \ \ \ \ <mount\ point>\ \ <type>\ \ \ \ \ \ \ \ \ <options>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ <dump>\ \ <pass>
  167. /mnt/disk*:/mnt/cdrom\ \ /media/drives\ \ fuse.mergerfs\ \ defaults,allow_other,use_ino\ \ 0\ \ \ \ \ \ \ 0
  168. \f[]
  169. .fi
  170. .PP
  171. \f[B]NOTE:\f[] the globbing is done at mount or xattr update time (see
  172. below).
  173. If a new directory is added matching the glob after the fact it will not
  174. be automatically included.
  175. .PP
  176. \f[B]NOTE:\f[] for mounting via \f[B]fstab\f[] to work you must have
  177. \f[B]mount.fuse\f[] installed.
  178. For Ubuntu/Debian it is included in the \f[B]fuse\f[] package.
  179. .SS symlinkify
  180. .PP
  181. Due to the levels of indirection introduced by mergerfs and the
  182. underlying technology FUSE there can be varying levels of performance
  183. degredation.
  184. This feature will turn non\-directories which are not writable into
  185. symlinks to the original file found by the \f[C]readlink\f[] policy
  186. after the mtime and ctime are older than the timeout.
  187. .PP
  188. \f[B]WARNING:\f[] The current implementation has a known issue in which
  189. if the file is open and being used when the file is converted to a
  190. symlink then the application which has that file open will receive an
  191. error when using it.
  192. This is unlikely to occur in practice but is something to keep in mind.
  193. .PP
  194. \f[B]WARNING:\f[] Some backup solutions, such as CrashPlan, do not
  195. backup the target of a symlink.
  196. If using this feature it will be necessary to point any backup software
  197. to the original drives or configure the software to follow symlinks if
  198. such an option is available.
  199. Alternatively create two mounts.
  200. One for backup and one for general consumption.
  201. .SS nullrw
  202. .PP
  203. Due to how FUSE works there is an overhead to all requests made to a
  204. FUSE filesystem.
  205. Meaning that even a simple passthrough will have some slowdown.
  206. However, generally the overhead is minimal in comparison to the cost of
  207. the underlying I/O.
  208. By disabling the underlying I/O we can test the theoretical performance
  209. boundries.
  210. .PP
  211. By enabling \f[C]nullrw\f[] mergerfs will work as it always does
  212. \f[B]except\f[] that all reads and writes will be no\-ops.
  213. A write will succeed (the size of the write will be returned as if it
  214. were successful) but mergerfs does nothing with the data it was given.
  215. Similarly a read will return the size requested but won\[aq]t touch the
  216. buffer.
  217. .PP
  218. Example:
  219. .IP
  220. .nf
  221. \f[C]
  222. $\ dd\ if=/dev/zero\ of=/path/to/mergerfs/mount/benchmark\ ibs=1M\ obs=512\ count=1024
  223. 1024+0\ records\ in
  224. 2097152+0\ records\ out
  225. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 15.4067\ s,\ 69.7\ MB/s
  226. $\ dd\ if=/dev/zero\ of=/path/to/mergerfs/mount/benchmark\ ibs=1M\ obs=1M\ count=1024
  227. 1024+0\ records\ in
  228. 1024+0\ records\ out
  229. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 0.219585\ s,\ 4.9\ GB/s
  230. $\ dd\ if=/path/to/mergerfs/mount/benchmark\ of=/dev/null\ bs=512\ count=102400
  231. 102400+0\ records\ in
  232. 102400+0\ records\ out
  233. 52428800\ bytes\ (52\ MB,\ 50\ MiB)\ copied,\ 0.757991\ s,\ 69.2\ MB/s
  234. $\ dd\ if=/path/to/mergerfs/mount/benchmark\ of=/dev/null\ bs=1M\ count=1024
  235. 1024+0\ records\ in
  236. 1024+0\ records\ out
  237. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 0.18405\ s,\ 5.8\ GB/s
  238. \f[]
  239. .fi
  240. .PP
  241. It\[aq]s important to test with different \f[C]obs\f[] (output block
  242. size) values since the relative overhead is greater with smaller values.
  243. As you can see above the size of a read or write can massively impact
  244. theoretical performance.
  245. If an application performs much worse through mergerfs it could very
  246. well be that it doesn\[aq]t optimally size its read and write requests.
  247. .SH FUNCTIONS / POLICIES / CATEGORIES
  248. .PP
  249. The POSIX filesystem API has a number of functions.
  250. \f[B]creat\f[], \f[B]stat\f[], \f[B]chown\f[], etc.
  251. In mergerfs these functions are grouped into 3 categories:
  252. \f[B]action\f[], \f[B]create\f[], and \f[B]search\f[].
  253. Functions and categories can be assigned a policy which dictates how
  254. \f[B]mergerfs\f[] behaves.
  255. Any policy can be assigned to a function or category though some may not
  256. be very useful in practice.
  257. For instance: \f[B]rand\f[] (random) may be useful for file creation
  258. (create) but could lead to very odd behavior if used for \f[C]chmod\f[]
  259. (though only if there were more than one copy of the file).
  260. .PP
  261. Policies, when called to create, will ignore drives which are readonly.
  262. This allows for readonly and read/write drives to be mixed together.
  263. Note that the drive must be explicitly mounted with the \f[B]ro\f[]
  264. mount option for this to work.
  265. .SS Function / Category classifications
  266. .PP
  267. .TS
  268. tab(@);
  269. lw(7.9n) lw(62.1n).
  270. T{
  271. Category
  272. T}@T{
  273. FUSE Functions
  274. T}
  275. _
  276. T{
  277. action
  278. T}@T{
  279. chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate,
  280. unlink, utimens
  281. T}
  282. T{
  283. create
  284. T}@T{
  285. create, mkdir, mknod, symlink
  286. T}
  287. T{
  288. search
  289. T}@T{
  290. access, getattr, getxattr, ioctl, listxattr, open, readlink
  291. T}
  292. T{
  293. N/A
  294. T}@T{
  295. fallocate, fgetattr, fsync, ftruncate, ioctl, read, readdir, release,
  296. statfs, write
  297. T}
  298. .TE
  299. .PP
  300. Due to FUSE limitations \f[B]ioctl\f[] behaves differently if its acting
  301. on a directory.
  302. It\[aq]ll use the \f[B]getattr\f[] policy to find and open the directory
  303. before issuing the \f[B]ioctl\f[].
  304. In other cases where something may be searched (to confirm a directory
  305. exists across all source mounts) \f[B]getattr\f[] will also be used.
  306. .SS Path Preservation
  307. .PP
  308. Policies, as described below, are of two core types.
  309. \f[C]path\ preserving\f[] and \f[C]non\-path\ preserving\f[].
  310. .PP
  311. All policies which start with \f[C]ep\f[] (\f[B]epff\f[],
  312. \f[B]eplfs\f[], \f[B]eplus\f[], \f[B]epmfs\f[], \f[B]eprand\f[]) are
  313. \f[C]path\ preserving\[aq].\f[]ep\f[C]stands\ for\ \[aq]existing\ path\f[].
  314. .PP
  315. As the descriptions explain a path preserving policy will only consider
  316. drives where the relative path being accessed already exists.
  317. .PP
  318. When using non\-path preserving policies where something is created
  319. paths will be copied to target drives as necessary.
  320. .SS Policy descriptions
  321. .PP
  322. .TS
  323. tab(@);
  324. lw(16.6n) lw(53.4n).
  325. T{
  326. Policy
  327. T}@T{
  328. Description
  329. T}
  330. _
  331. T{
  332. all
  333. T}@T{
  334. Search category: acts like \f[B]ff\f[].
  335. Action category: apply to all found.
  336. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  337. \f[B]symlink\f[] it will apply to all found.
  338. \f[B]create\f[] works like \f[B]ff\f[].
  339. It will exclude readonly drives and those with free space less than
  340. \f[B]minfreespace\f[].
  341. T}
  342. T{
  343. epall (existing path, all)
  344. T}@T{
  345. Search category: acts like \f[B]epff\f[].
  346. Action category: apply to all found.
  347. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  348. \f[B]symlink\f[] it will apply to all existing paths found.
  349. \f[B]create\f[] works like \f[B]epff\f[].
  350. Excludes readonly drives and those with free space less than
  351. \f[B]minfreespace\f[].
  352. T}
  353. T{
  354. epff (existing path, first found)
  355. T}@T{
  356. Given the order of the drives, as defined at mount time or configured at
  357. runtime, act on the first one found where the relative path already
  358. exists.
  359. For \f[B]create\f[] category functions it will exclude readonly drives
  360. and those with free space less than \f[B]minfreespace\f[] (unless there
  361. is no other option).
  362. Falls back to \f[B]ff\f[].
  363. T}
  364. T{
  365. eplfs (existing path, least free space)
  366. T}@T{
  367. Of all the drives on which the relative path exists choose the drive
  368. with the least free space.
  369. For \f[B]create\f[] category functions it will exclude readonly drives
  370. and those with free space less than \f[B]minfreespace\f[].
  371. Falls back to \f[B]lfs\f[].
  372. T}
  373. T{
  374. eplus (existing path, least used space)
  375. T}@T{
  376. Of all the drives on which the relative path exists choose the drive
  377. with the least used space.
  378. For \f[B]create\f[] category functions it will exclude readonly drives
  379. and those with free space less than \f[B]minfreespace\f[].
  380. Falls back to \f[B]lus\f[].
  381. T}
  382. T{
  383. epmfs (existing path, most free space)
  384. T}@T{
  385. Of all the drives on which the relative path exists choose the drive
  386. with the most free space.
  387. For \f[B]create\f[] category functions it will exclude readonly drives
  388. and those with free space less than \f[B]minfreespace\f[].
  389. Falls back to \f[B]mfs\f[].
  390. T}
  391. T{
  392. eprand (existing path, random)
  393. T}@T{
  394. Calls \f[B]epall\f[] and then randomizes.
  395. Otherwise behaves the same as \f[B]epall\f[].
  396. T}
  397. T{
  398. erofs
  399. T}@T{
  400. Exclusively return \f[B]\-1\f[] with \f[B]errno\f[] set to
  401. \f[B]EROFS\f[] (Read\-only filesystem).
  402. By setting \f[B]create\f[] functions to this you can in effect turn the
  403. filesystem mostly readonly.
  404. T}
  405. T{
  406. ff (first found)
  407. T}@T{
  408. Given the order of the drives, as defined at mount time or configured at
  409. runtime, act on the first one found.
  410. For \f[B]create\f[] category functions it will exclude readonly drives
  411. and those with free space less than \f[B]minfreespace\f[] (unless there
  412. is no other option).
  413. T}
  414. T{
  415. lfs (least free space)
  416. T}@T{
  417. Pick the drive with the least available free space.
  418. For \f[B]create\f[] category functions it will exclude readonly drives
  419. and those with free space less than \f[B]minfreespace\f[].
  420. Falls back to \f[B]mfs\f[].
  421. T}
  422. T{
  423. lus (least used space)
  424. T}@T{
  425. Pick the drive with the least used space.
  426. For \f[B]create\f[] category functions it will exclude readonly drives
  427. and those with free space less than \f[B]minfreespace\f[].
  428. Falls back to \f[B]mfs\f[].
  429. T}
  430. T{
  431. mfs (most free space)
  432. T}@T{
  433. Pick the drive with the most available free space.
  434. For \f[B]create\f[] category functions it will exclude readonly drives.
  435. Falls back to \f[B]ff\f[].
  436. T}
  437. T{
  438. newest
  439. T}@T{
  440. Pick the file / directory with the largest mtime.
  441. For \f[B]create\f[] category functions it will exclude readonly drives
  442. and those with free space less than \f[B]minfreespace\f[] (unless there
  443. is no other option).
  444. T}
  445. T{
  446. rand (random)
  447. T}@T{
  448. Calls \f[B]all\f[] and then randomizes.
  449. T}
  450. .TE
  451. .SS Defaults
  452. .PP
  453. .TS
  454. tab(@);
  455. l l.
  456. T{
  457. Category
  458. T}@T{
  459. Policy
  460. T}
  461. _
  462. T{
  463. action
  464. T}@T{
  465. all
  466. T}
  467. T{
  468. create
  469. T}@T{
  470. epmfs
  471. T}
  472. T{
  473. search
  474. T}@T{
  475. ff
  476. T}
  477. .TE
  478. .SS rename & link
  479. .PP
  480. \f[B]NOTE:\f[] If you\[aq]re receiving errors from software when files
  481. are moved / renamed then you should consider changing the create policy
  482. to one which is \f[B]not\f[] path preserving, enabling
  483. \f[C]ignorepponrename\f[], or contacting the author of the offending
  484. software and requesting that \f[C]EXDEV\f[] be properly handled.
  485. .PP
  486. rename (http://man7.org/linux/man-pages/man2/rename.2.html) is a tricky
  487. function in a merged system.
  488. Under normal situations rename only works within a single filesystem or
  489. device.
  490. If a rename can\[aq]t be done atomically due to the source and
  491. destination paths existing on different mount points it will return
  492. \f[B]\-1\f[] with \f[B]errno = EXDEV\f[] (cross device).
  493. .PP
  494. Originally mergerfs would return EXDEV whenever a rename was requested
  495. which was cross directory in any way.
  496. This made the code simple and was technically complient with POSIX
  497. requirements.
  498. However, many applications fail to handle EXDEV at all and treat it as a
  499. normal error or otherwise handle it poorly.
  500. Such apps include: gvfsd\-fuse v1.20.3 and prior, Finder / CIFS/SMB
  501. client in Apple OSX 10.9+, NZBGet, Samba\[aq]s recycling bin feature.
  502. .PP
  503. As a result a compromise was made in order to get most software to work
  504. while still obeying mergerfs\[aq] policies.
  505. Below is the rather complicated logic.
  506. .IP \[bu] 2
  507. If using a \f[B]create\f[] policy which tries to preserve directory
  508. paths (epff,eplfs,eplus,epmfs)
  509. .IP \[bu] 2
  510. Using the \f[B]rename\f[] policy get the list of files to rename
  511. .IP \[bu] 2
  512. For each file attempt rename:
  513. .RS 2
  514. .IP \[bu] 2
  515. If failure with ENOENT run \f[B]create\f[] policy
  516. .IP \[bu] 2
  517. If create policy returns the same drive as currently evaluating then
  518. clone the path
  519. .IP \[bu] 2
  520. Re\-attempt rename
  521. .RE
  522. .IP \[bu] 2
  523. If \f[B]any\f[] of the renames succeed the higher level rename is
  524. considered a success
  525. .IP \[bu] 2
  526. If \f[B]no\f[] renames succeed the first error encountered will be
  527. returned
  528. .IP \[bu] 2
  529. On success:
  530. .RS 2
  531. .IP \[bu] 2
  532. Remove the target from all drives with no source file
  533. .IP \[bu] 2
  534. Remove the source from all drives which failed to rename
  535. .RE
  536. .IP \[bu] 2
  537. If using a \f[B]create\f[] policy which does \f[B]not\f[] try to
  538. preserve directory paths
  539. .IP \[bu] 2
  540. Using the \f[B]rename\f[] policy get the list of files to rename
  541. .IP \[bu] 2
  542. Using the \f[B]getattr\f[] policy get the target path
  543. .IP \[bu] 2
  544. For each file attempt rename:
  545. .RS 2
  546. .IP \[bu] 2
  547. If the source drive != target drive:
  548. .IP \[bu] 2
  549. Clone target path from target drive to source drive
  550. .IP \[bu] 2
  551. Rename
  552. .RE
  553. .IP \[bu] 2
  554. If \f[B]any\f[] of the renames succeed the higher level rename is
  555. considered a success
  556. .IP \[bu] 2
  557. If \f[B]no\f[] renames succeed the first error encountered will be
  558. returned
  559. .IP \[bu] 2
  560. On success:
  561. .RS 2
  562. .IP \[bu] 2
  563. Remove the target from all drives with no source file
  564. .IP \[bu] 2
  565. Remove the source from all drives which failed to rename
  566. .RE
  567. .PP
  568. The the removals are subject to normal entitlement checks.
  569. .PP
  570. The above behavior will help minimize the likelihood of EXDEV being
  571. returned but it will still be possible.
  572. .PP
  573. \f[B]link\f[] uses the same basic strategy.
  574. .SS readdir
  575. .PP
  576. readdir (http://linux.die.net/man/3/readdir) is different from all other
  577. filesystem functions.
  578. While it could have it\[aq]s own set of policies to tweak its behavior
  579. at this time it provides a simple union of files and directories found.
  580. Remember that any action or information queried about these files and
  581. directories come from the respective function.
  582. For instance: an \f[B]ls\f[] is a \f[B]readdir\f[] and for each
  583. file/directory returned \f[B]getattr\f[] is called.
  584. Meaning the policy of \f[B]getattr\f[] is responsible for choosing the
  585. file/directory which is the source of the metadata you see in an
  586. \f[B]ls\f[].
  587. .SS statvfs
  588. .PP
  589. statvfs (http://linux.die.net/man/2/statvfs) normalizes the source
  590. drives based on the fragment size and sums the number of adjusted blocks
  591. and inodes.
  592. This means you will see the combined space of all sources.
  593. Total, used, and free.
  594. The sources however are dedupped based on the drive so multiple sources
  595. on the same drive will not result in double counting it\[aq]s space.
  596. .SH BUILDING
  597. .PP
  598. \f[B]NOTE:\f[] Prebuilt packages can be found at:
  599. https://github.com/trapexit/mergerfs/releases
  600. .PP
  601. First get the code from github (http://github.com/trapexit/mergerfs).
  602. .IP
  603. .nf
  604. \f[C]
  605. $\ git\ clone\ https://github.com/trapexit/mergerfs.git
  606. $\ #\ or
  607. $\ wget\ https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs\-<ver>.tar.gz
  608. \f[]
  609. .fi
  610. .SS Debian / Ubuntu
  611. .IP
  612. .nf
  613. \f[C]
  614. $\ sudo\ apt\-get\ \-y\ update
  615. $\ sudo\ apt\-get\ \-y\ install\ git\ make
  616. $\ cd\ mergerfs
  617. $\ make\ install\-build\-pkgs
  618. $\ make\ deb
  619. $\ sudo\ dpkg\ \-i\ ../mergerfs_version_arch.deb
  620. \f[]
  621. .fi
  622. .SS Fedora
  623. .IP
  624. .nf
  625. \f[C]
  626. $\ su\ \-
  627. #\ dnf\ \-y\ update
  628. #\ dnf\ \-y\ install\ git\ make
  629. #\ cd\ mergerfs
  630. #\ make\ install\-build\-pkgs
  631. #\ make\ rpm
  632. #\ rpm\ \-i\ rpmbuild/RPMS/<arch>/mergerfs\-<verion>.<arch>.rpm
  633. \f[]
  634. .fi
  635. .SS Generically
  636. .PP
  637. Have git, g++, make, python, libattr1, automake, libtool installed.
  638. .IP
  639. .nf
  640. \f[C]
  641. $\ cd\ mergerfs
  642. $\ make
  643. $\ sudo\ make\ install
  644. \f[]
  645. .fi
  646. .SH RUNTIME
  647. .SS \&.mergerfs pseudo file
  648. .IP
  649. .nf
  650. \f[C]
  651. <mountpoint>/.mergerfs
  652. \f[]
  653. .fi
  654. .PP
  655. There is a pseudo file available at the mount point which allows for the
  656. runtime modification of certain \f[B]mergerfs\f[] options.
  657. The file will not show up in \f[B]readdir\f[] but can be
  658. \f[B]stat\f[]\[aq]ed and manipulated via
  659. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls.
  660. .PP
  661. Even if xattrs are disabled for mergerfs the
  662. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls
  663. against this pseudo file will still work.
  664. .PP
  665. Any changes made at runtime are \f[B]not\f[] persisted.
  666. If you wish for values to persist they must be included as options
  667. wherever you configure the mounting of mergerfs (fstab).
  668. .SS Keys
  669. .PP
  670. Use \f[C]xattr\ \-l\ /mount/point/.mergerfs\f[] to see all supported
  671. keys.
  672. Some are informational and therefore readonly.
  673. .SS user.mergerfs.srcmounts
  674. .PP
  675. Used to query or modify the list of source mounts.
  676. When modifying there are several shortcuts to easy manipulation of the
  677. list.
  678. .PP
  679. .TS
  680. tab(@);
  681. l l.
  682. T{
  683. Value
  684. T}@T{
  685. Description
  686. T}
  687. _
  688. T{
  689. [list]
  690. T}@T{
  691. set
  692. T}
  693. T{
  694. +<[list]
  695. T}@T{
  696. prepend
  697. T}
  698. T{
  699. +>[list]
  700. T}@T{
  701. append
  702. T}
  703. T{
  704. \-[list]
  705. T}@T{
  706. remove all values provided
  707. T}
  708. T{
  709. \-<
  710. T}@T{
  711. remove first in list
  712. T}
  713. T{
  714. \->
  715. T}@T{
  716. remove last in list
  717. T}
  718. .TE
  719. .SS minfreespace
  720. .PP
  721. Input: interger with an optional multiplier suffix.
  722. \f[B]K\f[], \f[B]M\f[], or \f[B]G\f[].
  723. .PP
  724. Output: value in bytes
  725. .SS moveonenospc
  726. .PP
  727. Input: \f[B]true\f[] and \f[B]false\f[]
  728. .PP
  729. Ouput: \f[B]true\f[] or \f[B]false\f[]
  730. .SS categories / funcs
  731. .PP
  732. Input: short policy string as described elsewhere in this document
  733. .PP
  734. Output: the policy string except for categories where its funcs have
  735. multiple types.
  736. In that case it will be a comma separated list
  737. .SS Example
  738. .IP
  739. .nf
  740. \f[C]
  741. [trapexit:/tmp/mount]\ $\ xattr\ \-l\ .mergerfs
  742. user.mergerfs.srcmounts:\ /tmp/a:/tmp/b
  743. user.mergerfs.minfreespace:\ 4294967295
  744. user.mergerfs.moveonenospc:\ false
  745. \&...
  746. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  747. ff
  748. [trapexit:/tmp/mount]\ $\ xattr\ \-w\ user.mergerfs.category.search\ newest\ .mergerfs
  749. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  750. newest
  751. [trapexit:/tmp/mount]\ $\ xattr\ \-w\ user.mergerfs.srcmounts\ +/tmp/c\ .mergerfs
  752. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.srcmounts\ .mergerfs
  753. /tmp/a:/tmp/b:/tmp/c
  754. [trapexit:/tmp/mount]\ $\ xattr\ \-w\ user.mergerfs.srcmounts\ =/tmp/c\ .mergerfs
  755. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.srcmounts\ .mergerfs
  756. /tmp/c
  757. [trapexit:/tmp/mount]\ $\ xattr\ \-w\ user.mergerfs.srcmounts\ \[aq]+</tmp/a:/tmp/b\[aq]\ .mergerfs
  758. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.srcmounts\ .mergerfs
  759. /tmp/a:/tmp/b:/tmp/c
  760. \f[]
  761. .fi
  762. .SS file / directory xattrs
  763. .PP
  764. While they won\[aq]t show up when using
  765. listxattr (http://linux.die.net/man/2/listxattr) \f[B]mergerfs\f[]
  766. offers a number of special xattrs to query information about the files
  767. served.
  768. To access the values you will need to issue a
  769. getxattr (http://linux.die.net/man/2/getxattr) for one of the following:
  770. .IP \[bu] 2
  771. \f[B]user.mergerfs.basepath:\f[] the base mount point for the file given
  772. the current getattr policy
  773. .IP \[bu] 2
  774. \f[B]user.mergerfs.relpath:\f[] the relative path of the file from the
  775. perspective of the mount point
  776. .IP \[bu] 2
  777. \f[B]user.mergerfs.fullpath:\f[] the full path of the original file
  778. given the getattr policy
  779. .IP \[bu] 2
  780. \f[B]user.mergerfs.allpaths:\f[] a NUL (\[aq]\[aq]) separated list of
  781. full paths to all files found
  782. .IP
  783. .nf
  784. \f[C]
  785. [trapexit:/tmp/mount]\ $\ ls
  786. A\ B\ C
  787. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.fullpath\ A
  788. /mnt/a/full/path/to/A
  789. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.basepath\ A
  790. /mnt/a
  791. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.relpath\ A
  792. /full/path/to/A
  793. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.allpaths\ A\ |\ tr\ \[aq]\\0\[aq]\ \[aq]\\n\[aq]
  794. /mnt/a/full/path/to/A
  795. /mnt/b/full/path/to/A
  796. \f[]
  797. .fi
  798. .SH TOOLING
  799. .IP \[bu] 2
  800. https://github.com/trapexit/mergerfs\-tools
  801. .IP \[bu] 2
  802. mergerfs.ctl: A tool to make it easier to query and configure mergerfs
  803. at runtime
  804. .IP \[bu] 2
  805. mergerfs.fsck: Provides permissions and ownership auditing and the
  806. ability to fix them
  807. .IP \[bu] 2
  808. mergerfs.dedup: Will help identify and optionally remove duplicate files
  809. .IP \[bu] 2
  810. mergerfs.balance: Rebalance files across drives by moving them from the
  811. most filled to the least filled
  812. .IP \[bu] 2
  813. mergerfs.mktrash: Creates FreeDesktop.org Trash specification compatible
  814. directories on a mergerfs mount
  815. .IP \[bu] 2
  816. https://github.com/trapexit/scorch
  817. .IP \[bu] 2
  818. scorch: A tool to help discover silent corruption of files
  819. .IP \[bu] 2
  820. https://github.com/trapexit/bbf
  821. .IP \[bu] 2
  822. bbf (bad block finder): a tool to scan for and \[aq]fix\[aq] hard drive
  823. bad blocks and find the files using those blocks
  824. .SH TIPS / NOTES
  825. .IP \[bu] 2
  826. The recommended options are
  827. \f[B]defaults,allow_other,direct_io,use_ino\f[].
  828. (\f[B]use_ino\f[] will only work when used with mergerfs 2.18.0 and
  829. above.)
  830. .IP \[bu] 2
  831. Run mergerfs as \f[C]root\f[] unless you\[aq]re merging paths which are
  832. owned by the same user otherwise strange permission issues may arise.
  833. .IP \[bu] 2
  834. https://github.com/trapexit/backup\-and\-recovery\-howtos : A set of
  835. guides / howtos on creating a data storage system, backing it up,
  836. maintaining it, and recovering from failure.
  837. .IP \[bu] 2
  838. If you don\[aq]t see some directories and files you expect in a merged
  839. point or policies seem to skip drives be sure the user has permission to
  840. all the underlying directories.
  841. Use \f[C]mergerfs.fsck\f[] to audit the drive for out of sync
  842. permissions.
  843. .IP \[bu] 2
  844. Do \f[I]not\f[] use \f[C]direct_io\f[] if you expect applications (such
  845. as rtorrent) to mmap (http://linux.die.net/man/2/mmap) files.
  846. It is not currently supported in FUSE w/ \f[C]direct_io\f[] enabled.
  847. .IP \[bu] 2
  848. Since POSIX gives you only error or success on calls its difficult to
  849. determine the proper behavior when applying the behavior to multiple
  850. targets.
  851. \f[B]mergerfs\f[] will return an error only if all attempts of an action
  852. fail.
  853. Any success will lead to a success returned.
  854. This means however that some odd situations may arise.
  855. .IP \[bu] 2
  856. Kodi (http://kodi.tv), Plex (http://plex.tv),
  857. Subsonic (http://subsonic.org), etc.
  858. can use directory mtime (http://linux.die.net/man/2/stat) to more
  859. efficiently determine whether to scan for new content rather than simply
  860. performing a full scan.
  861. If using the default \f[B]getattr\f[] policy of \f[B]ff\f[] its possible
  862. \f[B]Kodi\f[] will miss an update on account of it returning the first
  863. directory found\[aq]s \f[B]stat\f[] info and its a later directory on
  864. another mount which had the \f[B]mtime\f[] recently updated.
  865. To fix this you will want to set \f[B]func.getattr=newest\f[].
  866. Remember though that this is just \f[B]stat\f[].
  867. If the file is later \f[B]open\f[]\[aq]ed or \f[B]unlink\f[]\[aq]ed and
  868. the policy is different for those then a completely different file or
  869. directory could be acted on.
  870. .IP \[bu] 2
  871. Some policies mixed with some functions may result in strange behaviors.
  872. Not that some of these behaviors and race conditions couldn\[aq]t happen
  873. outside \f[B]mergerfs\f[] but that they are far more likely to occur on
  874. account of attempt to merge together multiple sources of data which
  875. could be out of sync due to the different policies.
  876. .IP \[bu] 2
  877. For consistency its generally best to set \f[B]category\f[] wide
  878. policies rather than individual \f[B]func\f[]\[aq]s.
  879. This will help limit the confusion of tools such as
  880. rsync (http://linux.die.net/man/1/rsync).
  881. However, the flexibility is there if needed.
  882. .SH KNOWN ISSUES / BUGS
  883. .SS directory mtime is not being updated
  884. .PP
  885. Remember that the default policy for \f[C]getattr\f[] is \f[C]ff\f[].
  886. The information for the first directory found will be returned.
  887. If it wasn\[aq]t the directory which had been updated then it will
  888. appear outdated.
  889. .PP
  890. The reason this is the default is because any other policy would be far
  891. more expensive and for many applications it is unnecessary.
  892. To always return the directory with the most recent mtime or a faked
  893. value based on all found would require a scan of all drives.
  894. That alone is far more expensive than \f[C]ff\f[] but would also
  895. possibly spin up sleeping drives.
  896. .PP
  897. If you always want the directory information from the one with the most
  898. recent mtime then use the \f[C]newest\f[] policy for \f[C]getattr\f[].
  899. .SS cached memory appears greater than it should be
  900. .PP
  901. Use the \f[C]direct_io\f[] option as described above.
  902. Due to what mergerfs is doing there ends up being two caches of a file
  903. under normal usage.
  904. One from the underlying filesystem and one from mergerfs.
  905. Enabling \f[C]direct_io\f[] removes the mergerfs cache.
  906. This saves on memory but means the kernel needs to communicate with
  907. mergerfs more often and can therefore result in slower speeds.
  908. .PP
  909. Since enabling \f[C]direct_io\f[] disables \f[C]mmap\f[] this is not an
  910. ideal situation however write speeds should be increased.
  911. .PP
  912. If \f[C]direct_io\f[] is disabled it is probably a good idea to enable
  913. \f[C]dropcacheonclose\f[] to minimize double caching.
  914. .SS NFS clients don\[aq]t work
  915. .PP
  916. Some NFS clients appear to fail when a mergerfs mount is exported.
  917. Kodi in particular seems to have issues.
  918. .PP
  919. Try enabling the \f[C]use_ino\f[] option.
  920. Some have reported that it fixes the issue.
  921. .SS rtorrent fails with ENODEV (No such device)
  922. .PP
  923. Be sure to turn off \f[C]direct_io\f[].
  924. rtorrent and some other applications use
  925. mmap (http://linux.die.net/man/2/mmap) to read and write to files and
  926. offer no failback to traditional methods.
  927. FUSE does not currently support mmap while using \f[C]direct_io\f[].
  928. There will be a performance penalty on writes with \f[C]direct_io\f[]
  929. off as well as the problem of double caching but it\[aq]s the only way
  930. to get such applications to work.
  931. If the performance loss is too high for other apps you can mount
  932. mergerfs twice.
  933. Once with \f[C]direct_io\f[] enabled and one without it.
  934. .SS Plex doesn\[aq]t work with mergerfs
  935. .PP
  936. It does.
  937. If you\[aq]re trying to put Plex\[aq]s config / metadata on mergerfs you
  938. have to leave \f[C]direct_io\f[] off because Plex is using sqlite which
  939. apparently needs mmap.
  940. mmap doesn\[aq]t work with \f[C]direct_io\f[].
  941. .PP
  942. If the issue is that scanning doesn\[aq]t seem to pick up media then be
  943. sure to set \f[C]func.getattr=newest\f[] as mentioned above.
  944. .SS mmap performance is really bad
  945. .PP
  946. There is a bug (https://lkml.org/lkml/2016/3/16/260) in caching which
  947. affects overall performance of mmap through FUSE in Linux 4.x kernels.
  948. It is fixed in 4.4.10 and 4.5.4 (https://lkml.org/lkml/2016/5/11/59).
  949. .SS When a program tries to move or rename a file it fails
  950. .PP
  951. Please read the section above regarding rename & link (#rename--link).
  952. .PP
  953. The problem is that many applications do not properly handle
  954. \f[C]EXDEV\f[] errors which \f[C]rename\f[] and \f[C]link\f[] may return
  955. even though they are perfectly valid situations which do not indicate
  956. actual drive or OS errors.
  957. The error will only be returned by mergerfs if using a path preserving
  958. policy as described in the policy section above.
  959. If you do not care about path preservation simply change the mergerfs
  960. policy to the non\-path preserving version.
  961. For example: \f[C]\-o\ category.create=mfs\f[]
  962. .PP
  963. Ideally the offending software would be fixed and it is recommended that
  964. if you run into this problem you contact the software\[aq]s author and
  965. request proper handling of \f[C]EXDEV\f[] errors.
  966. .SS Samba: Moving files / directories fails
  967. .PP
  968. Workaround: Copy the file/directory and then remove the original rather
  969. than move.
  970. .PP
  971. This isn\[aq]t an issue with Samba but some SMB clients.
  972. GVFS\-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed
  973. to handle certain error codes correctly.
  974. Particularly \f[B]STATUS_NOT_SAME_DEVICE\f[] which comes from the
  975. \f[B]EXDEV\f[] which is returned by \f[B]rename\f[] when the call is
  976. crossing mount points.
  977. When a program gets an \f[B]EXDEV\f[] it needs to explicitly take an
  978. alternate action to accomplish it\[aq]s goal.
  979. In the case of \f[B]mv\f[] or similar it tries \f[B]rename\f[] and on
  980. \f[B]EXDEV\f[] falls back to a manual copying of data between the two
  981. locations and unlinking the source.
  982. In these older versions of GVFS\-fuse if it received \f[B]EXDEV\f[] it
  983. would translate that into \f[B]EIO\f[].
  984. This would cause \f[B]mv\f[] or most any application attempting to move
  985. files around on that SMB share to fail with a IO error.
  986. .PP
  987. GVFS\-fuse v1.22.0 (https://bugzilla.gnome.org/show_bug.cgi?id=734568)
  988. and above fixed this issue but a large number of systems use the older
  989. release.
  990. On Ubuntu the version can be checked by issuing
  991. \f[C]apt\-cache\ showpkg\ gvfs\-fuse\f[].
  992. Most distros released in 2015 seem to have the updated release and will
  993. work fine but older systems may not.
  994. Upgrading gvfs\-fuse or the distro in general will address the problem.
  995. .PP
  996. In Apple\[aq]s MacOSX 10.9 they replaced Samba (client and server) with
  997. their own product.
  998. It appears their new client does not handle \f[B]EXDEV\f[] either and
  999. responds similar to older release of gvfs on Linux.
  1000. .SS Trashing files occasionally fails
  1001. .PP
  1002. This is the same issue as with Samba.
  1003. \f[C]rename\f[] returns \f[C]EXDEV\f[] (in our case that will really
  1004. only happen with path preserving policies like \f[C]epmfs\f[]) and the
  1005. software doesn\[aq]t handle the situtation well.
  1006. This is unfortunately a common failure of software which moves files
  1007. around.
  1008. The standard indicates that an implementation \f[C]MAY\f[] choose to
  1009. support non\-user home directory trashing of files (which is a
  1010. \f[C]MUST\f[]).
  1011. The implementation \f[C]MAY\f[] also support "top directory trashes"
  1012. which many probably do.
  1013. .PP
  1014. To create a \f[C]$topdir/.Trash\f[] directory as defined in the standard
  1015. use the mergerfs\-tools (https://github.com/trapexit/mergerfs-tools)
  1016. tool \f[C]mergerfs.mktrash\f[].
  1017. .SS Supplemental user groups
  1018. .PP
  1019. Due to the overhead of
  1020. getgroups/setgroups (http://linux.die.net/man/2/setgroups) mergerfs
  1021. utilizes a cache.
  1022. This cache is opportunistic and per thread.
  1023. Each thread will query the supplemental groups for a user when that
  1024. particular thread needs to change credentials and will keep that data
  1025. for the lifetime of the thread.
  1026. This means that if a user is added to a group it may not be picked up
  1027. without the restart of mergerfs.
  1028. However, since the high level FUSE API\[aq]s (at least the standard
  1029. version) thread pool dynamically grows and shrinks it\[aq]s possible
  1030. that over time a thread will be killed and later a new thread with no
  1031. cache will start and query the new data.
  1032. .PP
  1033. The gid cache uses fixed storage to simplify the design and be
  1034. compatible with older systems which may not have C++11 compilers.
  1035. There is enough storage for 256 users\[aq] supplemental groups.
  1036. Each user is allowed upto 32 supplemental groups.
  1037. Linux >= 2.6.3 allows upto 65535 groups per user but most other *nixs
  1038. allow far less.
  1039. NFS allowing only 16.
  1040. The system does handle overflow gracefully.
  1041. If the user has more than 32 supplemental groups only the first 32 will
  1042. be used.
  1043. If more than 256 users are using the system when an uncached user is
  1044. found it will evict an existing user\[aq]s cache at random.
  1045. So long as there aren\[aq]t more than 256 active users this should be
  1046. fine.
  1047. If either value is too low for your needs you will have to modify
  1048. \f[C]gidcache.hpp\f[] to increase the values.
  1049. Note that doing so will increase the memory needed by each thread.
  1050. .SS mergerfs or libfuse crashing
  1051. .PP
  1052. \f[B]NOTE:\f[] as of mergerfs 2.22.0 it includes the most recent version
  1053. of libfuse so any crash should be reported.
  1054. For older releases continue reading...
  1055. .PP
  1056. If suddenly the mergerfs mount point disappears and
  1057. \f[C]Transport\ endpoint\ is\ not\ connected\f[] is returned when
  1058. attempting to perform actions within the mount directory \f[B]and\f[]
  1059. the version of libfuse (use \f[C]mergerfs\ \-v\f[] to find the version)
  1060. is older than \f[C]2.9.4\f[] its likely due to a bug in libfuse.
  1061. Affected versions of libfuse can be found in Debian Wheezy, Ubuntu
  1062. Precise and others.
  1063. .PP
  1064. In order to fix this please install newer versions of libfuse.
  1065. If using a Debian based distro (Debian,Ubuntu,Mint) you can likely just
  1066. install newer versions of
  1067. libfuse (https://packages.debian.org/unstable/libfuse2) and
  1068. fuse (https://packages.debian.org/unstable/fuse) from the repo of a
  1069. newer release.
  1070. .SS mergerfs appears to be crashing or exiting
  1071. .PP
  1072. There seems to be an issue with Linux version \f[C]4.9.0\f[] and above
  1073. in which an invalid message appears to be transmitted to libfuse (used
  1074. by mergerfs) causing it to exit.
  1075. No messages will be printed in any logs as its not a proper crash.
  1076. Debugging of the issue is still ongoing and can be followed via the
  1077. fuse\-devel
  1078. thread (https://sourceforge.net/p/fuse/mailman/message/35662577).
  1079. .SS mergerfs under heavy load and memory preasure leads to kernel panic
  1080. .PP
  1081. https://lkml.org/lkml/2016/9/14/527
  1082. .IP
  1083. .nf
  1084. \f[C]
  1085. [25192.515454]\ kernel\ BUG\ at\ /build/linux\-a2WvEb/linux\-4.4.0/mm/workingset.c:346!
  1086. [25192.517521]\ invalid\ opcode:\ 0000\ [#1]\ SMP
  1087. [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]
  1088. [25192.540910]\ CPU:\ 2\ PID:\ 63\ Comm:\ kswapd0\ Not\ tainted\ 4.4.0\-36\-generic\ #55\-Ubuntu
  1089. [25192.543411]\ Hardware\ name:\ System\ manufacturer\ System\ Product\ Name/P8H67\-M\ PRO,\ BIOS\ 3904\ 04/27/2013
  1090. [25192.545840]\ task:\ ffff88040cae6040\ ti:\ ffff880407488000\ task.ti:\ ffff880407488000
  1091. [25192.548277]\ RIP:\ 0010:[<ffffffff811ba501>]\ \ [<ffffffff811ba501>]\ shadow_lru_isolate+0x181/0x190
  1092. [25192.550706]\ RSP:\ 0018:ffff88040748bbe0\ \ EFLAGS:\ 00010002
  1093. [25192.553127]\ RAX:\ 0000000000001c81\ RBX:\ ffff8802f91ee928\ RCX:\ ffff8802f91eeb38
  1094. [25192.555544]\ RDX:\ ffff8802f91ee938\ RSI:\ ffff8802f91ee928\ RDI:\ ffff8804099ba2c0
  1095. [25192.557914]\ RBP:\ ffff88040748bc08\ R08:\ 000000000001a7b6\ R09:\ 000000000000003f
  1096. [25192.560237]\ R10:\ 000000000001a750\ R11:\ 0000000000000000\ R12:\ ffff8804099ba2c0
  1097. [25192.562512]\ R13:\ ffff8803157e9680\ R14:\ ffff8803157e9668\ R15:\ ffff8804099ba2c8
  1098. [25192.564724]\ FS:\ \ 0000000000000000(0000)\ GS:ffff88041f280000(0000)\ knlGS:0000000000000000
  1099. [25192.566990]\ CS:\ \ 0010\ DS:\ 0000\ ES:\ 0000\ CR0:\ 0000000080050033
  1100. [25192.569201]\ CR2:\ 00007ffabb690000\ CR3:\ 0000000001e0a000\ CR4:\ 00000000000406e0
  1101. [25192.571419]\ Stack:
  1102. [25192.573550]\ \ ffff8804099ba2c0\ ffff88039e4f86f0\ ffff8802f91ee928\ ffff8804099ba2c8
  1103. [25192.575695]\ \ ffff88040748bd08\ ffff88040748bc58\ ffffffff811b99bf\ 0000000000000052
  1104. [25192.577814]\ \ 0000000000000000\ ffffffff811ba380\ 000000000000008a\ 0000000000000080
  1105. [25192.579947]\ Call\ Trace:
  1106. [25192.582022]\ \ [<ffffffff811b99bf>]\ __list_lru_walk_one.isra.3+0x8f/0x130
  1107. [25192.584137]\ \ [<ffffffff811ba380>]\ ?\ memcg_drain_all_list_lrus+0x190/0x190
  1108. [25192.586165]\ \ [<ffffffff811b9a83>]\ list_lru_walk_one+0x23/0x30
  1109. [25192.588145]\ \ [<ffffffff811ba544>]\ scan_shadow_nodes+0x34/0x50
  1110. [25192.590074]\ \ [<ffffffff811a0e9d>]\ shrink_slab.part.40+0x1ed/0x3d0
  1111. [25192.591985]\ \ [<ffffffff811a53da>]\ shrink_zone+0x2ca/0x2e0
  1112. [25192.593863]\ \ [<ffffffff811a64ce>]\ kswapd+0x51e/0x990
  1113. [25192.595737]\ \ [<ffffffff811a5fb0>]\ ?\ mem_cgroup_shrink_node_zone+0x1c0/0x1c0
  1114. [25192.597613]\ \ [<ffffffff810a0808>]\ kthread+0xd8/0xf0
  1115. [25192.599495]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  1116. [25192.601335]\ \ [<ffffffff8182e34f>]\ ret_from_fork+0x3f/0x70
  1117. [25192.603193]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  1118. \f[]
  1119. .fi
  1120. .PP
  1121. There is a bug in the kernel.
  1122. A work around appears to be turning off \f[C]splice\f[].
  1123. Add \f[C]no_splice_write,no_splice_move,no_splice_read\f[] to
  1124. mergerfs\[aq] options.
  1125. Should be placed after \f[C]defaults\f[] if it is used since it will
  1126. turn them on.
  1127. This however is not guaranteed to work.
  1128. .SH FAQ
  1129. .SS Why use mergerfs over mhddfs?
  1130. .PP
  1131. mhddfs is no longer maintained and has some known stability and security
  1132. issues (see below).
  1133. MergerFS provides a superset of mhddfs\[aq] features and should offer
  1134. the same or maybe better performance.
  1135. .PP
  1136. If you wish to get similar behavior to mhddfs from mergerfs then set
  1137. \f[C]category.create=ff\f[].
  1138. .SS Why use mergerfs over aufs?
  1139. .PP
  1140. While aufs can offer better peak performance mergerfs provides more
  1141. configurability and is generally easier to use.
  1142. mergerfs however does not offer the overlay / copy\-on\-write (COW)
  1143. features which aufs and overlayfs have.
  1144. .SS Why use mergerfs over LVM/ZFS/BTRFS/RAID0 drive concatenation /
  1145. striping?
  1146. .PP
  1147. With simple JBOD / drive concatenation / stripping / RAID0 a single
  1148. drive failure will result in full pool failure.
  1149. mergerfs performs a similar behavior without the possibility of
  1150. catastrophic failure and difficulties in recovery.
  1151. Drives may fail however all other data will continue to be accessable.
  1152. .PP
  1153. When combined with something like SnapRaid (http://www.snapraid.it)
  1154. and/or an offsite backup solution you can have the flexibilty of JBOD
  1155. without the single point of failure.
  1156. .SS Why use mergerfs over ZFS?
  1157. .PP
  1158. MergerFS is not intended to be a replacement for ZFS.
  1159. MergerFS is intended to provide flexible pooling of arbitrary drives
  1160. (local or remote), of arbitrary sizes, and arbitrary filesystems.
  1161. For \f[C]write\ once,\ read\ many\f[] usecases such as bulk media
  1162. storage.
  1163. Where data integrity and backup is managed in other ways.
  1164. In that situation ZFS can introduce major maintance and cost burdens as
  1165. described
  1166. here (http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html).
  1167. .SS Can drives be written to directly? Outside of mergerfs while pooled?
  1168. .PP
  1169. Yes.
  1170. It will be represented immediately in the pool as the policies
  1171. perscribe.
  1172. .SS Why do I get an "out of space" error even though the system says
  1173. there\[aq]s lots of space left?
  1174. .PP
  1175. First make sure you\[aq]ve read the sections above about policies, path
  1176. preserving, and the \f[B]moveonenospc\f[] option.
  1177. .PP
  1178. Remember that mergerfs is simply presenting a logical merging of the
  1179. contents of the pooled drives.
  1180. The reported free space is the aggregate space available \f[B]not\f[]
  1181. the contiguous space available.
  1182. MergerFS does not split files across drives.
  1183. If the writing of a file fills a drive and \f[B]moveonenospc\f[] is
  1184. disabled it will return an ENOSPC error.
  1185. .PP
  1186. If \f[B]moveonenospc\f[] is enabled but there exists no drives with
  1187. enough space for the file and the data to be written (or the drive
  1188. happened to fill up as the file was being moved) it will error
  1189. indicating there isn\[aq]t enough space.
  1190. .PP
  1191. It is also possible that the filesystem selected has run out of inodes.
  1192. Use \f[C]df\ \-i\f[] to list the total and available inodes per
  1193. filesystem.
  1194. In the future it might be worth considering the number of inodes
  1195. available when making placement decisions in order to minimize this
  1196. situation.
  1197. .SS Can mergerfs mounts be exported over NFS?
  1198. .PP
  1199. Yes.
  1200. Some clients (Kodi) have issues in which the contents of the NFS mount
  1201. will not be presented but users have found that enabling the
  1202. \f[C]use_ino\f[] option often fixes that problem.
  1203. .SS Can mergerfs mounts be exported over Samba / SMB?
  1204. .PP
  1205. Yes.
  1206. .SS How are inodes calculated?
  1207. .PP
  1208. mergerfs\-inode = (original\-inode | (device\-id << 32))
  1209. .PP
  1210. While \f[C]ino_t\f[] is 64 bits only a few filesystems use more than 32.
  1211. Similarly, while \f[C]dev_t\f[] is also 64 bits it was traditionally 16
  1212. bits.
  1213. Bitwise or\[aq]ing them together should work most of the time.
  1214. While totally unique inodes are preferred the overhead which would be
  1215. needed does not seem to outweighted by the benefits.
  1216. .SS It\[aq]s mentioned that there are some security issues with mhddfs.
  1217. What are they? How does mergerfs address them?
  1218. .PP
  1219. mhddfs (https://github.com/trapexit/mhddfs) manages running as
  1220. \f[B]root\f[] by calling
  1221. getuid() (https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  1222. and if it returns \f[B]0\f[] then it will
  1223. chown (http://linux.die.net/man/1/chown) the file.
  1224. Not only is that a race condition but it doesn\[aq]t handle many other
  1225. situations.
  1226. Rather than attempting to simulate POSIX ACL behavior the proper way to
  1227. manage this is to use seteuid (http://linux.die.net/man/2/seteuid) and
  1228. setegid (http://linux.die.net/man/2/setegid), in effect becoming the
  1229. user making the original call, and perform the action as them.
  1230. This is what mergerfs does.
  1231. .PP
  1232. In Linux setreuid syscalls apply only to the thread.
  1233. GLIBC hides this away by using realtime signals to inform all threads to
  1234. change credentials.
  1235. Taking after \f[B]Samba\f[], mergerfs uses
  1236. \f[B]syscall(SYS_setreuid,...)\f[] to set the callers credentials for
  1237. that thread only.
  1238. Jumping back to \f[B]root\f[] as necessary should escalated privileges
  1239. be needed (for instance: to clone paths between drives).
  1240. .PP
  1241. For non\-Linux systems mergerfs uses a read\-write lock and changes
  1242. credentials only when necessary.
  1243. If multiple threads are to be user X then only the first one will need
  1244. to change the processes credentials.
  1245. So long as the other threads need to be user X they will take a readlock
  1246. allowing multiple threads to share the credentials.
  1247. Once a request comes in to run as user Y that thread will attempt a
  1248. write lock and change to Y\[aq]s credentials when it can.
  1249. If the ability to give writers priority is supported then that flag will
  1250. be used so threads trying to change credentials don\[aq]t starve.
  1251. This isn\[aq]t the best solution but should work reasonably well
  1252. assuming there are few users.
  1253. .SH SUPPORT
  1254. .SS Issues with the software
  1255. .IP \[bu] 2
  1256. github.com: https://github.com/trapexit/mergerfs/issues
  1257. .IP \[bu] 2
  1258. email: trapexit\@spawn.link
  1259. .IP \[bu] 2
  1260. twitter: https://twitter.com/_trapexit
  1261. .SS Support development
  1262. .IP \[bu] 2
  1263. Gratipay: https://gratipay.com/~trapexit
  1264. .IP \[bu] 2
  1265. BitCoin: 12CdMhEPQVmjz3SSynkAEuD5q9JmhTDCZA
  1266. .SH LINKS
  1267. .IP \[bu] 2
  1268. http://github.com/trapexit/mergerfs
  1269. .IP \[bu] 2
  1270. http://github.com/trapexit/mergerfs\-tools
  1271. .IP \[bu] 2
  1272. http://github.com/trapexit/scorch
  1273. .IP \[bu] 2
  1274. http://github.com/trapexit/backup\-and\-recovery\-howtos
  1275. .SH AUTHORS
  1276. Antonio SJ Musumeci <trapexit@spawn.link>.