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.

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