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.

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