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.

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