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.

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