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.

1541 lines
57 KiB

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