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.

1707 lines
64 KiB

9 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
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
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
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
9 years ago
  1. .\"t
  2. .\" Automatically generated by Pandoc 1.19.2.4
  3. .\"
  4. .TH "mergerfs" "1" "2018\-10\-08" "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 How it works
  43. .PP
  44. mergerfs logically merges multiple paths together.
  45. Think a union of sets.
  46. The file/s or directory/s acted on or presented through mergerfs are
  47. based on the policy chosen for that particular action.
  48. Read more about policies below.
  49. .IP
  50. .nf
  51. \f[C]
  52. A\ \ \ \ \ \ \ \ \ +\ \ \ \ \ \ B\ \ \ \ \ \ \ \ =\ \ \ \ \ \ \ C
  53. /disk1\ \ \ \ \ \ \ \ \ \ \ /disk2\ \ \ \ \ \ \ \ \ \ \ /merged
  54. |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
  55. +\-\-\ /dir1\ \ \ \ \ \ \ \ +\-\-\ /dir1\ \ \ \ \ \ \ \ +\-\-\ /dir1
  56. |\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ |
  57. |\ \ \ +\-\-\ file1\ \ \ \ |\ \ \ +\-\-\ file2\ \ \ \ |\ \ \ +\-\-\ file1
  58. |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file3\ \ \ \ |\ \ \ +\-\-\ file2
  59. +\-\-\ /dir2\ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file3
  60. |\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ /dir3\ \ \ \ \ \ \ \ |
  61. |\ \ \ +\-\-\ file4\ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ /dir2
  62. |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ file5\ \ \ |\ \ \ |
  63. +\-\-\ file6\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file4
  64. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
  65. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ /dir3
  66. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ |
  67. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file5
  68. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
  69. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ file6
  70. \f[]
  71. .fi
  72. .PP
  73. mergerfs does \f[B]not\f[] support the copy\-on\-write (CoW) behavior
  74. found in \f[B]aufs\f[] and \f[B]overlayfs\f[].
  75. You can \f[B]not\f[] mount a read\-only filesystem and write to it.
  76. However, mergerfs will ignore read\-only drives when creating new files
  77. so you can mix rw and ro drives.
  78. .SH OPTIONS
  79. .SS mount options
  80. .IP \[bu] 2
  81. \f[B]defaults\f[]: a shortcut for FUSE\[aq]s \f[B]atomic_o_trunc\f[],
  82. \f[B]auto_cache\f[], \f[B]big_writes\f[], \f[B]default_permissions\f[],
  83. \f[B]splice_move\f[], \f[B]splice_read\f[], and \f[B]splice_write\f[].
  84. These options seem to provide the best performance.
  85. .IP \[bu] 2
  86. \f[B]allow_other\f[]: a libfuse option which allows users besides the
  87. one which ran mergerfs to see the filesystem.
  88. This is required for most use\-cases.
  89. .IP \[bu] 2
  90. \f[B]direct_io\f[]: causes FUSE to bypass caching which can increase
  91. write speeds at the detriment of reads.
  92. Note that not enabling \f[C]direct_io\f[] will cause double caching of
  93. files and therefore less memory for caching generally (enable
  94. \f[B]dropcacheonclose\f[] to help with this problem).
  95. However, \f[C]mmap\f[] does not work when \f[C]direct_io\f[] is enabled.
  96. .IP \[bu] 2
  97. \f[B]minfreespace=value\f[]: the minimum space value used for creation
  98. policies.
  99. Understands \[aq]K\[aq], \[aq]M\[aq], and \[aq]G\[aq] to represent
  100. kilobyte, megabyte, and gigabyte respectively.
  101. (default: 4G)
  102. .IP \[bu] 2
  103. \f[B]moveonenospc=true|false\f[]: when enabled (set to \f[B]true\f[]) if
  104. a \f[B]write\f[] fails with \f[B]ENOSPC\f[] or \f[B]EDQUOT\f[] a scan of
  105. all drives will be done looking for the drive with the most free space
  106. which is at least the size of the file plus the amount which failed to
  107. write.
  108. An attempt to move the file to that drive will occur (keeping all
  109. metadata possible) and if successful the original is unlinked and the
  110. write retried.
  111. (default: false)
  112. .IP \[bu] 2
  113. \f[B]use_ino\f[]: causes mergerfs to supply file/directory inodes rather
  114. than libfuse.
  115. While not a default it is generally recommended it be enabled so that
  116. hard linked files share the same inode value.
  117. .IP \[bu] 2
  118. \f[B]hard_remove\f[]: force libfuse to immedately remove files when
  119. unlinked.
  120. This can have a very minor performance impact in some cases but is
  121. generally recommended since there are subtle race conditions which can
  122. occur when removing large sets of files & directories.
  123. .IP \[bu] 2
  124. \f[B]dropcacheonclose=true|false\f[]: when a file is requested to be
  125. closed call \f[C]posix_fadvise\f[] on it first to instruct the kernel
  126. that we no longer need the data and it can drop its cache.
  127. Recommended when \f[B]direct_io\f[] is not enabled to limit double
  128. caching.
  129. (default: false)
  130. .IP \[bu] 2
  131. \f[B]symlinkify=true|false\f[]: when enabled (set to \f[B]true\f[]) and
  132. a file is not writable and its mtime or ctime is older than
  133. \f[B]symlinkify_timeout\f[] files will be reported as symlinks to the
  134. original files.
  135. Please read more below before using.
  136. (default: false)
  137. .IP \[bu] 2
  138. \f[B]symlinkify_timeout=value\f[]: time to wait, in seconds, to activate
  139. the \f[B]symlinkify\f[] behavior.
  140. (default: 3600)
  141. .IP \[bu] 2
  142. \f[B]nullrw=true|false\f[]: turns reads and writes into no\-ops.
  143. The request will succeed but do nothing.
  144. Useful for benchmarking mergerfs.
  145. (default: false)
  146. .IP \[bu] 2
  147. \f[B]ignorepponrename=true|false\f[]: ignore path preserving on rename.
  148. Typically rename and link act differently depending on the policy of
  149. \f[C]create\f[] (read below).
  150. Enabling this will cause rename and link to always use the non\-path
  151. preserving behavior.
  152. This means files, when renamed or linked, will stay on the same drive.
  153. (default: false)
  154. .IP \[bu] 2
  155. \f[B]security_capability=true|false\f[]: If false return ENOATTR when
  156. xattr security.capability is queried.
  157. (default: true)
  158. .IP \[bu] 2
  159. \f[B]xattr=passthrough|noattr|notsup\f[]: Runtime control of xattrs.
  160. Default is to passthrough xattr requests.
  161. \[aq]noattr\[aq] will short circuit as if nothing exists.
  162. \[aq]notsup\[aq] will respond with ENOTSUP as if xattrs are not
  163. supported or disabled.
  164. (default: passthrough)
  165. .IP \[bu] 2
  166. \f[B]link_cow=true|false\f[]: When enabled if a regular file is opened
  167. which has a link count > 1 it will copy the file to a temporary file and
  168. rename over the original.
  169. Breaking the link and providing a basic copy\-on\-write function similar
  170. to cow\-shell.
  171. (default: false)
  172. .IP \[bu] 2
  173. \f[B]threads=num\f[]: number of threads to use in multithreaded mode.
  174. When set to zero (the default) it will attempt to discover and use the
  175. number of logical cores.
  176. If the lookup fails it will fall back to using 4.
  177. If the thread count is set negative it will look up the number of cores
  178. then divide by the absolute value.
  179. ie.
  180. threads=\-2 on an 8 core machine will result in 8 / 2 = 4 threads.
  181. There will always be at least 1 thread.
  182. NOTE: higher number of threads increases parallelism but usually
  183. decreases throughput.
  184. (default: number of cores) \f[I]NOTE2:\f[] the option is unavailable
  185. when built with system libfuse.
  186. .IP \[bu] 2
  187. \f[B]fsname=name\f[]: sets the name of the filesystem as seen in
  188. \f[B]mount\f[], \f[B]df\f[], etc.
  189. Defaults to a list of the source paths concatenated together with the
  190. longest common prefix removed.
  191. .IP \[bu] 2
  192. \f[B]func.<func>=<policy>\f[]: sets the specific FUSE function\[aq]s
  193. policy.
  194. See below for the list of value types.
  195. Example: \f[B]func.getattr=newest\f[]
  196. .IP \[bu] 2
  197. \f[B]category.<category>=<policy>\f[]: Sets policy of all FUSE functions
  198. in the provided category.
  199. Example: \f[B]category.create=mfs\f[]
  200. .PP
  201. \f[B]NOTE:\f[] Options are evaluated in the order listed so if the
  202. options are \f[B]func.rmdir=rand,category.action=ff\f[] the
  203. \f[B]action\f[] category setting will override the \f[B]rmdir\f[]
  204. setting.
  205. .SS srcmounts
  206. .PP
  207. The srcmounts (source mounts) argument is a colon (\[aq]:\[aq])
  208. delimited list of paths to be included in the pool.
  209. It does not matter if the paths are on the same or different drives nor
  210. does it matter the filesystem.
  211. Used and available space will not be duplicated for paths on the same
  212. device and any features which aren\[aq]t supported by the underlying
  213. filesystem (such as file attributes or extended attributes) will return
  214. the appropriate errors.
  215. .PP
  216. To make it easier to include multiple source mounts mergerfs supports
  217. globbing (http://linux.die.net/man/7/glob).
  218. \f[B]The globbing tokens MUST be escaped when using via the shell else
  219. the shell itself will expand it.\f[]
  220. .IP
  221. .nf
  222. \f[C]
  223. $\ mergerfs\ \-o\ defaults,allow_other,use_ino\ /mnt/disk\\*:/mnt/cdrom\ /media/drives
  224. \f[]
  225. .fi
  226. .PP
  227. The above line will use all mount points in /mnt prefixed with
  228. \f[B]disk\f[] and the \f[B]cdrom\f[].
  229. .PP
  230. To have the pool mounted at boot or otherwise accessable from related
  231. tools use \f[B]/etc/fstab\f[].
  232. .IP
  233. .nf
  234. \f[C]
  235. #\ <file\ system>\ \ \ \ \ \ \ \ <mount\ point>\ \ <type>\ \ \ \ \ \ \ \ \ <options>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ <dump>\ \ <pass>
  236. /mnt/disk*:/mnt/cdrom\ \ /media/drives\ \ fuse.mergerfs\ \ defaults,allow_other,use_ino,hard_remove\ \ 0\ \ \ \ \ \ \ 0
  237. \f[]
  238. .fi
  239. .PP
  240. \f[B]NOTE:\f[] the globbing is done at mount or xattr update time (see
  241. below).
  242. If a new directory is added matching the glob after the fact it will not
  243. be automatically included.
  244. .PP
  245. \f[B]NOTE:\f[] for mounting via \f[B]fstab\f[] to work you must have
  246. \f[B]mount.fuse\f[] installed.
  247. For Ubuntu/Debian it is included in the \f[B]fuse\f[] package.
  248. .SS symlinkify
  249. .PP
  250. Due to the levels of indirection introduced by mergerfs and the
  251. underlying technology FUSE there can be varying levels of performance
  252. degredation.
  253. This feature will turn non\-directories which are not writable into
  254. symlinks to the original file found by the \f[C]readlink\f[] policy
  255. after the mtime and ctime are older than the timeout.
  256. .PP
  257. \f[B]WARNING:\f[] The current implementation has a known issue in which
  258. if the file is open and being used when the file is converted to a
  259. symlink then the application which has that file open will receive an
  260. error when using it.
  261. This is unlikely to occur in practice but is something to keep in mind.
  262. .PP
  263. \f[B]WARNING:\f[] Some backup solutions, such as CrashPlan, do not
  264. backup the target of a symlink.
  265. If using this feature it will be necessary to point any backup software
  266. to the original drives or configure the software to follow symlinks if
  267. such an option is available.
  268. Alternatively create two mounts.
  269. One for backup and one for general consumption.
  270. .SS nullrw
  271. .PP
  272. Due to how FUSE works there is an overhead to all requests made to a
  273. FUSE filesystem.
  274. Meaning that even a simple passthrough will have some slowdown.
  275. However, generally the overhead is minimal in comparison to the cost of
  276. the underlying I/O.
  277. By disabling the underlying I/O we can test the theoretical performance
  278. boundries.
  279. .PP
  280. By enabling \f[C]nullrw\f[] mergerfs will work as it always does
  281. \f[B]except\f[] that all reads and writes will be no\-ops.
  282. A write will succeed (the size of the write will be returned as if it
  283. were successful) but mergerfs does nothing with the data it was given.
  284. Similarly a read will return the size requested but won\[aq]t touch the
  285. buffer.
  286. .PP
  287. Example:
  288. .IP
  289. .nf
  290. \f[C]
  291. $\ dd\ if=/dev/zero\ of=/path/to/mergerfs/mount/benchmark\ ibs=1M\ obs=512\ count=1024
  292. 1024+0\ records\ in
  293. 2097152+0\ records\ out
  294. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 15.4067\ s,\ 69.7\ MB/s
  295. $\ dd\ if=/dev/zero\ of=/path/to/mergerfs/mount/benchmark\ ibs=1M\ obs=1M\ count=1024
  296. 1024+0\ records\ in
  297. 1024+0\ records\ out
  298. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 0.219585\ s,\ 4.9\ GB/s
  299. $\ dd\ if=/path/to/mergerfs/mount/benchmark\ of=/dev/null\ bs=512\ count=102400
  300. 102400+0\ records\ in
  301. 102400+0\ records\ out
  302. 52428800\ bytes\ (52\ MB,\ 50\ MiB)\ copied,\ 0.757991\ s,\ 69.2\ MB/s
  303. $\ dd\ if=/path/to/mergerfs/mount/benchmark\ of=/dev/null\ bs=1M\ count=1024
  304. 1024+0\ records\ in
  305. 1024+0\ records\ out
  306. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 0.18405\ s,\ 5.8\ GB/s
  307. \f[]
  308. .fi
  309. .PP
  310. It\[aq]s important to test with different \f[C]obs\f[] (output block
  311. size) values since the relative overhead is greater with smaller values.
  312. As you can see above the size of a read or write can massively impact
  313. theoretical performance.
  314. If an application performs much worse through mergerfs it could very
  315. well be that it doesn\[aq]t optimally size its read and write requests.
  316. .SS xattr
  317. .PP
  318. Runtime extended attribute support can be managed via the \f[C]xattr\f[]
  319. option.
  320. By default it will passthrough any xattr calls.
  321. Given xattr support is rarely used and can have significant performance
  322. implications mergerfs allows it to be disabled at runtime.
  323. .PP
  324. \f[C]noattr\f[] will cause mergerfs to short circuit all xattr calls and
  325. return ENOATTR where appropriate.
  326. mergerfs still gets all the requests but they will not be forwarded on
  327. to the underlying filesystems.
  328. The runtime control will still function in this mode.
  329. .PP
  330. \f[C]notsup\f[] will cause mergerfs to return ENOTSUP for any xattr
  331. call.
  332. The difference with \f[C]noattr\f[] is that the kernel will cache this
  333. fact and itself short circuit future calls.
  334. This will be more efficient than \f[C]noattr\f[] but will cause
  335. mergerfs\[aq] runtime control via the hidden file to stop working.
  336. .SH FUNCTIONS / POLICIES / CATEGORIES
  337. .PP
  338. The POSIX filesystem API has a number of functions.
  339. \f[B]creat\f[], \f[B]stat\f[], \f[B]chown\f[], etc.
  340. In mergerfs these functions are grouped into 3 categories:
  341. \f[B]action\f[], \f[B]create\f[], and \f[B]search\f[].
  342. Functions and categories can be assigned a policy which dictates how
  343. \f[B]mergerfs\f[] behaves.
  344. Any policy can be assigned to a function or category though some may not
  345. be very useful in practice.
  346. For instance: \f[B]rand\f[] (random) may be useful for file creation
  347. (create) but could lead to very odd behavior if used for \f[C]chmod\f[]
  348. (though only if there were more than one copy of the file).
  349. .PP
  350. Policies, when called to create, will ignore drives which are readonly.
  351. This allows for readonly and read/write drives to be mixed together.
  352. Note that the drive must be explicitly mounted with the \f[B]ro\f[]
  353. mount option for this to work.
  354. .SS Function / Category classifications
  355. .PP
  356. .TS
  357. tab(@);
  358. lw(7.9n) lw(62.1n).
  359. T{
  360. Category
  361. T}@T{
  362. FUSE Functions
  363. T}
  364. _
  365. T{
  366. action
  367. T}@T{
  368. chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate,
  369. unlink, utimens
  370. T}
  371. T{
  372. create
  373. T}@T{
  374. create, mkdir, mknod, symlink
  375. T}
  376. T{
  377. search
  378. T}@T{
  379. access, getattr, getxattr, ioctl, listxattr, open, readlink
  380. T}
  381. T{
  382. N/A
  383. T}@T{
  384. fallocate, fgetattr, fsync, ftruncate, ioctl, read, readdir, release,
  385. statfs, write
  386. T}
  387. .TE
  388. .PP
  389. Due to FUSE limitations \f[B]ioctl\f[] behaves differently if its acting
  390. on a directory.
  391. It\[aq]ll use the \f[B]getattr\f[] policy to find and open the directory
  392. before issuing the \f[B]ioctl\f[].
  393. In other cases where something may be searched (to confirm a directory
  394. exists across all source mounts) \f[B]getattr\f[] will also be used.
  395. .SS Path Preservation
  396. .PP
  397. Policies, as described below, are of two core types.
  398. \f[C]path\ preserving\f[] and \f[C]non\-path\ preserving\f[].
  399. .PP
  400. All policies which start with \f[C]ep\f[] (\f[B]epff\f[],
  401. \f[B]eplfs\f[], \f[B]eplus\f[], \f[B]epmfs\f[], \f[B]eprand\f[]) are
  402. \f[C]path\ preserving\f[].
  403. \f[C]ep\f[] stands for \f[C]existing\ path\f[].
  404. .PP
  405. As the descriptions explain a path preserving policy will only consider
  406. drives where the relative path being accessed already exists.
  407. .PP
  408. When using non\-path preserving policies where something is created
  409. paths will be copied to target drives as necessary.
  410. .SS Policy descriptions
  411. .PP
  412. .TS
  413. tab(@);
  414. lw(16.6n) lw(53.4n).
  415. T{
  416. Policy
  417. T}@T{
  418. Description
  419. T}
  420. _
  421. T{
  422. all
  423. T}@T{
  424. Search category: acts like \f[B]ff\f[].
  425. Action category: apply to all found.
  426. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  427. \f[B]symlink\f[] it will apply to all found.
  428. \f[B]create\f[] works like \f[B]ff\f[].
  429. It will exclude readonly drives and those with free space less than
  430. \f[B]minfreespace\f[].
  431. T}
  432. T{
  433. epall (existing path, all)
  434. T}@T{
  435. Search category: acts like \f[B]epff\f[].
  436. Action category: apply to all found.
  437. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  438. \f[B]symlink\f[] it will apply to all existing paths found.
  439. \f[B]create\f[] works like \f[B]epff\f[].
  440. Excludes readonly drives and those with free space less than
  441. \f[B]minfreespace\f[].
  442. T}
  443. T{
  444. epff (existing path, first found)
  445. T}@T{
  446. Given the order of the drives, as defined at mount time or configured at
  447. runtime, act on the first one found where the relative path already
  448. exists.
  449. For \f[B]create\f[] category functions it will exclude readonly drives
  450. and those with free space less than \f[B]minfreespace\f[] (unless there
  451. is no other option).
  452. Falls back to \f[B]ff\f[].
  453. T}
  454. T{
  455. eplfs (existing path, least free space)
  456. T}@T{
  457. Of all the drives on which the relative path exists choose the drive
  458. with the least free space.
  459. For \f[B]create\f[] category functions it will exclude readonly drives
  460. and those with free space less than \f[B]minfreespace\f[].
  461. Falls back to \f[B]lfs\f[].
  462. T}
  463. T{
  464. eplus (existing path, least used space)
  465. T}@T{
  466. Of all the drives on which the relative path exists choose the drive
  467. with the least used space.
  468. For \f[B]create\f[] category functions it will exclude readonly drives
  469. and those with free space less than \f[B]minfreespace\f[].
  470. Falls back to \f[B]lus\f[].
  471. T}
  472. T{
  473. epmfs (existing path, most free space)
  474. T}@T{
  475. Of all the drives on which the relative path exists choose the drive
  476. with the most free space.
  477. For \f[B]create\f[] category functions it will exclude readonly drives
  478. and those with free space less than \f[B]minfreespace\f[].
  479. Falls back to \f[B]mfs\f[].
  480. T}
  481. T{
  482. eprand (existing path, random)
  483. T}@T{
  484. Calls \f[B]epall\f[] and then randomizes.
  485. Otherwise behaves the same as \f[B]epall\f[].
  486. T}
  487. T{
  488. erofs
  489. T}@T{
  490. Exclusively return \f[B]\-1\f[] with \f[B]errno\f[] set to
  491. \f[B]EROFS\f[] (Read\-only filesystem).
  492. By setting \f[B]create\f[] functions to this you can in effect turn the
  493. filesystem mostly readonly.
  494. T}
  495. T{
  496. ff (first found)
  497. T}@T{
  498. Given the order of the drives, as defined at mount time or configured at
  499. runtime, act on the first one found.
  500. For \f[B]create\f[] category functions it will exclude readonly drives
  501. and those with free space less than \f[B]minfreespace\f[] (unless there
  502. is no other option).
  503. T}
  504. T{
  505. lfs (least free space)
  506. T}@T{
  507. Pick the drive with the least available free space.
  508. For \f[B]create\f[] category functions it will exclude readonly drives
  509. and those with free space less than \f[B]minfreespace\f[].
  510. Falls back to \f[B]mfs\f[].
  511. T}
  512. T{
  513. lus (least used space)
  514. T}@T{
  515. Pick the drive with the least used space.
  516. For \f[B]create\f[] category functions it will exclude readonly drives
  517. and those with free space less than \f[B]minfreespace\f[].
  518. Falls back to \f[B]mfs\f[].
  519. T}
  520. T{
  521. mfs (most free space)
  522. T}@T{
  523. Pick the drive with the most available free space.
  524. For \f[B]create\f[] category functions it will exclude readonly drives.
  525. Falls back to \f[B]ff\f[].
  526. T}
  527. T{
  528. newest
  529. T}@T{
  530. Pick the file / directory with the largest mtime.
  531. For \f[B]create\f[] category functions it will exclude readonly drives
  532. and those with free space less than \f[B]minfreespace\f[] (unless there
  533. is no other option).
  534. T}
  535. T{
  536. rand (random)
  537. T}@T{
  538. Calls \f[B]all\f[] and then randomizes.
  539. T}
  540. .TE
  541. .SS Defaults
  542. .PP
  543. .TS
  544. tab(@);
  545. l l.
  546. T{
  547. Category
  548. T}@T{
  549. Policy
  550. T}
  551. _
  552. T{
  553. action
  554. T}@T{
  555. all
  556. T}
  557. T{
  558. create
  559. T}@T{
  560. epmfs
  561. T}
  562. T{
  563. search
  564. T}@T{
  565. ff
  566. T}
  567. .TE
  568. .SS rename & link
  569. .PP
  570. \f[B]NOTE:\f[] If you\[aq]re receiving errors from software when files
  571. are moved / renamed then you should consider changing the create policy
  572. to one which is \f[B]not\f[] path preserving, enabling
  573. \f[C]ignorepponrename\f[], or contacting the author of the offending
  574. software and requesting that \f[C]EXDEV\f[] be properly handled.
  575. .PP
  576. rename (http://man7.org/linux/man-pages/man2/rename.2.html) is a tricky
  577. function in a merged system.
  578. Under normal situations rename only works within a single filesystem or
  579. device.
  580. If a rename can\[aq]t be done atomically due to the source and
  581. destination paths existing on different mount points it will return
  582. \f[B]\-1\f[] with \f[B]errno = EXDEV\f[] (cross device).
  583. .PP
  584. Originally mergerfs would return EXDEV whenever a rename was requested
  585. which was cross directory in any way.
  586. This made the code simple and was technically complient with POSIX
  587. requirements.
  588. However, many applications fail to handle EXDEV at all and treat it as a
  589. normal error or otherwise handle it poorly.
  590. Such apps include: gvfsd\-fuse v1.20.3 and prior, Finder / CIFS/SMB
  591. client in Apple OSX 10.9+, NZBGet, Samba\[aq]s recycling bin feature.
  592. .PP
  593. As a result a compromise was made in order to get most software to work
  594. while still obeying mergerfs\[aq] policies.
  595. Below is the rather complicated logic.
  596. .IP \[bu] 2
  597. If using a \f[B]create\f[] policy which tries to preserve directory
  598. paths (epff,eplfs,eplus,epmfs)
  599. .IP \[bu] 2
  600. Using the \f[B]rename\f[] policy get the list of files to rename
  601. .IP \[bu] 2
  602. For each file attempt rename:
  603. .RS 2
  604. .IP \[bu] 2
  605. If failure with ENOENT run \f[B]create\f[] policy
  606. .IP \[bu] 2
  607. If create policy returns the same drive as currently evaluating then
  608. clone the path
  609. .IP \[bu] 2
  610. Re\-attempt rename
  611. .RE
  612. .IP \[bu] 2
  613. If \f[B]any\f[] of the renames succeed the higher level rename is
  614. considered a success
  615. .IP \[bu] 2
  616. If \f[B]no\f[] renames succeed the first error encountered will be
  617. returned
  618. .IP \[bu] 2
  619. On success:
  620. .RS 2
  621. .IP \[bu] 2
  622. Remove the target from all drives with no source file
  623. .IP \[bu] 2
  624. Remove the source from all drives which failed to rename
  625. .RE
  626. .IP \[bu] 2
  627. If using a \f[B]create\f[] policy which does \f[B]not\f[] try to
  628. preserve directory paths
  629. .IP \[bu] 2
  630. Using the \f[B]rename\f[] policy get the list of files to rename
  631. .IP \[bu] 2
  632. Using the \f[B]getattr\f[] policy get the target path
  633. .IP \[bu] 2
  634. For each file attempt rename:
  635. .RS 2
  636. .IP \[bu] 2
  637. If the source drive != target drive:
  638. .IP \[bu] 2
  639. Clone target path from target drive to source drive
  640. .IP \[bu] 2
  641. Rename
  642. .RE
  643. .IP \[bu] 2
  644. If \f[B]any\f[] of the renames succeed the higher level rename is
  645. considered a success
  646. .IP \[bu] 2
  647. If \f[B]no\f[] renames succeed the first error encountered will be
  648. returned
  649. .IP \[bu] 2
  650. On success:
  651. .RS 2
  652. .IP \[bu] 2
  653. Remove the target from all drives with no source file
  654. .IP \[bu] 2
  655. Remove the source from all drives which failed to rename
  656. .RE
  657. .PP
  658. The the removals are subject to normal entitlement checks.
  659. .PP
  660. The above behavior will help minimize the likelihood of EXDEV being
  661. returned but it will still be possible.
  662. .PP
  663. \f[B]link\f[] uses the same basic strategy.
  664. .SS readdir
  665. .PP
  666. readdir (http://linux.die.net/man/3/readdir) is different from all other
  667. filesystem functions.
  668. While it could have it\[aq]s own set of policies to tweak its behavior
  669. at this time it provides a simple union of files and directories found.
  670. Remember that any action or information queried about these files and
  671. directories come from the respective function.
  672. For instance: an \f[B]ls\f[] is a \f[B]readdir\f[] and for each
  673. file/directory returned \f[B]getattr\f[] is called.
  674. Meaning the policy of \f[B]getattr\f[] is responsible for choosing the
  675. file/directory which is the source of the metadata you see in an
  676. \f[B]ls\f[].
  677. .SS statvfs
  678. .PP
  679. statvfs (http://linux.die.net/man/2/statvfs) normalizes the source
  680. drives based on the fragment size and sums the number of adjusted blocks
  681. and inodes.
  682. This means you will see the combined space of all sources.
  683. Total, used, and free.
  684. The sources however are dedupped based on the drive so multiple sources
  685. on the same drive will not result in double counting it\[aq]s space.
  686. .SH BUILDING
  687. .PP
  688. \f[B]NOTE:\f[] Prebuilt packages can be found at:
  689. https://github.com/trapexit/mergerfs/releases
  690. .PP
  691. First get the code from github (http://github.com/trapexit/mergerfs).
  692. .IP
  693. .nf
  694. \f[C]
  695. $\ git\ clone\ https://github.com/trapexit/mergerfs.git
  696. $\ #\ or
  697. $\ wget\ https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs\-<ver>.tar.gz
  698. \f[]
  699. .fi
  700. .SS Debian / Ubuntu
  701. .IP
  702. .nf
  703. \f[C]
  704. $\ sudo\ apt\-get\ \-y\ update
  705. $\ sudo\ apt\-get\ \-y\ install\ git\ make
  706. $\ cd\ mergerfs
  707. $\ make\ install\-build\-pkgs
  708. $\ #\ build\-essential\ git\ g++\ debhelper\ python\ automake\ libtool\ lsb\-release
  709. $\ make\ deb
  710. $\ sudo\ dpkg\ \-i\ ../mergerfs_version_arch.deb
  711. \f[]
  712. .fi
  713. .SS Fedora
  714. .IP
  715. .nf
  716. \f[C]
  717. $\ su\ \-
  718. #\ dnf\ \-y\ update
  719. #\ dnf\ \-y\ install\ git\ make
  720. #\ cd\ mergerfs
  721. #\ make\ install\-build\-pkgs
  722. #\ #\ rpm\-build\ gcc\-c++\ which\ python\ automake\ libtool\ gettext\-devel
  723. #\ make\ rpm
  724. #\ rpm\ \-i\ rpmbuild/RPMS/<arch>/mergerfs\-<verion>.<arch>.rpm
  725. \f[]
  726. .fi
  727. .SS Generically
  728. .PP
  729. Have git, g++, make, python, automake, libtool installed.
  730. .IP
  731. .nf
  732. \f[C]
  733. $\ cd\ mergerfs
  734. $\ make
  735. $\ sudo\ make\ install
  736. \f[]
  737. .fi
  738. .SS Generically with system libfuse
  739. .PP
  740. \f[B]NOTE:\f[] Configurable threading and thus \f[C]\-o\ threads=num\f[]
  741. option will be unavailable when built with system libfuse.
  742. .PP
  743. Have git, g++, make, python, pkg\-config installed.
  744. Also, install libfuse >= 2.9.7 (but not libfuse\-3.x) and matching
  745. libfuse\-dev (or libfuse\-devel).
  746. .IP
  747. .nf
  748. \f[C]
  749. $\ cd\ mergerfs
  750. $\ make\ INTERNAL_FUSE=0
  751. $\ sudo\ make\ INTERNAL_FUSE=0\ install
  752. \f[]
  753. .fi
  754. .SH RUNTIME
  755. .SS .mergerfs pseudo file
  756. .IP
  757. .nf
  758. \f[C]
  759. <mountpoint>/.mergerfs
  760. \f[]
  761. .fi
  762. .PP
  763. There is a pseudo file available at the mount point which allows for the
  764. runtime modification of certain \f[B]mergerfs\f[] options.
  765. The file will not show up in \f[B]readdir\f[] but can be
  766. \f[B]stat\f[]\[aq]ed and manipulated via
  767. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls.
  768. .PP
  769. Any changes made at runtime are \f[B]not\f[] persisted.
  770. If you wish for values to persist they must be included as options
  771. wherever you configure the mounting of mergerfs (/etc/fstab).
  772. .SS Keys
  773. .PP
  774. Use \f[C]xattr\ \-l\ /mount/point/.mergerfs\f[] to see all supported
  775. keys.
  776. Some are informational and therefore readonly.
  777. .SS user.mergerfs.srcmounts
  778. .PP
  779. Used to query or modify the list of source mounts.
  780. When modifying there are several shortcuts to easy manipulation of the
  781. list.
  782. .PP
  783. .TS
  784. tab(@);
  785. l l.
  786. T{
  787. Value
  788. T}@T{
  789. Description
  790. T}
  791. _
  792. T{
  793. [list]
  794. T}@T{
  795. set
  796. T}
  797. T{
  798. +<[list]
  799. T}@T{
  800. prepend
  801. T}
  802. T{
  803. +>[list]
  804. T}@T{
  805. append
  806. T}
  807. T{
  808. \-[list]
  809. T}@T{
  810. remove all values provided
  811. T}
  812. T{
  813. \-<
  814. T}@T{
  815. remove first in list
  816. T}
  817. T{
  818. \->
  819. T}@T{
  820. remove last in list
  821. T}
  822. .TE
  823. .PP
  824. \f[C]xattr\ \-w\ user.mergerfs.srcmounts\ +</mnt/drive3\ /mnt/pool/.mergerfs\f[]
  825. .SS minfreespace
  826. .PP
  827. Input: interger with an optional multiplier suffix.
  828. \f[B]K\f[], \f[B]M\f[], or \f[B]G\f[].
  829. .PP
  830. Output: value in bytes
  831. .SS moveonenospc
  832. .PP
  833. Input: \f[B]true\f[] and \f[B]false\f[]
  834. .PP
  835. Ouput: \f[B]true\f[] or \f[B]false\f[]
  836. .SS categories / funcs
  837. .PP
  838. Input: short policy string as described elsewhere in this document
  839. .PP
  840. Output: the policy string except for categories where its funcs have
  841. multiple types.
  842. In that case it will be a comma separated list
  843. .SS Example
  844. .IP
  845. .nf
  846. \f[C]
  847. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-l\ .mergerfs
  848. user.mergerfs.srcmounts:\ /mnt/a:/mnt/b
  849. user.mergerfs.minfreespace:\ 4294967295
  850. user.mergerfs.moveonenospc:\ false
  851. \&...
  852. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  853. ff
  854. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.category.search\ newest\ .mergerfs
  855. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  856. newest
  857. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.srcmounts\ +/mnt/c\ .mergerfs
  858. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.srcmounts\ .mergerfs
  859. /mnt/a:/mnt/b:/mnt/c
  860. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.srcmounts\ =/mnt/c\ .mergerfs
  861. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.srcmounts\ .mergerfs
  862. /mnt/c
  863. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.srcmounts\ \[aq]+</mnt/a:/mnt/b\[aq]\ .mergerfs
  864. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.srcmounts\ .mergerfs
  865. /mnt/a:/mnt/b:/mnt/c
  866. \f[]
  867. .fi
  868. .SS file / directory xattrs
  869. .PP
  870. While they won\[aq]t show up when using
  871. listxattr (http://linux.die.net/man/2/listxattr) \f[B]mergerfs\f[]
  872. offers a number of special xattrs to query information about the files
  873. served.
  874. To access the values you will need to issue a
  875. getxattr (http://linux.die.net/man/2/getxattr) for one of the following:
  876. .IP \[bu] 2
  877. \f[B]user.mergerfs.basepath:\f[] the base mount point for the file given
  878. the current getattr policy
  879. .IP \[bu] 2
  880. \f[B]user.mergerfs.relpath:\f[] the relative path of the file from the
  881. perspective of the mount point
  882. .IP \[bu] 2
  883. \f[B]user.mergerfs.fullpath:\f[] the full path of the original file
  884. given the getattr policy
  885. .IP \[bu] 2
  886. \f[B]user.mergerfs.allpaths:\f[] a NUL (\[aq]\[aq]) separated list of
  887. full paths to all files found
  888. .IP
  889. .nf
  890. \f[C]
  891. [trapexit:/mnt/mergerfs]\ $\ ls
  892. A\ B\ C
  893. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.fullpath\ A
  894. /mnt/a/full/path/to/A
  895. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.basepath\ A
  896. /mnt/a
  897. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.relpath\ A
  898. /full/path/to/A
  899. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.allpaths\ A\ |\ tr\ \[aq]\\0\[aq]\ \[aq]\\n\[aq]
  900. /mnt/a/full/path/to/A
  901. /mnt/b/full/path/to/A
  902. \f[]
  903. .fi
  904. .SH TOOLING
  905. .IP \[bu] 2
  906. https://github.com/trapexit/mergerfs\-tools
  907. .IP \[bu] 2
  908. mergerfs.ctl: A tool to make it easier to query and configure mergerfs
  909. at runtime
  910. .IP \[bu] 2
  911. mergerfs.fsck: Provides permissions and ownership auditing and the
  912. ability to fix them
  913. .IP \[bu] 2
  914. mergerfs.dedup: Will help identify and optionally remove duplicate files
  915. .IP \[bu] 2
  916. mergerfs.dup: Ensure there are at least N copies of a file across the
  917. pool
  918. .IP \[bu] 2
  919. mergerfs.balance: Rebalance files across drives by moving them from the
  920. most filled to the least filled
  921. .IP \[bu] 2
  922. mergerfs.mktrash: Creates FreeDesktop.org Trash specification compatible
  923. directories on a mergerfs mount
  924. .IP \[bu] 2
  925. https://github.com/trapexit/scorch
  926. .IP \[bu] 2
  927. scorch: A tool to help discover silent corruption of files and keep
  928. track of files
  929. .IP \[bu] 2
  930. https://github.com/trapexit/bbf
  931. .IP \[bu] 2
  932. bbf (bad block finder): a tool to scan for and \[aq]fix\[aq] hard drive
  933. bad blocks and find the files using those blocks
  934. .SH CACHING
  935. .PP
  936. MergerFS does not natively support any sort of caching.
  937. Most users have no use for such a feature and it would greatly
  938. complicate the code.
  939. However, there are a few situations where a cache drive could help with
  940. a typical mergerfs setup.
  941. .IP "1." 3
  942. Fast network, slow drives, many readers: You\[aq]ve a 10+Gbps network
  943. with many readers and your regular drives can\[aq]t keep up.
  944. .IP "2." 3
  945. Fast network, slow drives, small\[aq]ish bursty writes: You have a
  946. 10+Gbps network and wish to transfer amounts of data less than your
  947. cache drive but wish to do so quickly.
  948. .PP
  949. The below will mostly address usecase #2.
  950. It will also work for #1 assuming the data is regularly accessed and was
  951. placed into the system via this method.
  952. Otherwise a similar script may need to be written to populate the cache
  953. from the backing pool.
  954. .IP "1." 3
  955. Create 2 mergerfs pools.
  956. One which includes just the backing drives and one which has both the
  957. cache drives (SSD,NVME,etc.) and backing drives.
  958. .IP "2." 3
  959. The \[aq]cache\[aq] pool should have the cache drives listed first.
  960. .IP "3." 3
  961. The best policies to use for the \[aq]cache\[aq] pool would probably be
  962. \f[C]ff\f[], \f[C]epff\f[], \f[C]lfs\f[], or \f[C]eplfs\f[].
  963. The latter two under the assumption that the cache drive(s) are far
  964. smaller than the backing drives.
  965. If using path preserving policies remember that you\[aq]ll need to
  966. manually create the core directories of those paths you wish to be
  967. cached.
  968. (Be sure the permissions are in sync.
  969. Use \f[C]mergerfs.fsck\f[] to check / correct them.)
  970. .IP "4." 3
  971. Enable \f[C]moveonenospc\f[] and set \f[C]minfreespace\f[]
  972. appropriately.
  973. .IP "5." 3
  974. Set your programs to use the cache pool.
  975. .IP "6." 3
  976. Save one of the below scripts.
  977. .IP "7." 3
  978. Use \f[C]crontab\f[] (as root) to schedule the command at whatever
  979. frequency is appropriate for your workflow.
  980. .SS Time based expiring
  981. .PP
  982. Move files from cache to backing pool based only on the last time the
  983. file was accessed.
  984. .IP
  985. .nf
  986. \f[C]
  987. #!/bin/bash
  988. if\ [\ $#\ !=\ 3\ ];\ then
  989. \ \ echo\ "usage:\ $0\ <cache\-drive>\ <backing\-pool>\ <days\-old>"
  990. \ \ exit\ 1
  991. fi
  992. CACHE="${1}"
  993. BACKING="${2}"
  994. N=${3}
  995. find\ "${CACHE}"\ \-type\ f\ \-atime\ +${N}\ \-printf\ \[aq]%P\\n\[aq]\ |\ \\
  996. \ \ rsync\ \-\-files\-from=\-\ \-aq\ \-\-remove\-source\-files\ "${CACHE}/"\ "${BACKING}/"
  997. \f[]
  998. .fi
  999. .SS Percentage full expiring
  1000. .PP
  1001. Move the oldest file from the cache to the backing pool.
  1002. Continue till below percentage threshold.
  1003. .IP
  1004. .nf
  1005. \f[C]
  1006. #!/bin/bash
  1007. if\ [\ $#\ !=\ 3\ ];\ then
  1008. \ \ echo\ "usage:\ $0\ <cache\-drive>\ <backing\-pool>\ <percentage>"
  1009. \ \ exit\ 1
  1010. fi
  1011. CACHE="${1}"
  1012. BACKING="${2}"
  1013. PERCENTAGE=${3}
  1014. set\ \-o\ errexit
  1015. while\ [\ $(df\ \-\-output=pcent\ "${CACHE}"\ |\ grep\ \-v\ Use\ |\ cut\ \-d\[aq]%\[aq]\ \-f1)\ \-gt\ ${PERCENTAGE}\ ]
  1016. do
  1017. \ \ \ \ FILE=$(find\ "${CACHE}"\ \-type\ f\ \-printf\ \[aq]%A\@\ %P\\n\[aq]\ |\ \\
  1018. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sort\ |\ \\
  1019. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ head\ \-n\ 1\ |\ \\
  1020. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cut\ \-d\[aq]\ \[aq]\ \-f2\-)
  1021. \ \ \ \ test\ \-n\ "${FILE}"
  1022. \ \ \ \ rsync\ \-aq\ \-\-remove\-source\-files\ "${CACHE}/./${FILE}"\ "${BACKING}/"
  1023. done
  1024. \f[]
  1025. .fi
  1026. .SH TIPS / NOTES
  1027. .IP \[bu] 2
  1028. The recommended base options are
  1029. \f[B]defaults,allow_other,direct_io,use_ino,hard_remove\f[].
  1030. (\f[B]use_ino\f[] will only work when used with mergerfs 2.18.0 and
  1031. above.)
  1032. .IP \[bu] 2
  1033. Run mergerfs as \f[C]root\f[] unless you\[aq]re merging paths which are
  1034. owned by the same user otherwise strange permission issues may arise.
  1035. .IP \[bu] 2
  1036. https://github.com/trapexit/backup\-and\-recovery\-howtos : A set of
  1037. guides / howtos on creating a data storage system, backing it up,
  1038. maintaining it, and recovering from failure.
  1039. .IP \[bu] 2
  1040. If you don\[aq]t see some directories and files you expect in a merged
  1041. point or policies seem to skip drives be sure the user has permission to
  1042. all the underlying directories.
  1043. Use \f[C]mergerfs.fsck\f[] to audit the drive for out of sync
  1044. permissions.
  1045. .IP \[bu] 2
  1046. Do \f[B]not\f[] use \f[C]direct_io\f[] if you expect applications (such
  1047. as rtorrent) to mmap (http://linux.die.net/man/2/mmap) files.
  1048. It is not currently supported in FUSE w/ \f[C]direct_io\f[] enabled.
  1049. Enabling \f[C]dropcacheonclose\f[] is recommended when
  1050. \f[C]direct_io\f[] is disabled.
  1051. .IP \[bu] 2
  1052. Since POSIX gives you only error or success on calls its difficult to
  1053. determine the proper behavior when applying the behavior to multiple
  1054. targets.
  1055. \f[B]mergerfs\f[] will return an error only if all attempts of an action
  1056. fail.
  1057. Any success will lead to a success returned.
  1058. This means however that some odd situations may arise.
  1059. .IP \[bu] 2
  1060. Kodi (http://kodi.tv), Plex (http://plex.tv),
  1061. Subsonic (http://subsonic.org), etc.
  1062. can use directory mtime (http://linux.die.net/man/2/stat) to more
  1063. efficiently determine whether to scan for new content rather than simply
  1064. performing a full scan.
  1065. If using the default \f[B]getattr\f[] policy of \f[B]ff\f[] its possible
  1066. those programs will miss an update on account of it returning the first
  1067. directory found\[aq]s \f[B]stat\f[] info and its a later directory on
  1068. another mount which had the \f[B]mtime\f[] recently updated.
  1069. To fix this you will want to set \f[B]func.getattr=newest\f[].
  1070. Remember though that this is just \f[B]stat\f[].
  1071. If the file is later \f[B]open\f[]\[aq]ed or \f[B]unlink\f[]\[aq]ed and
  1072. the policy is different for those then a completely different file or
  1073. directory could be acted on.
  1074. .IP \[bu] 2
  1075. Some policies mixed with some functions may result in strange behaviors.
  1076. Not that some of these behaviors and race conditions couldn\[aq]t happen
  1077. outside \f[B]mergerfs\f[] but that they are far more likely to occur on
  1078. account of the attempt to merge together multiple sources of data which
  1079. could be out of sync due to the different policies.
  1080. .IP \[bu] 2
  1081. For consistency its generally best to set \f[B]category\f[] wide
  1082. policies rather than individual \f[B]func\f[]\[aq]s.
  1083. This will help limit the confusion of tools such as
  1084. rsync (http://linux.die.net/man/1/rsync).
  1085. However, the flexibility is there if needed.
  1086. .SH KNOWN ISSUES / BUGS
  1087. .SS directory mtime is not being updated
  1088. .PP
  1089. Remember that the default policy for \f[C]getattr\f[] is \f[C]ff\f[].
  1090. The information for the first directory found will be returned.
  1091. If it wasn\[aq]t the directory which had been updated then it will
  1092. appear outdated.
  1093. .PP
  1094. The reason this is the default is because any other policy would be far
  1095. more expensive and for many applications it is unnecessary.
  1096. To always return the directory with the most recent mtime or a faked
  1097. value based on all found would require a scan of all drives.
  1098. That alone is far more expensive than \f[C]ff\f[] but would also
  1099. possibly spin up sleeping drives.
  1100. .PP
  1101. If you always want the directory information from the one with the most
  1102. recent mtime then use the \f[C]newest\f[] policy for \f[C]getattr\f[].
  1103. .SS cached memory appears greater than it should be
  1104. .PP
  1105. Use the \f[C]direct_io\f[] option as described above.
  1106. Due to what mergerfs is doing there ends up being two caches of a file
  1107. under normal usage.
  1108. One from the underlying filesystem and one from mergerfs.
  1109. Enabling \f[C]direct_io\f[] removes the mergerfs cache.
  1110. This saves on memory but means the kernel needs to communicate with
  1111. mergerfs more often and can therefore result in slower speeds.
  1112. .PP
  1113. Since enabling \f[C]direct_io\f[] disables \f[C]mmap\f[] this is not an
  1114. ideal situation however write speeds should be increased.
  1115. .PP
  1116. If \f[C]direct_io\f[] is disabled it is probably a good idea to enable
  1117. \f[C]dropcacheonclose\f[] to minimize double caching.
  1118. .SS NFS clients don\[aq]t work
  1119. .PP
  1120. Some NFS clients appear to fail when a mergerfs mount is exported.
  1121. Kodi in particular seems to have issues.
  1122. .PP
  1123. Try enabling the \f[C]use_ino\f[] option.
  1124. Some have reported that it fixes the issue.
  1125. .SS rtorrent fails with ENODEV (No such device)
  1126. .PP
  1127. Be sure to turn off \f[C]direct_io\f[].
  1128. rtorrent and some other applications use
  1129. mmap (http://linux.die.net/man/2/mmap) to read and write to files and
  1130. offer no failback to traditional methods.
  1131. FUSE does not currently support mmap while using \f[C]direct_io\f[].
  1132. There will be a performance penalty on writes with \f[C]direct_io\f[]
  1133. off as well as the problem of double caching but it\[aq]s the only way
  1134. to get such applications to work.
  1135. If the performance loss is too high for other apps you can mount
  1136. mergerfs twice.
  1137. Once with \f[C]direct_io\f[] enabled and one without it.
  1138. .SS Plex doesn\[aq]t work with mergerfs
  1139. .PP
  1140. It does.
  1141. If you\[aq]re trying to put Plex\[aq]s config / metadata on mergerfs you
  1142. have to leave \f[C]direct_io\f[] off because Plex is using sqlite which
  1143. apparently needs mmap.
  1144. mmap doesn\[aq]t work with \f[C]direct_io\f[].
  1145. .PP
  1146. If the issue is that scanning doesn\[aq]t seem to pick up media then be
  1147. sure to set \f[C]func.getattr=newest\f[] as mentioned above.
  1148. .SS mmap performance is really bad
  1149. .PP
  1150. There is a bug (https://lkml.org/lkml/2016/3/16/260) in caching which
  1151. affects overall performance of mmap through FUSE in Linux 4.x kernels.
  1152. It is fixed in 4.4.10 and 4.5.4 (https://lkml.org/lkml/2016/5/11/59).
  1153. .SS When a program tries to move or rename a file it fails
  1154. .PP
  1155. Please read the section above regarding rename & link (#rename--link).
  1156. .PP
  1157. The problem is that many applications do not properly handle
  1158. \f[C]EXDEV\f[] errors which \f[C]rename\f[] and \f[C]link\f[] may return
  1159. even though they are perfectly valid situations which do not indicate
  1160. actual drive or OS errors.
  1161. The error will only be returned by mergerfs if using a path preserving
  1162. policy as described in the policy section above.
  1163. If you do not care about path preservation simply change the mergerfs
  1164. policy to the non\-path preserving version.
  1165. For example: \f[C]\-o\ category.create=mfs\f[]
  1166. .PP
  1167. Ideally the offending software would be fixed and it is recommended that
  1168. if you run into this problem you contact the software\[aq]s author and
  1169. request proper handling of \f[C]EXDEV\f[] errors.
  1170. .SS Samba: Moving files / directories fails
  1171. .PP
  1172. Workaround: Copy the file/directory and then remove the original rather
  1173. than move.
  1174. .PP
  1175. This isn\[aq]t an issue with Samba but some SMB clients.
  1176. GVFS\-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed
  1177. to handle certain error codes correctly.
  1178. Particularly \f[B]STATUS_NOT_SAME_DEVICE\f[] which comes from the
  1179. \f[B]EXDEV\f[] which is returned by \f[B]rename\f[] when the call is
  1180. crossing mount points.
  1181. When a program gets an \f[B]EXDEV\f[] it needs to explicitly take an
  1182. alternate action to accomplish it\[aq]s goal.
  1183. In the case of \f[B]mv\f[] or similar it tries \f[B]rename\f[] and on
  1184. \f[B]EXDEV\f[] falls back to a manual copying of data between the two
  1185. locations and unlinking the source.
  1186. In these older versions of GVFS\-fuse if it received \f[B]EXDEV\f[] it
  1187. would translate that into \f[B]EIO\f[].
  1188. This would cause \f[B]mv\f[] or most any application attempting to move
  1189. files around on that SMB share to fail with a IO error.
  1190. .PP
  1191. GVFS\-fuse v1.22.0 (https://bugzilla.gnome.org/show_bug.cgi?id=734568)
  1192. and above fixed this issue but a large number of systems use the older
  1193. release.
  1194. On Ubuntu the version can be checked by issuing
  1195. \f[C]apt\-cache\ showpkg\ gvfs\-fuse\f[].
  1196. Most distros released in 2015 seem to have the updated release and will
  1197. work fine but older systems may not.
  1198. Upgrading gvfs\-fuse or the distro in general will address the problem.
  1199. .PP
  1200. In Apple\[aq]s MacOSX 10.9 they replaced Samba (client and server) with
  1201. their own product.
  1202. It appears their new client does not handle \f[B]EXDEV\f[] either and
  1203. responds similar to older release of gvfs on Linux.
  1204. .SS Trashing files occasionally fails
  1205. .PP
  1206. This is the same issue as with Samba.
  1207. \f[C]rename\f[] returns \f[C]EXDEV\f[] (in our case that will really
  1208. only happen with path preserving policies like \f[C]epmfs\f[]) and the
  1209. software doesn\[aq]t handle the situtation well.
  1210. This is unfortunately a common failure of software which moves files
  1211. around.
  1212. The standard indicates that an implementation \f[C]MAY\f[] choose to
  1213. support non\-user home directory trashing of files (which is a
  1214. \f[C]MUST\f[]).
  1215. The implementation \f[C]MAY\f[] also support "top directory trashes"
  1216. which many probably do.
  1217. .PP
  1218. To create a \f[C]$topdir/.Trash\f[] directory as defined in the standard
  1219. use the mergerfs\-tools (https://github.com/trapexit/mergerfs-tools)
  1220. tool \f[C]mergerfs.mktrash\f[].
  1221. .SS tar: Directory renamed before its status could be extracted
  1222. .PP
  1223. Make sure to use the \f[C]use_ino\f[] option.
  1224. .SS Supplemental user groups
  1225. .PP
  1226. Due to the overhead of
  1227. getgroups/setgroups (http://linux.die.net/man/2/setgroups) mergerfs
  1228. utilizes a cache.
  1229. This cache is opportunistic and per thread.
  1230. Each thread will query the supplemental groups for a user when that
  1231. particular thread needs to change credentials and will keep that data
  1232. for the lifetime of the thread.
  1233. This means that if a user is added to a group it may not be picked up
  1234. without the restart of mergerfs.
  1235. However, since the high level FUSE API\[aq]s (at least the standard
  1236. version) thread pool dynamically grows and shrinks it\[aq]s possible
  1237. that over time a thread will be killed and later a new thread with no
  1238. cache will start and query the new data.
  1239. .PP
  1240. The gid cache uses fixed storage to simplify the design and be
  1241. compatible with older systems which may not have C++11 compilers.
  1242. There is enough storage for 256 users\[aq] supplemental groups.
  1243. Each user is allowed upto 32 supplemental groups.
  1244. Linux >= 2.6.3 allows upto 65535 groups per user but most other *nixs
  1245. allow far less.
  1246. NFS allowing only 16.
  1247. The system does handle overflow gracefully.
  1248. If the user has more than 32 supplemental groups only the first 32 will
  1249. be used.
  1250. If more than 256 users are using the system when an uncached user is
  1251. found it will evict an existing user\[aq]s cache at random.
  1252. So long as there aren\[aq]t more than 256 active users this should be
  1253. fine.
  1254. If either value is too low for your needs you will have to modify
  1255. \f[C]gidcache.hpp\f[] to increase the values.
  1256. Note that doing so will increase the memory needed by each thread.
  1257. .SS mergerfs or libfuse crashing
  1258. .PP
  1259. \f[B]NOTE:\f[] as of mergerfs 2.22.0 it includes the most recent version
  1260. of libfuse (or requires libfuse\-2.9.7) so any crash should be reported.
  1261. For older releases continue reading...
  1262. .PP
  1263. If suddenly the mergerfs mount point disappears and
  1264. \f[C]Transport\ endpoint\ is\ not\ connected\f[] is returned when
  1265. attempting to perform actions within the mount directory \f[B]and\f[]
  1266. the version of libfuse (use \f[C]mergerfs\ \-v\f[] to find the version)
  1267. is older than \f[C]2.9.4\f[] its likely due to a bug in libfuse.
  1268. Affected versions of libfuse can be found in Debian Wheezy, Ubuntu
  1269. Precise and others.
  1270. .PP
  1271. In order to fix this please install newer versions of libfuse.
  1272. If using a Debian based distro (Debian,Ubuntu,Mint) you can likely just
  1273. install newer versions of
  1274. libfuse (https://packages.debian.org/unstable/libfuse2) and
  1275. fuse (https://packages.debian.org/unstable/fuse) from the repo of a
  1276. newer release.
  1277. .SS mergerfs appears to be crashing or exiting
  1278. .PP
  1279. There seems to be an issue with Linux version \f[C]4.9.0\f[] and above
  1280. in which an invalid message appears to be transmitted to libfuse (used
  1281. by mergerfs) causing it to exit.
  1282. No messages will be printed in any logs as its not a proper crash.
  1283. Debugging of the issue is still ongoing and can be followed via the
  1284. fuse\-devel
  1285. thread (https://sourceforge.net/p/fuse/mailman/message/35662577).
  1286. .SS mergerfs under heavy load and memory preasure leads to kernel panic
  1287. .PP
  1288. https://lkml.org/lkml/2016/9/14/527
  1289. .IP
  1290. .nf
  1291. \f[C]
  1292. [25192.515454]\ kernel\ BUG\ at\ /build/linux\-a2WvEb/linux\-4.4.0/mm/workingset.c:346!
  1293. [25192.517521]\ invalid\ opcode:\ 0000\ [#1]\ SMP
  1294. [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]
  1295. [25192.540910]\ CPU:\ 2\ PID:\ 63\ Comm:\ kswapd0\ Not\ tainted\ 4.4.0\-36\-generic\ #55\-Ubuntu
  1296. [25192.543411]\ Hardware\ name:\ System\ manufacturer\ System\ Product\ Name/P8H67\-M\ PRO,\ BIOS\ 3904\ 04/27/2013
  1297. [25192.545840]\ task:\ ffff88040cae6040\ ti:\ ffff880407488000\ task.ti:\ ffff880407488000
  1298. [25192.548277]\ RIP:\ 0010:[<ffffffff811ba501>]\ \ [<ffffffff811ba501>]\ shadow_lru_isolate+0x181/0x190
  1299. [25192.550706]\ RSP:\ 0018:ffff88040748bbe0\ \ EFLAGS:\ 00010002
  1300. [25192.553127]\ RAX:\ 0000000000001c81\ RBX:\ ffff8802f91ee928\ RCX:\ ffff8802f91eeb38
  1301. [25192.555544]\ RDX:\ ffff8802f91ee938\ RSI:\ ffff8802f91ee928\ RDI:\ ffff8804099ba2c0
  1302. [25192.557914]\ RBP:\ ffff88040748bc08\ R08:\ 000000000001a7b6\ R09:\ 000000000000003f
  1303. [25192.560237]\ R10:\ 000000000001a750\ R11:\ 0000000000000000\ R12:\ ffff8804099ba2c0
  1304. [25192.562512]\ R13:\ ffff8803157e9680\ R14:\ ffff8803157e9668\ R15:\ ffff8804099ba2c8
  1305. [25192.564724]\ FS:\ \ 0000000000000000(0000)\ GS:ffff88041f280000(0000)\ knlGS:0000000000000000
  1306. [25192.566990]\ CS:\ \ 0010\ DS:\ 0000\ ES:\ 0000\ CR0:\ 0000000080050033
  1307. [25192.569201]\ CR2:\ 00007ffabb690000\ CR3:\ 0000000001e0a000\ CR4:\ 00000000000406e0
  1308. [25192.571419]\ Stack:
  1309. [25192.573550]\ \ ffff8804099ba2c0\ ffff88039e4f86f0\ ffff8802f91ee928\ ffff8804099ba2c8
  1310. [25192.575695]\ \ ffff88040748bd08\ ffff88040748bc58\ ffffffff811b99bf\ 0000000000000052
  1311. [25192.577814]\ \ 0000000000000000\ ffffffff811ba380\ 000000000000008a\ 0000000000000080
  1312. [25192.579947]\ Call\ Trace:
  1313. [25192.582022]\ \ [<ffffffff811b99bf>]\ __list_lru_walk_one.isra.3+0x8f/0x130
  1314. [25192.584137]\ \ [<ffffffff811ba380>]\ ?\ memcg_drain_all_list_lrus+0x190/0x190
  1315. [25192.586165]\ \ [<ffffffff811b9a83>]\ list_lru_walk_one+0x23/0x30
  1316. [25192.588145]\ \ [<ffffffff811ba544>]\ scan_shadow_nodes+0x34/0x50
  1317. [25192.590074]\ \ [<ffffffff811a0e9d>]\ shrink_slab.part.40+0x1ed/0x3d0
  1318. [25192.591985]\ \ [<ffffffff811a53da>]\ shrink_zone+0x2ca/0x2e0
  1319. [25192.593863]\ \ [<ffffffff811a64ce>]\ kswapd+0x51e/0x990
  1320. [25192.595737]\ \ [<ffffffff811a5fb0>]\ ?\ mem_cgroup_shrink_node_zone+0x1c0/0x1c0
  1321. [25192.597613]\ \ [<ffffffff810a0808>]\ kthread+0xd8/0xf0
  1322. [25192.599495]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  1323. [25192.601335]\ \ [<ffffffff8182e34f>]\ ret_from_fork+0x3f/0x70
  1324. [25192.603193]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  1325. \f[]
  1326. .fi
  1327. .PP
  1328. There is a bug in the kernel.
  1329. A work around appears to be turning off \f[C]splice\f[].
  1330. Add \f[C]no_splice_write,no_splice_move,no_splice_read\f[] to
  1331. mergerfs\[aq] options.
  1332. Should be placed after \f[C]defaults\f[] if it is used since it will
  1333. turn them on.
  1334. This however is not guaranteed to work.
  1335. .SS rm: fts_read failed: No such file or directory
  1336. .PP
  1337. Not \f[I]really\f[] a bug.
  1338. The FUSE library will move files when asked to delete them as a way to
  1339. deal with certain edge cases and then later delete that file when its
  1340. clear the file is no longer needed.
  1341. This however can lead to two issues.
  1342. One is that these hidden files are noticed by \f[C]rm\ \-rf\f[] or
  1343. \f[C]find\f[] when scanning directories and they may try to remove them
  1344. and they might have disappeared already.
  1345. There is nothing \f[I]wrong\f[] about this happening but it can be
  1346. annoying.
  1347. The second issue is that a directory might not be able to removed on
  1348. account of the hidden file being still there.
  1349. .PP
  1350. Using the \f[B]hard_remove\f[] option will make it so these temporary
  1351. files are not used and files are deleted immedately.
  1352. .SH FAQ
  1353. .SS How well does mergerfs scale? Is it "production ready?"
  1354. .PP
  1355. Users have reported running mergerfs on everything from a Raspberry Pi
  1356. to dual socket Xeon systems with >20 cores.
  1357. I\[aq]m aware of at least a few companies which use mergerfs in
  1358. production.
  1359. Open Media Vault (https://www.openmediavault.org) includes mergerfs is
  1360. it\[aq]s sole solution for pooling drives.
  1361. .SS Can mergerfs be used with drives which already have data / are in
  1362. use?
  1363. .PP
  1364. Yes.
  1365. MergerFS is a proxy and does \f[B]NOT\f[] interfere with the normal form
  1366. or function of the drives / mounts / paths it manages.
  1367. .PP
  1368. MergerFS is \f[B]not\f[] a traditional filesystem.
  1369. MergerFS is \f[B]not\f[] RAID.
  1370. It does \f[B]not\f[] manipulate the data that passes through it.
  1371. It does \f[B]not\f[] shard data across drives.
  1372. It merely shards some \f[B]behavior\f[] and aggregates others.
  1373. .SS Can mergerfs be removed without affecting the data?
  1374. .PP
  1375. See the previous question\[aq]s answer.
  1376. .SS Do hard links work?
  1377. .PP
  1378. Yes.
  1379. You need to use \f[C]use_ino\f[] to support proper reporting of inodes.
  1380. Read the section "rename & link" for caveats.
  1381. .SS Does mergerfs support CoW / copy\-on\-write?
  1382. .PP
  1383. Not in the sense of a filesystem like BTRFS or ZFS nor in the overlayfs
  1384. or aufs sense.
  1385. It does offer a
  1386. cow\-shell (http://manpages.ubuntu.com/manpages/bionic/man1/cow-shell.1.html)
  1387. like hardlink breaking (copy to temp file then rename over original)
  1388. which can be useful when wanting to save space by hardlinking duplicate
  1389. files but wish to treat each name as if it were a unique and separate
  1390. file.
  1391. .SS Why can\[aq]t I see my files / directories?
  1392. .PP
  1393. It\[aq]s almost always a permissions issue.
  1394. Unlike mhddfs, which runs as root and attempts to access content as
  1395. such, mergerfs always changes it\[aq]s credentials to that of the
  1396. caller.
  1397. This means that if the user does not have access to a file or directory
  1398. than neither will mergerfs.
  1399. However, because mergerfs is creating a union of paths it may be able to
  1400. read some files and directories on one drive but not another resulting
  1401. in an incomplete set.
  1402. .PP
  1403. Whenever you run into a split permission issue (seeing some but not all
  1404. files) try using
  1405. mergerfs.fsck (https://github.com/trapexit/mergerfs-tools) tool to check
  1406. for and fix the mismatch.
  1407. If you aren\[aq]t seeing anything at all be sure that the basic
  1408. permissions are correct.
  1409. The user and group values are correct and that directories have their
  1410. executable bit set.
  1411. A common mistake by users new to Linux is to \f[C]chmod\ \-R\ 644\f[]
  1412. when they should have \f[C]chmod\ \-R\ u=rwX,go=rX\f[].
  1413. .PP
  1414. If using a network filesystem such as NFS, SMB, CIFS (Samba) be sure to
  1415. pay close attention to anything regarding permissioning and users.
  1416. Root squashing and user translation for instance has bitten a few
  1417. mergerfs users.
  1418. Some of these also affect the use of mergerfs from container platforms
  1419. such as Docker.
  1420. .SS Why is only one drive being used?
  1421. .PP
  1422. Are you using a path preserving policy?
  1423. The default policy for file creation is \f[C]epmfs\f[].
  1424. That means only the drives with the path preexisting will be considered
  1425. when creating a file.
  1426. If you don\[aq]t care about where files and directories are created you
  1427. likely shouldn\[aq]t be using a path preserving policy and instead
  1428. something like \f[C]mfs\f[].
  1429. .PP
  1430. This can be especially apparent when filling an empty pool from an
  1431. external source.
  1432. If you do want path preservation you\[aq]ll need to perform the manual
  1433. act of creating paths on the drives you want the data to land on before
  1434. transfering your data.
  1435. .SS Why was libfuse embedded into mergerfs?
  1436. .PP
  1437. A significant number of users use mergerfs on distros with very old
  1438. versions of libfuse which have serious bugs.
  1439. Requiring updated versions of libfuse on those distros isn\[aq]t
  1440. pratical (no package offered, user inexperience, etc.).
  1441. The only practical way to provide a stable runtime on those systems was
  1442. to "vendor" the library into the project.
  1443. .SS Why use mergerfs over mhddfs?
  1444. .PP
  1445. mhddfs is no longer maintained and has some known stability and security
  1446. issues (see below).
  1447. MergerFS provides a superset of mhddfs\[aq] features and should offer
  1448. the same or maybe better performance.
  1449. .PP
  1450. Below is an example of mhddfs and mergerfs setup to work similarly.
  1451. .PP
  1452. \f[C]mhddfs\ \-o\ mlimit=4G,allow_other\ /mnt/drive1,/mnt/drive2\ /mnt/pool\f[]
  1453. .PP
  1454. \f[C]mergerfs\ \-o\ minfreespace=4G,defaults,allow_other,category.create=ff\ /mnt/drive1:/mnt/drive2\ /mnt/pool\f[]
  1455. .SS Why use mergerfs over aufs?
  1456. .PP
  1457. aufs is mostly abandoned and no longer available in many distros.
  1458. .PP
  1459. While aufs can offer better peak performance mergerfs provides more
  1460. configurability and is generally easier to use.
  1461. mergerfs however does not offer the overlay / copy\-on\-write (CoW)
  1462. features which aufs and overlayfs have.
  1463. .SS Why use mergerfs over unionfs?
  1464. .PP
  1465. UnionFS is more like aufs then mergerfs in that it offers overlay / CoW
  1466. features.
  1467. If you\[aq]re just looking to create a union of drives and want
  1468. flexibility in file/directory placement then mergerfs offers that
  1469. whereas unionfs is more for overlaying RW filesystems over RO ones.
  1470. .SS Why use mergerfs over LVM/ZFS/BTRFS/RAID0 drive concatenation /
  1471. striping?
  1472. .PP
  1473. With simple JBOD / drive concatenation / stripping / RAID0 a single
  1474. drive failure will result in full pool failure.
  1475. mergerfs performs a similar behavior without the possibility of
  1476. catastrophic failure and the difficulties in recovery.
  1477. Drives may fail however all other data will continue to be accessable.
  1478. .PP
  1479. When combined with something like SnapRaid (http://www.snapraid.it)
  1480. and/or an offsite backup solution you can have the flexibilty of JBOD
  1481. without the single point of failure.
  1482. .SS Why use mergerfs over ZFS?
  1483. .PP
  1484. MergerFS is not intended to be a replacement for ZFS.
  1485. MergerFS is intended to provide flexible pooling of arbitrary drives
  1486. (local or remote), of arbitrary sizes, and arbitrary filesystems.
  1487. For \f[C]write\ once,\ read\ many\f[] usecases such as bulk media
  1488. storage.
  1489. Where data integrity and backup is managed in other ways.
  1490. In that situation ZFS can introduce major maintance and cost burdens as
  1491. described
  1492. here (http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html).
  1493. .SS Can drives be written to directly? Outside of mergerfs while pooled?
  1494. .PP
  1495. Yes.
  1496. It will be represented immediately in the pool as the policies
  1497. perscribe.
  1498. .SS Why do I get an "out of space" error even though the system says
  1499. there\[aq]s lots of space left?
  1500. .PP
  1501. First make sure you\[aq]ve read the sections above about policies, path
  1502. preserving, and the \f[B]moveonenospc\f[] option.
  1503. .PP
  1504. Remember that mergerfs is simply presenting a logical merging of the
  1505. contents of the pooled drives.
  1506. The reported free space is the aggregate space available \f[B]not\f[]
  1507. the contiguous space available.
  1508. MergerFS does not split files across drives.
  1509. If the writing of a file fills an underlying drive and
  1510. \f[B]moveonenospc\f[] is disabled it will return an ENOSPC (No space
  1511. left on device) error.
  1512. .PP
  1513. If \f[B]moveonenospc\f[] is enabled but there exists no drives with
  1514. enough space for the file and the data to be written (or the drive
  1515. happened to fill up as the file was being moved) it will error
  1516. indicating there isn\[aq]t enough space.
  1517. .PP
  1518. It is also possible that the filesystem selected has run out of inodes.
  1519. Use \f[C]df\ \-i\f[] to list the total and available inodes per
  1520. filesystem.
  1521. In the future it might be worth considering the number of inodes
  1522. available when making placement decisions in order to minimize this
  1523. situation.
  1524. .SS Can mergerfs mounts be exported over NFS?
  1525. .PP
  1526. Yes.
  1527. Some clients (Kodi) have issues in which the contents of the NFS mount
  1528. will not be presented but users have found that enabling the
  1529. \f[C]use_ino\f[] option often fixes that problem.
  1530. .SS Can mergerfs mounts be exported over Samba / SMB?
  1531. .PP
  1532. Yes.
  1533. While some users have reported problems it appears to always be related
  1534. to how Samba is setup in relation to permissions.
  1535. .SS How are inodes calculated?
  1536. .PP
  1537. mergerfs\-inode = (original\-inode | (device\-id << 32))
  1538. .PP
  1539. While \f[C]ino_t\f[] is 64 bits only a few filesystems use more than 32.
  1540. Similarly, while \f[C]dev_t\f[] is also 64 bits it was traditionally 16
  1541. bits.
  1542. Bitwise or\[aq]ing them together should work most of the time.
  1543. While totally unique inodes are preferred the overhead which would be
  1544. needed does not seem to outweighted by the benefits.
  1545. .PP
  1546. While atypical, yes, inodes can be reused and not refer to the same
  1547. file.
  1548. The internal id used to reference a file in FUSE is different from the
  1549. inode value presented.
  1550. The former is the \f[C]nodeid\f[] and is actually a tuple of
  1551. (nodeid,generation).
  1552. That tuple is not user facing.
  1553. The inode is merely metadata passed through the kernel and found using
  1554. the \f[C]stat\f[] family of calls or \f[C]readdir\f[].
  1555. .PP
  1556. From FUSE docs regarding \f[C]use_ino\f[]:
  1557. .IP
  1558. .nf
  1559. \f[C]
  1560. Honor\ the\ st_ino\ field\ in\ the\ functions\ getattr()\ and
  1561. fill_dir().\ This\ value\ is\ used\ to\ fill\ in\ the\ st_ino\ field
  1562. in\ the\ stat(2),\ lstat(2),\ fstat(2)\ functions\ and\ the\ d_ino
  1563. field\ in\ the\ readdir(2)\ function.\ The\ filesystem\ does\ not
  1564. have\ to\ guarantee\ uniqueness,\ however\ some\ applications
  1565. rely\ on\ this\ value\ being\ unique\ for\ the\ whole\ filesystem.
  1566. Note\ that\ this\ does\ *not*\ affect\ the\ inode\ that\ libfuse
  1567. and\ the\ kernel\ use\ internally\ (also\ called\ the\ "nodeid").
  1568. \f[]
  1569. .fi
  1570. .SS I notice massive slowdowns of writes over NFS
  1571. .PP
  1572. Due to how NFS works and interacts with FUSE when not using
  1573. \f[C]direct_io\f[] its possible that a getxattr for
  1574. \f[C]security.capability\f[] will be issued prior to any write.
  1575. This will usually result in a massive slowdown for writes.
  1576. Using \f[C]direct_io\f[] will keep this from happening (and generally
  1577. good to enable unless you need the features it disables) but the
  1578. \f[C]security_capability\f[] option can also help by short circuiting
  1579. the call and returning \f[C]ENOATTR\f[].
  1580. .PP
  1581. You could also set \f[C]xattr\f[] to \f[C]noattr\f[] or \f[C]notsup\f[]
  1582. to short circuit or stop all xattr requests.
  1583. .SS It\[aq]s mentioned that there are some security issues with mhddfs.
  1584. What are they? How does mergerfs address them?
  1585. .PP
  1586. mhddfs (https://github.com/trapexit/mhddfs) manages running as
  1587. \f[B]root\f[] by calling
  1588. getuid() (https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  1589. and if it returns \f[B]0\f[] then it will
  1590. chown (http://linux.die.net/man/1/chown) the file.
  1591. Not only is that a race condition but it doesn\[aq]t handle many other
  1592. situations.
  1593. Rather than attempting to simulate POSIX ACL behavior the proper way to
  1594. manage this is to use seteuid (http://linux.die.net/man/2/seteuid) and
  1595. setegid (http://linux.die.net/man/2/setegid), in effect becoming the
  1596. user making the original call, and perform the action as them.
  1597. This is what mergerfs does.
  1598. .PP
  1599. In Linux setreuid syscalls apply only to the thread.
  1600. GLIBC hides this away by using realtime signals to inform all threads to
  1601. change credentials.
  1602. Taking after \f[B]Samba\f[], mergerfs uses
  1603. \f[B]syscall(SYS_setreuid,...)\f[] to set the callers credentials for
  1604. that thread only.
  1605. Jumping back to \f[B]root\f[] as necessary should escalated privileges
  1606. be needed (for instance: to clone paths between drives).
  1607. .PP
  1608. For non\-Linux systems mergerfs uses a read\-write lock and changes
  1609. credentials only when necessary.
  1610. If multiple threads are to be user X then only the first one will need
  1611. to change the processes credentials.
  1612. So long as the other threads need to be user X they will take a readlock
  1613. allowing multiple threads to share the credentials.
  1614. Once a request comes in to run as user Y that thread will attempt a
  1615. write lock and change to Y\[aq]s credentials when it can.
  1616. If the ability to give writers priority is supported then that flag will
  1617. be used so threads trying to change credentials don\[aq]t starve.
  1618. This isn\[aq]t the best solution but should work reasonably well
  1619. assuming there are few users.
  1620. .SH SUPPORT
  1621. .PP
  1622. Filesystems are very complex and difficult to debug.
  1623. mergerfs, while being just a proxy of sorts, is also very difficult to
  1624. debug given the large number of possible settings it can have itself and
  1625. the massive number of environments it can run in.
  1626. When reporting on a suspected issue \f[B]please, please\f[] include as
  1627. much of the below information as possible otherwise it will be difficult
  1628. or impossible to diagnose.
  1629. Also please make sure to read all of the above documentation as it
  1630. includes nearly every known system or user issue previously encountered.
  1631. .SS Information to include in bug reports
  1632. .IP \[bu] 2
  1633. Version of mergerfs: \f[C]mergerfs\ \-V\f[]
  1634. .IP \[bu] 2
  1635. mergerfs settings: from \f[C]/etc/fstab\f[] or command line execution
  1636. .IP \[bu] 2
  1637. Version of Linux: \f[C]uname\ \-a\f[]
  1638. .IP \[bu] 2
  1639. Versions of any additional software being used
  1640. .IP \[bu] 2
  1641. List of drives, their filesystems, and sizes (before and after issue):
  1642. \f[C]df\ \-h\f[]
  1643. .IP \[bu] 2
  1644. A \f[C]strace\f[] of the app having problems:
  1645. .IP \[bu] 2
  1646. \f[C]strace\ \-f\ \-o\ /tmp/app.strace.txt\ <cmd>\f[]
  1647. .IP \[bu] 2
  1648. A \f[C]strace\f[] of mergerfs while the program is trying to do whatever
  1649. it\[aq]s failing to do:
  1650. .IP \[bu] 2
  1651. \f[C]strace\ \-f\ \-p\ <mergerfsPID>\ \-o\ /tmp/mergerfs.strace.txt\f[]
  1652. .IP \[bu] 2
  1653. \f[B]Precise\f[] directions on replicating the issue.
  1654. Do not leave \f[B]anything\f[] out.
  1655. .IP \[bu] 2
  1656. Try to recreate the problem in the simplist way using standard programs.
  1657. .SS Contact / Issue submission
  1658. .IP \[bu] 2
  1659. github.com: https://github.com/trapexit/mergerfs/issues
  1660. .IP \[bu] 2
  1661. email: trapexit\@spawn.link
  1662. .IP \[bu] 2
  1663. twitter: https://twitter.com/_trapexit
  1664. .SS Support development
  1665. .PP
  1666. This software is free to use and released under a very liberal license.
  1667. That said if you like this software and would like to support its
  1668. development donations are welcome.
  1669. .IP \[bu] 2
  1670. Bitcoin (BTC): 12CdMhEPQVmjz3SSynkAEuD5q9JmhTDCZA
  1671. .IP \[bu] 2
  1672. Bitcoin Cash (BCH): 1AjPqZZhu7GVEs6JFPjHmtsvmDL4euzMzp
  1673. .IP \[bu] 2
  1674. Ethereum (ETH): 0x09A166B11fCC127324C7fc5f1B572255b3046E94
  1675. .IP \[bu] 2
  1676. Litecoin (LTC): LXAsq6yc6zYU3EbcqyWtHBrH1Ypx4GjUjm
  1677. .IP \[bu] 2
  1678. Ripple (XRP): rNACR2hqGjpbHuCKwmJ4pDpd2zRfuRATcE
  1679. .IP \[bu] 2
  1680. PayPal: trapexit\@spawn.link
  1681. .IP \[bu] 2
  1682. Patreon: https://www.patreon.com/trapexit
  1683. .SH LINKS
  1684. .IP \[bu] 2
  1685. http://github.com/trapexit/mergerfs
  1686. .IP \[bu] 2
  1687. http://github.com/trapexit/mergerfs\-tools
  1688. .IP \[bu] 2
  1689. http://github.com/trapexit/scorch
  1690. .IP \[bu] 2
  1691. http://github.com/trapexit/backup\-and\-recovery\-howtos
  1692. .SH AUTHORS
  1693. Antonio SJ Musumeci <trapexit@spawn.link>.