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.

1255 lines
46 KiB

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