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.

2707 lines
101 KiB

7 years ago
7 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
5 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
5 years ago
4 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
7 years ago
6 years ago
6 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
7 years ago
7 years ago
7 years ago
9 years ago
9 years ago
6 years ago
6 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
9 years ago
4 years ago
4 years ago
7 years ago
7 years ago
9 years ago
9 years ago
9 years ago
  1. .\"t
  2. .\" Automatically generated by Pandoc 1.19.2.4
  3. .\"
  4. .TH "mergerfs" "1" "2020\-08\-30" "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> <branches> <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 / file placement
  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 read\-only and read/write drives
  40. .IP \[bu] 2
  41. Can turn read\-only files into symlinks to underlying file
  42. .IP \[bu] 2
  43. Hard link copy\-on\-write / CoW
  44. .IP \[bu] 2
  45. supports POSIX ACLs
  46. .SH HOW IT WORKS
  47. .PP
  48. mergerfs logically merges multiple paths together.
  49. Think a union of sets.
  50. The file/s or directory/s acted on or presented through mergerfs are
  51. based on the policy chosen for that particular action.
  52. Read more about policies below.
  53. .IP
  54. .nf
  55. \f[C]
  56. A\ \ \ \ \ \ \ \ \ +\ \ \ \ \ \ B\ \ \ \ \ \ \ \ =\ \ \ \ \ \ \ C
  57. /disk1\ \ \ \ \ \ \ \ \ \ \ /disk2\ \ \ \ \ \ \ \ \ \ \ /merged
  58. |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
  59. +\-\-\ /dir1\ \ \ \ \ \ \ \ +\-\-\ /dir1\ \ \ \ \ \ \ \ +\-\-\ /dir1
  60. |\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ |
  61. |\ \ \ +\-\-\ file1\ \ \ \ |\ \ \ +\-\-\ file2\ \ \ \ |\ \ \ +\-\-\ file1
  62. |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file3\ \ \ \ |\ \ \ +\-\-\ file2
  63. +\-\-\ /dir2\ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file3
  64. |\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ /dir3\ \ \ \ \ \ \ \ |
  65. |\ \ \ +\-\-\ file4\ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ /dir2
  66. |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ file5\ \ \ |\ \ \ |
  67. +\-\-\ file6\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file4
  68. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
  69. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ /dir3
  70. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ |
  71. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file5
  72. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
  73. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ file6
  74. \f[]
  75. .fi
  76. .PP
  77. mergerfs does \f[B]not\f[] support the copy\-on\-write (CoW) behavior
  78. found in \f[B]aufs\f[] and \f[B]overlayfs\f[].
  79. You can \f[B]not\f[] mount a read\-only filesystem and write to it.
  80. However, mergerfs will ignore read\-only drives when creating new files
  81. so you can mix read\-write and read\-only drives.
  82. It also does \f[B]not\f[] split data across drives.
  83. It is not RAID0 / striping.
  84. It is simply a union.
  85. .SH TERMINOLOGY
  86. .IP \[bu] 2
  87. branch: A base path used in the pool.
  88. .IP \[bu] 2
  89. pool: The mergerfs mount.
  90. The union of the branches.
  91. .IP \[bu] 2
  92. relative path: The path in the pool relative to the branch and mount.
  93. .IP \[bu] 2
  94. policy: The algorithm used to select a file when performing a function.
  95. .IP \[bu] 2
  96. function: A filesystem call (open, unlink, create, getattr, etc.)
  97. .IP \[bu] 2
  98. category: A collection of functions (action, create, search).
  99. .IP \[bu] 2
  100. path preservation: Aspect of some policies which includes checking the
  101. path for which a file would be created.
  102. .SH BASIC SETUP
  103. .PP
  104. If you don\[aq]t already know that you have a special use case then just
  105. start with one of the following option sets.
  106. .SS You don\[aq]t need \f[C]mmap\f[]
  107. .PP
  108. \f[C]use_ino,cache.files=off,dropcacheonclose=true,allow_other,category.create=mfs\f[]
  109. .SS You do need \f[C]mmap\f[] (used by rtorrent and some other programs)
  110. .PP
  111. \f[C]use_ino,cache.files=partial,dropcacheonclose=true,allow_other,category.create=mfs\f[]
  112. .PP
  113. See the mergerfs wiki for real world
  114. deployments (https://github.com/trapexit/mergerfs/wiki/Real-World-Deployments)
  115. for comparisons / ideas.
  116. .SH OPTIONS
  117. .SS mount options
  118. .IP \[bu] 2
  119. \f[B]config\f[]: Path to a config file.
  120. Same arguments as below in key=val format.
  121. .IP \[bu] 2
  122. \f[B]branches\f[]: Colon delimited list of branches.
  123. .IP \[bu] 2
  124. \f[B]allow_other\f[]: A libfuse option which allows users besides the
  125. one which ran mergerfs to see the filesystem.
  126. This is required for most use\-cases.
  127. .IP \[bu] 2
  128. \f[B]minfreespace=SIZE\f[]: The minimum space value used for creation
  129. policies.
  130. Understands \[aq]K\[aq], \[aq]M\[aq], and \[aq]G\[aq] to represent
  131. kilobyte, megabyte, and gigabyte respectively.
  132. (default: 4G)
  133. .IP \[bu] 2
  134. \f[B]moveonenospc=BOOL|POLICY\f[]: When enabled if a \f[B]write\f[]
  135. fails with \f[B]ENOSPC\f[] (no space left on device) or \f[B]EDQUOT\f[]
  136. (disk quota exceeded) the policy selected will run to find a new
  137. location for the file.
  138. An attempt to move the file to that branch will occur (keeping all
  139. metadata possible) and if successful the original is unlinked and the
  140. write retried.
  141. (default: false, true = mfs)
  142. .IP \[bu] 2
  143. \f[B]use_ino\f[]: Causes mergerfs to supply file/directory inodes rather
  144. than libfuse.
  145. While not a default it is recommended it be enabled so that linked files
  146. share the same inode value.
  147. .IP \[bu] 2
  148. \f[B]inodecalc=passthrough|path\-hash|devino\-hash|hybrid\-hash\f[]:
  149. Selects the inode calculation algorithm.
  150. (default: hybrid\-hash)
  151. .IP \[bu] 2
  152. \f[B]dropcacheonclose=BOOL\f[]: When a file is requested to be closed
  153. call \f[C]posix_fadvise\f[] on it first to instruct the kernel that we
  154. no longer need the data and it can drop its cache.
  155. Recommended when \f[B]cache.files=partial|full|auto\-full\f[] to limit
  156. double caching.
  157. (default: false)
  158. .IP \[bu] 2
  159. \f[B]symlinkify=BOOL\f[]: When enabled and a file is not writable and
  160. its mtime or ctime is older than \f[B]symlinkify_timeout\f[] files will
  161. be reported as symlinks to the original files.
  162. Please read more below before using.
  163. (default: false)
  164. .IP \[bu] 2
  165. \f[B]symlinkify_timeout=INT\f[]: Time to wait, in seconds, to activate
  166. the \f[B]symlinkify\f[] behavior.
  167. (default: 3600)
  168. .IP \[bu] 2
  169. \f[B]nullrw=BOOL\f[]: Turns reads and writes into no\-ops.
  170. The request will succeed but do nothing.
  171. Useful for benchmarking mergerfs.
  172. (default: false)
  173. .IP \[bu] 2
  174. \f[B]ignorepponrename=BOOL\f[]: Ignore path preserving on rename.
  175. Typically rename and link act differently depending on the policy of
  176. \f[C]create\f[] (read below).
  177. Enabling this will cause rename and link to always use the non\-path
  178. preserving behavior.
  179. This means files, when renamed or linked, will stay on the same drive.
  180. (default: false)
  181. .IP \[bu] 2
  182. \f[B]security_capability=BOOL\f[]: If false return ENOATTR when xattr
  183. security.capability is queried.
  184. (default: true)
  185. .IP \[bu] 2
  186. \f[B]xattr=passthrough|noattr|nosys\f[]: Runtime control of xattrs.
  187. Default is to passthrough xattr requests.
  188. \[aq]noattr\[aq] will short circuit as if nothing exists.
  189. \[aq]nosys\[aq] will respond with ENOSYS as if xattrs are not supported
  190. or disabled.
  191. (default: passthrough)
  192. .IP \[bu] 2
  193. \f[B]link_cow=BOOL\f[]: When enabled if a regular file is opened which
  194. has a link count > 1 it will copy the file to a temporary file and
  195. rename over the original.
  196. Breaking the link and providing a basic copy\-on\-write function similar
  197. to cow\-shell.
  198. (default: false)
  199. .IP \[bu] 2
  200. \f[B]statfs=base|full\f[]: Controls how statfs works.
  201. \[aq]base\[aq] means it will always use all branches in statfs
  202. calculations.
  203. \[aq]full\[aq] is in effect path preserving and only includes drives
  204. where the path exists.
  205. (default: base)
  206. .IP \[bu] 2
  207. \f[B]statfs_ignore=none|ro|nc\f[]: \[aq]ro\[aq] will cause statfs
  208. calculations to ignore available space for branches mounted or tagged as
  209. \[aq]read\-only\[aq] or \[aq]no create\[aq].
  210. \[aq]nc\[aq] will ignore available space for branches tagged as \[aq]no
  211. create\[aq].
  212. (default: none)
  213. .IP \[bu] 2
  214. \f[B]nfsopenhack=off|git|all\f[]: A workaround for exporting mergerfs
  215. over NFS where there are issues with creating files for write while
  216. setting the mode to read\-only.
  217. (default: off)
  218. .IP \[bu] 2
  219. \f[B]followsymlinks=never|directory|regular|all\f[]: Turns symlinks into
  220. what they point to.
  221. (default: never)
  222. .IP \[bu] 2
  223. \f[B]posix_acl=BOOL\f[]: Enable POSIX ACL support (if supported by
  224. kernel and underlying filesystem).
  225. (default: false)
  226. .IP \[bu] 2
  227. \f[B]async_read=BOOL\f[]: Perform reads asynchronously.
  228. If disabled or unavailable the kernel will ensure there is at most one
  229. pending read request per file handle and will attempt to order requests
  230. by offset.
  231. (default: true)
  232. .IP \[bu] 2
  233. \f[B]fuse_msg_size=INT\f[]: Set the max number of pages per FUSE
  234. message.
  235. Only available on Linux >= 4.20 and ignored otherwise.
  236. (min: 1; max: 256; default: 256)
  237. .IP \[bu] 2
  238. \f[B]threads=INT\f[]: Number of threads to use in multithreaded mode.
  239. When set to zero it will attempt to discover and use the number of
  240. logical cores.
  241. If the lookup fails it will fall back to using 4.
  242. If the thread count is set negative it will look up the number of cores
  243. then divide by the absolute value.
  244. ie.
  245. threads=\-2 on an 8 core machine will result in 8 / 2 = 4 threads.
  246. There will always be at least 1 thread.
  247. NOTE: higher number of threads increases parallelism but usually
  248. decreases throughput.
  249. (default: 0)
  250. .IP \[bu] 2
  251. \f[B]fsname=STR\f[]: Sets the name of the filesystem as seen in
  252. \f[B]mount\f[], \f[B]df\f[], etc.
  253. Defaults to a list of the source paths concatenated together with the
  254. longest common prefix removed.
  255. .IP \[bu] 2
  256. \f[B]func.FUNC=POLICY\f[]: Sets the specific FUSE function\[aq]s policy.
  257. See below for the list of value types.
  258. Example: \f[B]func.getattr=newest\f[]
  259. .IP \[bu] 2
  260. \f[B]category.CATEGORY=POLICY\f[]: Sets policy of all FUSE functions in
  261. the provided category.
  262. See POLICIES section for defaults.
  263. Example: \f[B]category.create=mfs\f[]
  264. .IP \[bu] 2
  265. \f[B]cache.open=INT\f[]: \[aq]open\[aq] policy cache timeout in seconds.
  266. (default: 0)
  267. .IP \[bu] 2
  268. \f[B]cache.statfs=INT\f[]: \[aq]statfs\[aq] cache timeout in seconds.
  269. (default: 0)
  270. .IP \[bu] 2
  271. \f[B]cache.attr=INT\f[]: File attribute cache timeout in seconds.
  272. (default: 1)
  273. .IP \[bu] 2
  274. \f[B]cache.entry=INT\f[]: File name lookup cache timeout in seconds.
  275. (default: 1)
  276. .IP \[bu] 2
  277. \f[B]cache.negative_entry=INT\f[]: Negative file name lookup cache
  278. timeout in seconds.
  279. (default: 0)
  280. .IP \[bu] 2
  281. \f[B]cache.files=libfuse|off|partial|full|auto\-full\f[]: File page
  282. caching mode (default: libfuse)
  283. .IP \[bu] 2
  284. \f[B]cache.writeback=BOOL\f[]: Enable kernel writeback caching (default:
  285. false)
  286. .IP \[bu] 2
  287. \f[B]cache.symlinks=BOOL\f[]: Cache symlinks (if supported by kernel)
  288. (default: false)
  289. .IP \[bu] 2
  290. \f[B]cache.readdir=BOOL\f[]: Cache readdir (if supported by kernel)
  291. (default: false)
  292. .IP \[bu] 2
  293. \f[B]direct_io\f[]: deprecated \- Bypass page cache.
  294. Use \f[C]cache.files=off\f[] instead.
  295. (default: false)
  296. .IP \[bu] 2
  297. \f[B]kernel_cache\f[]: deprecated \- Do not invalidate data cache on
  298. file open.
  299. Use \f[C]cache.files=full\f[] instead.
  300. (default: false)
  301. .IP \[bu] 2
  302. \f[B]auto_cache\f[]: deprecated \- Invalidate data cache if file mtime
  303. or size change.
  304. Use \f[C]cache.files=auto\-full\f[] instead.
  305. (default: false)
  306. .IP \[bu] 2
  307. \f[B]async_read\f[]: deprecated \- Perform reads asynchronously.
  308. Use \f[C]async_read=true\f[] instead.
  309. .IP \[bu] 2
  310. \f[B]sync_read\f[]: deprecated \- Perform reads synchronously.
  311. Use \f[C]async_read=false\f[] instead.
  312. .PP
  313. \f[B]NOTE:\f[] Options are evaluated in the order listed so if the
  314. options are \f[B]func.rmdir=rand,category.action=ff\f[] the
  315. \f[B]action\f[] category setting will override the \f[B]rmdir\f[]
  316. setting.
  317. .SS Value Types
  318. .IP \[bu] 2
  319. BOOL = \[aq]true\[aq] | \[aq]false\[aq]
  320. .IP \[bu] 2
  321. INT = [0,MAX_INT]
  322. .IP \[bu] 2
  323. SIZE = \[aq]NNM\[aq]; NN = INT, M = \[aq]K\[aq] | \[aq]M\[aq] |
  324. \[aq]G\[aq] | \[aq]T\[aq]
  325. .IP \[bu] 2
  326. STR = string
  327. .IP \[bu] 2
  328. FUNC = FUSE function
  329. .IP \[bu] 2
  330. CATEGORY = FUSE function category
  331. .IP \[bu] 2
  332. POLICY = mergerfs function policy
  333. .SS branches
  334. .PP
  335. The \[aq]branches\[aq] (formerly \[aq]srcmounts\[aq]) argument is a
  336. colon (\[aq]:\[aq]) delimited list of paths to be pooled together.
  337. It does not matter if the paths are on the same or different drives nor
  338. does it matter the filesystem.
  339. Used and available space will not be duplicated for paths on the same
  340. device and any features which aren\[aq]t supported by the underlying
  341. filesystem (such as file attributes or extended attributes) will return
  342. the appropriate errors.
  343. .PP
  344. To make it easier to include multiple branches mergerfs supports
  345. globbing (http://linux.die.net/man/7/glob).
  346. \f[B]The globbing tokens MUST be escaped when using via the shell else
  347. the shell itself will apply the glob itself.\f[]
  348. .PP
  349. Each branch can have a suffix of \f[C]=RW\f[] (read / write),
  350. \f[C]=RO\f[] (read\-only), or \f[C]=NC\f[] (no create).
  351. These suffixes work with globs as well and will apply to each path
  352. found.
  353. \f[C]RW\f[] is the default behavior and those paths will be eligible for
  354. all policy categories.
  355. \f[C]RO\f[] will exclude those paths from \f[C]create\f[] and
  356. \f[C]action\f[] policies (just as a filesystem being mounted \f[C]ro\f[]
  357. would).
  358. \f[C]NC\f[] will exclude those paths from \f[C]create\f[] policies (you
  359. can\[aq]t create but you can change / delete).
  360. .IP
  361. .nf
  362. \f[C]
  363. #\ mergerfs\ \-o\ allow_other,use_ino\ /mnt/disk\\*:/mnt/cdrom\ /media/drives
  364. \f[]
  365. .fi
  366. .PP
  367. The above line will use all mount points in /mnt prefixed with
  368. \f[B]disk\f[] and the \f[B]cdrom\f[].
  369. .PP
  370. To have the pool mounted at boot or otherwise accessible from related
  371. tools use \f[B]/etc/fstab\f[].
  372. .IP
  373. .nf
  374. \f[C]
  375. #\ <file\ system>\ \ \ \ \ \ \ \ <mount\ point>\ \ <type>\ \ \ \ \ \ \ \ \ <options>\ \ \ \ \ \ \ \ \ \ \ \ \ <dump>\ \ <pass>
  376. /mnt/disk*:/mnt/cdrom\ \ /mnt/pool\ \ \ \ \ \ fuse.mergerfs\ \ allow_other,use_ino\ \ \ 0\ \ \ \ \ \ \ 0
  377. \f[]
  378. .fi
  379. .PP
  380. \f[B]NOTE:\f[] the globbing is done at mount or xattr update time (see
  381. below).
  382. If a new directory is added matching the glob after the fact it will not
  383. be automatically included.
  384. .PP
  385. \f[B]NOTE:\f[] for mounting via \f[B]fstab\f[] to work you must have
  386. \f[B]mount.fuse\f[] installed.
  387. For Ubuntu/Debian it is included in the \f[B]fuse\f[] package.
  388. .SS inodecalc
  389. .PP
  390. Inodes (st_ino) are unique identifiers within a filesystem.
  391. Each mounted filesystem has device ID (st_dev) as well and together they
  392. can uniquely identify a file on the whole of the system.
  393. Entries on the same device with the same inode are in fact references to
  394. the same underlying file.
  395. It is a many to one relationship between names and an inode.
  396. Directories, however, do not have multiple links on most systems due to
  397. the complexity they add.
  398. .PP
  399. FUSE allows the server (mergerfs) to set inode values but not device
  400. IDs.
  401. Creating an inode value is somewhat complex in mergerfs\[aq] case as
  402. files aren\[aq]t really in its control.
  403. If a policy changes what directory or file is to be selected or
  404. something changes out of band it becomes unclear what value should be
  405. used.
  406. Most software does not to care what the values are but those that do
  407. often break if a value changes unexpectedly.
  408. The tool \f[C]find\f[] will abort a directory walk if it sees a
  409. directory inode change.
  410. NFS will return stale handle errors if the inode changes out of band.
  411. File dedup tools will usually leverage device ids and inodes as a
  412. shortcut in searching for duplicate files and would resort to full file
  413. comparisons should it find different inode values.
  414. .PP
  415. mergerfs offers multiple ways to calculate the inode in hopes of
  416. covering different usecases.
  417. .IP \[bu] 2
  418. passthrough: Passes through the underlying inode value.
  419. Mostly intended for testing as using this does not address any of the
  420. problems mentioned above and could confuse file deduplication software
  421. as inodes from different filesystems can be the same.
  422. .IP \[bu] 2
  423. path\-hash: Hashes the relative path of the entry in question.
  424. The underlying file\[aq]s values are completely ignored.
  425. This means the inode value will always be the same for that file path.
  426. This is useful when using NFS and you make changes out of band such as
  427. copy data between branches.
  428. This also means that entries that do point to the same file will not be
  429. recognizable via inodes.
  430. That \f[B]does not\f[] mean hard links don\[aq]t work.
  431. They will.
  432. .IP \[bu] 2
  433. path\-hash32: 32bit version of path\-hash.
  434. .IP \[bu] 2
  435. devino\-hash: Hashes the device id and inode of the underlying entry.
  436. This won\[aq]t prevent issues with NFS should the policy pick a
  437. different file or files move out of band but will present the same inode
  438. for underlying files that do too.
  439. .IP \[bu] 2
  440. devino\-hash32: 32bit version of devino\-hash.
  441. .IP \[bu] 2
  442. hybrid\-hash: Performs \f[C]path\-hash\f[] on directories and
  443. \f[C]devino\-hash\f[] on other file types.
  444. Since directories can\[aq]t have hard links the static value won\[aq]t
  445. make a difference and the files will get values useful for finding
  446. duplicates.
  447. Probably the best to use if not using NFS.
  448. As such it is the default.
  449. .IP \[bu] 2
  450. hybrid\-hash32: 32bit version of hybrid\-hash.
  451. .PP
  452. 32bit versions are provided as there is some software which does not
  453. handle 64bit inodes well.
  454. .PP
  455. While there is a risk of hash collision in tests of a couple million
  456. entries there were zero collisions.
  457. Unlike a typical filesystem FUSE filesystems can reuse inodes and not
  458. refer to the same entry.
  459. The internal identifier used to reference a file in FUSE is different
  460. from the inode value presented.
  461. The former is the \f[C]nodeid\f[] and is actually a tuple of 2 64bit
  462. values: \f[C]nodeid\f[] and \f[C]generation\f[].
  463. This tuple is not client facing.
  464. The inode that is presented to the client is passed through the kernel
  465. uninterpreted.
  466. .PP
  467. From FUSE docs regarding \f[C]use_ino\f[]:
  468. .IP
  469. .nf
  470. \f[C]
  471. Honor\ the\ st_ino\ field\ in\ the\ functions\ getattr()\ and
  472. fill_dir().\ This\ value\ is\ used\ to\ fill\ in\ the\ st_ino\ field
  473. in\ the\ stat(2),\ lstat(2),\ fstat(2)\ functions\ and\ the\ d_ino
  474. field\ in\ the\ readdir(2)\ function.\ The\ filesystem\ does\ not
  475. have\ to\ guarantee\ uniqueness,\ however\ some\ applications
  476. rely\ on\ this\ value\ being\ unique\ for\ the\ whole\ filesystem.
  477. Note\ that\ this\ does\ *not*\ affect\ the\ inode\ that\ libfuse
  478. and\ the\ kernel\ use\ internally\ (also\ called\ the\ "nodeid").
  479. \f[]
  480. .fi
  481. .PP
  482. In the future the \f[C]use_ino\f[] option will probably be removed as
  483. this feature should replace the original libfuse inode calculation
  484. strategy.
  485. Currently you still need to use \f[C]use_ino\f[] in order to enable
  486. \f[C]inodecalc\f[].
  487. .SS fuse_msg_size
  488. .PP
  489. FUSE applications communicate with the kernel over a special character
  490. device: \f[C]/dev/fuse\f[].
  491. A large portion of the overhead associated with FUSE is the cost of
  492. going back and forth from user space and kernel space over that device.
  493. Generally speaking the fewer trips needed the better the performance
  494. will be.
  495. Reducing the number of trips can be done a number of ways.
  496. Kernel level caching and increasing message sizes being two significant
  497. ones.
  498. When it comes to reads and writes if the message size is doubled the
  499. number of trips are approximately halved.
  500. .PP
  501. In Linux 4.20 a new feature was added allowing the negotiation of the
  502. max message size.
  503. Since the size is in multiples of
  504. pages (https://en.wikipedia.org/wiki/Page_(computer_memory)) the feature
  505. is called \f[C]max_pages\f[].
  506. There is a maximum \f[C]max_pages\f[] value of 256 (1MiB) and minimum of
  507. 1 (4KiB).
  508. The default used by Linux >=4.20, and hardcoded value used before 4.20,
  509. is 32 (128KiB).
  510. In mergerfs its referred to as \f[C]fuse_msg_size\f[] to make it clear
  511. what it impacts and provide some abstraction.
  512. .PP
  513. Since there should be no downsides to increasing \f[C]fuse_msg_size\f[]
  514. / \f[C]max_pages\f[], outside a minor bump in RAM usage due to larger
  515. message buffers, mergerfs defaults the value to 256.
  516. On kernels before 4.20 the value has no effect.
  517. The reason the value is configurable is to enable experimentation and
  518. benchmarking.
  519. See the BENCHMARKING section for examples.
  520. .SS followsymlinks
  521. .PP
  522. This feature, when enabled, will cause symlinks to be interpreted by
  523. mergerfs as their target (depending on the mode).
  524. .PP
  525. When there is a getattr/stat request for a file mergerfs will check if
  526. the file is a symlink and depending on the \f[C]followsymlinks\f[]
  527. setting will replace the information about the symlink with that of that
  528. which it points to.
  529. .PP
  530. When unlink\[aq]ing or rmdir\[aq]ing the followed symlink it will remove
  531. the symlink itself and not that which it points to.
  532. .SS symlinkify
  533. .PP
  534. Due to the levels of indirection introduced by mergerfs and the
  535. underlying technology FUSE there can be varying levels of performance
  536. degradation.
  537. This feature will turn non\-directories which are not writable into
  538. symlinks to the original file found by the \f[C]readlink\f[] policy
  539. after the mtime and ctime are older than the timeout.
  540. .PP
  541. \f[B]WARNING:\f[] The current implementation has a known issue in which
  542. if the file is open and being used when the file is converted to a
  543. symlink then the application which has that file open will receive an
  544. error when using it.
  545. This is unlikely to occur in practice but is something to keep in mind.
  546. .PP
  547. \f[B]WARNING:\f[] Some backup solutions, such as CrashPlan, do not
  548. backup the target of a symlink.
  549. If using this feature it will be necessary to point any backup software
  550. to the original drives or configure the software to follow symlinks if
  551. such an option is available.
  552. Alternatively create two mounts.
  553. One for backup and one for general consumption.
  554. .SS nullrw
  555. .PP
  556. Due to how FUSE works there is an overhead to all requests made to a
  557. FUSE filesystem that wouldn\[aq]t exist for an in kernel one.
  558. Meaning that even a simple passthrough will have some slowdown.
  559. However, generally the overhead is minimal in comparison to the cost of
  560. the underlying I/O.
  561. By disabling the underlying I/O we can test the theoretical performance
  562. boundaries.
  563. .PP
  564. By enabling \f[C]nullrw\f[] mergerfs will work as it always does
  565. \f[B]except\f[] that all reads and writes will be no\-ops.
  566. A write will succeed (the size of the write will be returned as if it
  567. were successful) but mergerfs does nothing with the data it was given.
  568. Similarly a read will return the size requested but won\[aq]t touch the
  569. buffer.
  570. .PP
  571. See the BENCHMARKING section for suggestions on how to test.
  572. .SS xattr
  573. .PP
  574. Runtime extended attribute support can be managed via the \f[C]xattr\f[]
  575. option.
  576. By default it will passthrough any xattr calls.
  577. Given xattr support is rarely used and can have significant performance
  578. implications mergerfs allows it to be disabled at runtime.
  579. The performance problems mostly comes when file caching is enabled.
  580. The kernel will send a \f[C]getxattr\f[] for
  581. \f[C]security.capability\f[] \f[I]before every single write\f[].
  582. It doesn\[aq]t cache the responses to any \f[C]getxattr\f[].
  583. This might be addressed in the future but for now mergerfs can really
  584. only offer the following workarounds.
  585. .PP
  586. \f[C]noattr\f[] will cause mergerfs to short circuit all xattr calls and
  587. return ENOATTR where appropriate.
  588. mergerfs still gets all the requests but they will not be forwarded on
  589. to the underlying filesystems.
  590. The runtime control will still function in this mode.
  591. .PP
  592. \f[C]nosys\f[] will cause mergerfs to return ENOSYS for any xattr call.
  593. The difference with \f[C]noattr\f[] is that the kernel will cache this
  594. fact and itself short circuit future calls.
  595. This is more efficient than \f[C]noattr\f[] but will cause mergerfs\[aq]
  596. runtime control via the hidden file to stop working.
  597. .SS nfsopenhack
  598. .PP
  599. NFS is not fully POSIX compliant and historically certain behaviors,
  600. such as opening files with O_EXCL, are not or not well supported.
  601. When mergerfs (or any FUSE filesystem) is exported over NFS some of
  602. these issues come up due to how NFS and FUSE interact.
  603. .PP
  604. This hack addresses the issue where the creation of a file with a
  605. read\-only mode but with a read/write or write only flag.
  606. Normally this is perfectly valid but NFS chops the one open call into
  607. multiple calls.
  608. Exactly how it is translated depends on the configuration and versions
  609. of the NFS server and clients but it results in a permission error
  610. because a normal user is not allowed to open a read\-only file as
  611. writable.
  612. .PP
  613. Even though it\[aq]s a more niche situation this hack breaks normal
  614. security and behavior and as such is \f[C]off\f[] by default.
  615. If set to \f[C]git\f[] it will only perform the hack when the path in
  616. question includes \f[C]/.git/\f[].
  617. \f[C]all\f[] will result it it applying anytime a readonly file which is
  618. empty is opened for writing.
  619. .SH FUNCTIONS / POLICIES / CATEGORIES
  620. .PP
  621. The POSIX filesystem API is made up of a number of functions.
  622. \f[B]creat\f[], \f[B]stat\f[], \f[B]chown\f[], etc.
  623. For ease of configuration in mergerfs most of the core functions are
  624. grouped into 3 categories: \f[B]action\f[], \f[B]create\f[], and
  625. \f[B]search\f[].
  626. These functions and categories can be assigned a policy which dictates
  627. which underlying branch/file/directory is chosen when performing that
  628. behavior.
  629. Any policy can be assigned to a function or category though some may not
  630. be very useful in practice.
  631. For instance: \f[B]rand\f[] (random) may be useful for file creation
  632. (create) but could lead to very odd behavior if used for \f[C]chmod\f[]
  633. if there were more than one copy of the file.
  634. .PP
  635. Some functions, listed in the category \f[C]N/A\f[] below, can not be
  636. assigned the normal policies.
  637. All functions which work on file handles use the handle which was
  638. acquired by \f[C]open\f[] or \f[C]create\f[].
  639. \f[C]readdir\f[] has no real need for a policy given the purpose is
  640. merely to return a list of entries in a directory.
  641. \f[C]statfs\f[]\[aq]s behavior can be modified via other options.
  642. That said many times the current FUSE kernel driver will not always
  643. provide the file handle when a client calls \f[C]fgetattr\f[],
  644. \f[C]fchown\f[], \f[C]fchmod\f[], \f[C]futimens\f[], \f[C]ftruncate\f[],
  645. etc.
  646. This means it will call the regular, path based, versions.
  647. .PP
  648. When using policies which are based on a branch\[aq]s available space
  649. the base path provided is used.
  650. Not the full path to the file in question.
  651. Meaning that sub mounts won\[aq]t be considered in the space
  652. calculations.
  653. The reason is that it doesn\[aq]t really work for non\-path preserving
  654. policies and can lead to non\-obvious behaviors.
  655. .SS Functions and their Category classifications
  656. .PP
  657. .TS
  658. tab(@);
  659. lw(7.9n) lw(62.1n).
  660. T{
  661. Category
  662. T}@T{
  663. FUSE Functions
  664. T}
  665. _
  666. T{
  667. action
  668. T}@T{
  669. chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate,
  670. unlink, utimens
  671. T}
  672. T{
  673. create
  674. T}@T{
  675. create, mkdir, mknod, symlink
  676. T}
  677. T{
  678. search
  679. T}@T{
  680. access, getattr, getxattr, ioctl (directories), listxattr, open,
  681. readlink
  682. T}
  683. T{
  684. N/A
  685. T}@T{
  686. fchmod, fchown, futimens, ftruncate, fallocate, fgetattr, fsync, ioctl
  687. (files), read, readdir, release, statfs, write, copy_file_range
  688. T}
  689. .TE
  690. .PP
  691. In cases where something may be searched (to confirm a directory exists
  692. across all source mounts) \f[B]getattr\f[] will be used.
  693. .SS Path Preservation
  694. .PP
  695. Policies, as described below, are of two basic types.
  696. \f[C]path\ preserving\f[] and \f[C]non\-path\ preserving\f[].
  697. .PP
  698. All policies which start with \f[C]ep\f[] (\f[B]epff\f[],
  699. \f[B]eplfs\f[], \f[B]eplus\f[], \f[B]epmfs\f[], \f[B]eprand\f[]) are
  700. \f[C]path\ preserving\f[].
  701. \f[C]ep\f[] stands for \f[C]existing\ path\f[].
  702. .PP
  703. A path preserving policy will only consider drives where the relative
  704. path being accessed already exists.
  705. .PP
  706. When using non\-path preserving policies paths will be cloned to target
  707. drives as necessary.
  708. .PP
  709. With the \f[C]msp\f[] or \f[C]most\ shared\ path\f[] policies they are
  710. defined as \f[C]path\ preserving\f[] for the purpose of controlling
  711. \f[C]link\f[] and \f[C]rename\f[]\[aq]s behaviors since
  712. \f[C]ignorepponrename\f[] is available to disable that behavior.
  713. In mergerfs v3.0 the path preserving behavior of rename and link will
  714. likely be separated from the policy all together.
  715. .SS Filters
  716. .PP
  717. Policies basically search branches and create a list of files / paths
  718. for functions to work on.
  719. The policy is responsible for filtering and sorting.
  720. Filters include \f[B]minfreespace\f[], whether or not a branch is
  721. mounted read\-only, and the branch tagging (RO,NC,RW).
  722. The policy defines the sorting but filtering is mostly uniform as
  723. described below.
  724. .IP \[bu] 2
  725. No \f[B]search\f[] policies filter.
  726. .IP \[bu] 2
  727. All \f[B]action\f[] policies will filter out branches which are mounted
  728. \f[B]read\-only\f[] or tagged as \f[B]RO (read\-only)\f[].
  729. .IP \[bu] 2
  730. All \f[B]create\f[] policies will filter out branches which are mounted
  731. \f[B]read\-only\f[], tagged \f[B]RO (read\-only)\f[] or \f[B]NC (no
  732. create)\f[], or has available space less than \f[C]minfreespace\f[].
  733. .PP
  734. If all branches are filtered an error will be returned.
  735. Typically \f[B]EROFS\f[] (read\-only filesystem) or \f[B]ENOSPC\f[] (no
  736. space left on device) depending on the most recent reason for filtering
  737. a branch.
  738. .SS Policy descriptions
  739. .PP
  740. Because of the nature of the behavior the policies act differently
  741. depending on the function it is used with (based on the category).
  742. .PP
  743. .TS
  744. tab(@);
  745. lw(16.6n) lw(53.4n).
  746. T{
  747. Policy
  748. T}@T{
  749. Description
  750. T}
  751. _
  752. T{
  753. all
  754. T}@T{
  755. Search: Same as \f[B]epall\f[].
  756. Action: Same as \f[B]epall\f[].
  757. Create: for \f[B]mkdir\f[], \f[B]mknod\f[], and \f[B]symlink\f[] it will
  758. apply to all branches.
  759. \f[B]create\f[] works like \f[B]ff\f[].
  760. T}
  761. T{
  762. epall (existing path, all)
  763. T}@T{
  764. Search: Same as \f[B]epff\f[] (but more expensive because it doesn\[aq]t
  765. stop after finding a valid branch).
  766. Action: apply to all found.
  767. Create: for \f[B]mkdir\f[], \f[B]mknod\f[], and \f[B]symlink\f[] it will
  768. apply to all found.
  769. \f[B]create\f[] works like \f[B]epff\f[] (but more expensive because it
  770. doesn\[aq]t stop after finding a valid branch).
  771. T}
  772. T{
  773. epff (existing path, first found)
  774. T}@T{
  775. Given the order of the branches, as defined at mount time or configured
  776. at runtime, act on the first one found where the relative path exists.
  777. T}
  778. T{
  779. eplfs (existing path, least free space)
  780. T}@T{
  781. Of all the branches on which the relative path exists choose the drive
  782. with the least free space.
  783. T}
  784. T{
  785. eplus (existing path, least used space)
  786. T}@T{
  787. Of all the branches on which the relative path exists choose the drive
  788. with the least used space.
  789. T}
  790. T{
  791. epmfs (existing path, most free space)
  792. T}@T{
  793. Of all the branches on which the relative path exists choose the drive
  794. with the most free space.
  795. T}
  796. T{
  797. eppfrd (existing path, percentage free random distribution)
  798. T}@T{
  799. Like \f[B]pfrd\f[] but limited to existing paths.
  800. T}
  801. T{
  802. eprand (existing path, random)
  803. T}@T{
  804. Calls \f[B]epall\f[] and then randomizes.
  805. Returns 1.
  806. T}
  807. T{
  808. erofs
  809. T}@T{
  810. Exclusively return \f[B]\-1\f[] with \f[B]errno\f[] set to
  811. \f[B]EROFS\f[] (read\-only filesystem).
  812. T}
  813. T{
  814. ff (first found)
  815. T}@T{
  816. Search: Same as \f[B]epff\f[].
  817. Action: Same as \f[B]epff\f[].
  818. Create: Given the order of the drives, as defined at mount time or
  819. configured at runtime, act on the first one found.
  820. T}
  821. T{
  822. lfs (least free space)
  823. T}@T{
  824. Search: Same as \f[B]eplfs\f[].
  825. Action: Same as \f[B]eplfs\f[].
  826. Create: Pick the drive with the least available free space.
  827. T}
  828. T{
  829. lus (least used space)
  830. T}@T{
  831. Search: Same as \f[B]eplus\f[].
  832. Action: Same as \f[B]eplus\f[].
  833. Create: Pick the drive with the least used space.
  834. T}
  835. T{
  836. mfs (most free space)
  837. T}@T{
  838. Search: Same as \f[B]epmfs\f[].
  839. Action: Same as \f[B]epmfs\f[].
  840. Create: Pick the drive with the most available free space.
  841. T}
  842. T{
  843. msplfs (most shared path, least free space)
  844. T}@T{
  845. Search: Same as \f[B]eplfs\f[].
  846. Action: Same as \f[B]eplfs\f[].
  847. Create: like \f[B]eplfs\f[] but walk back the path if it fails to find a
  848. branch at that level.
  849. T}
  850. T{
  851. msplus (most shared path, least used space)
  852. T}@T{
  853. Search: Same as \f[B]eplus\f[].
  854. Action: Same as \f[B]eplus\f[].
  855. Create: like \f[B]eplus\f[] but walk back the path if it fails to find a
  856. branch at that level.
  857. T}
  858. T{
  859. mspmfs (most shared path, most free space)
  860. T}@T{
  861. Search: Same as \f[B]epmfs\f[].
  862. Action: Same as \f[B]epmfs\f[].
  863. Create: like \f[B]epmfs\f[] but walk back the path if it fails to find a
  864. branch at that level.
  865. T}
  866. T{
  867. msppfrd (most shared path, percentage free random distribution)
  868. T}@T{
  869. Search: Same as \f[B]eppfrd\f[].
  870. Action: Same as \f[B]eppfrd\f[].
  871. Create: Like \f[B]eppfrd\f[] but will walk back the path if it fails to
  872. find a branch at that level.
  873. T}
  874. T{
  875. newest
  876. T}@T{
  877. Pick the file / directory with the largest mtime.
  878. T}
  879. T{
  880. pfrd (percentage free random distribution)
  881. T}@T{
  882. Search: Same as \f[B]eppfrd\f[].
  883. Action: Same as \f[B]eppfrd\f[].
  884. Create: Chooses a branch at random with the likelihood of selection
  885. based on a branch\[aq]s available space relative to the total.
  886. T}
  887. T{
  888. rand (random)
  889. T}@T{
  890. Calls \f[B]all\f[] and then randomizes.
  891. Returns 1.
  892. T}
  893. .TE
  894. .PP
  895. \f[B]NOTE:\f[] If you are using an underlying filesystem that reserves
  896. blocks such as ext2, ext3, or ext4 be aware that mergerfs respects the
  897. reservation by using \f[C]f_bavail\f[] (number of free blocks for
  898. unprivileged users) rather than \f[C]f_bfree\f[] (number of free blocks)
  899. in policy calculations.
  900. \f[B]df\f[] does NOT use \f[C]f_bavail\f[], it uses \f[C]f_bfree\f[], so
  901. direct comparisons between \f[B]df\f[] output and mergerfs\[aq] policies
  902. is not appropriate.
  903. .SS Defaults
  904. .PP
  905. .TS
  906. tab(@);
  907. l l.
  908. T{
  909. Category
  910. T}@T{
  911. Policy
  912. T}
  913. _
  914. T{
  915. action
  916. T}@T{
  917. epall
  918. T}
  919. T{
  920. create
  921. T}@T{
  922. epmfs
  923. T}
  924. T{
  925. search
  926. T}@T{
  927. ff
  928. T}
  929. .TE
  930. .SS ioctl
  931. .PP
  932. When \f[C]ioctl\f[] is used with an open file then it will use the file
  933. handle which was created at the original \f[C]open\f[] call.
  934. However, when using \f[C]ioctl\f[] with a directory mergerfs will use
  935. the \f[C]open\f[] policy to find the directory to act on.
  936. .SS unlink
  937. .PP
  938. In FUSE there is an opaque "file handle" which is created by
  939. \f[C]open\f[], \f[C]create\f[], or \f[C]opendir\f[], passed to the
  940. kernel, and then is passed back to the FUSE userland application by the
  941. kernel.
  942. Unfortunately, the FUSE kernel driver does not always send the file
  943. handle when it theoretically could/should.
  944. This complicates certain behaviors / workflows particularly in the high
  945. level API.
  946. As a result mergerfs is currently doing a few hacky things.
  947. .PP
  948. libfuse2 and libfuse3, when using the high level API, will rename names
  949. to \f[C]\&.fuse_hiddenXXXXXX\f[] if the file is open when unlinked or
  950. renamed over.
  951. It does this so the file is still available when a request referencing
  952. the now missing file is made.
  953. This file however keeps a \f[C]rmdir\f[] from succeeding and can be
  954. picked up by software reading directories.
  955. .PP
  956. The change mergerfs has done is that if a file is open when an unlink or
  957. rename happens it will open the file and keep it open till closed by all
  958. those who opened it prior.
  959. When a request comes in referencing that file and it doesn\[aq]t include
  960. a file handle it will instead use the file handle created at
  961. unlink/rename time.
  962. .PP
  963. This won\[aq]t result in technically proper behavior but close enough
  964. for many usecases.
  965. .PP
  966. The plan is to rewrite mergerfs to use the low level API so these
  967. invasive libfuse changes are no longer necessary.
  968. .SS rename & link
  969. .PP
  970. \f[B]NOTE:\f[] If you\[aq]re receiving errors from software when files
  971. are moved / renamed / linked then you should consider changing the
  972. create policy to one which is \f[B]not\f[] path preserving, enabling
  973. \f[C]ignorepponrename\f[], or contacting the author of the offending
  974. software and requesting that \f[C]EXDEV\f[] (cross device / improper
  975. link) be properly handled.
  976. .PP
  977. \f[C]rename\f[] and \f[C]link\f[] are tricky functions in a union
  978. filesystem.
  979. \f[C]rename\f[] only works within a single filesystem or device.
  980. If a rename can\[aq]t be done atomically due to the source and
  981. destination paths existing on different mount points it will return
  982. \f[B]\-1\f[] with \f[B]errno = EXDEV\f[] (cross device / improper link).
  983. So if a \f[C]rename\f[]\[aq]s source and target are on different drives
  984. within the pool it creates an issue.
  985. .PP
  986. Originally mergerfs would return EXDEV whenever a rename was requested
  987. which was cross directory in any way.
  988. This made the code simple and was technically compliant with POSIX
  989. requirements.
  990. However, many applications fail to handle EXDEV at all and treat it as a
  991. normal error or otherwise handle it poorly.
  992. Such apps include: gvfsd\-fuse v1.20.3 and prior, Finder / CIFS/SMB
  993. client in Apple OSX 10.9+, NZBGet, Samba\[aq]s recycling bin feature.
  994. .PP
  995. As a result a compromise was made in order to get most software to work
  996. while still obeying mergerfs\[aq] policies.
  997. Below is the basic logic.
  998. .IP \[bu] 2
  999. If using a \f[B]create\f[] policy which tries to preserve directory
  1000. paths (epff,eplfs,eplus,epmfs)
  1001. .IP \[bu] 2
  1002. Using the \f[B]rename\f[] policy get the list of files to rename
  1003. .IP \[bu] 2
  1004. For each file attempt rename:
  1005. .RS 2
  1006. .IP \[bu] 2
  1007. If failure with ENOENT (no such file or directory) run \f[B]create\f[]
  1008. policy
  1009. .IP \[bu] 2
  1010. If create policy returns the same drive as currently evaluating then
  1011. clone the path
  1012. .IP \[bu] 2
  1013. Re\-attempt rename
  1014. .RE
  1015. .IP \[bu] 2
  1016. If \f[B]any\f[] of the renames succeed the higher level rename is
  1017. considered a success
  1018. .IP \[bu] 2
  1019. If \f[B]no\f[] renames succeed the first error encountered will be
  1020. returned
  1021. .IP \[bu] 2
  1022. On success:
  1023. .RS 2
  1024. .IP \[bu] 2
  1025. Remove the target from all drives with no source file
  1026. .IP \[bu] 2
  1027. Remove the source from all drives which failed to rename
  1028. .RE
  1029. .IP \[bu] 2
  1030. If using a \f[B]create\f[] policy which does \f[B]not\f[] try to
  1031. preserve directory paths
  1032. .IP \[bu] 2
  1033. Using the \f[B]rename\f[] policy get the list of files to rename
  1034. .IP \[bu] 2
  1035. Using the \f[B]getattr\f[] policy get the target path
  1036. .IP \[bu] 2
  1037. For each file attempt rename:
  1038. .RS 2
  1039. .IP \[bu] 2
  1040. If the source drive != target drive:
  1041. .IP \[bu] 2
  1042. Clone target path from target drive to source drive
  1043. .IP \[bu] 2
  1044. Rename
  1045. .RE
  1046. .IP \[bu] 2
  1047. If \f[B]any\f[] of the renames succeed the higher level rename is
  1048. considered a success
  1049. .IP \[bu] 2
  1050. If \f[B]no\f[] renames succeed the first error encountered will be
  1051. returned
  1052. .IP \[bu] 2
  1053. On success:
  1054. .RS 2
  1055. .IP \[bu] 2
  1056. Remove the target from all drives with no source file
  1057. .IP \[bu] 2
  1058. Remove the source from all drives which failed to rename
  1059. .RE
  1060. .PP
  1061. The the removals are subject to normal entitlement checks.
  1062. .PP
  1063. The above behavior will help minimize the likelihood of EXDEV being
  1064. returned but it will still be possible.
  1065. .PP
  1066. \f[B]link\f[] uses the same strategy but without the removals.
  1067. .SS readdir
  1068. .PP
  1069. readdir (http://linux.die.net/man/3/readdir) is different from all other
  1070. filesystem functions.
  1071. While it could have its own set of policies to tweak its behavior at
  1072. this time it provides a simple union of files and directories found.
  1073. Remember that any action or information queried about these files and
  1074. directories come from the respective function.
  1075. For instance: an \f[B]ls\f[] is a \f[B]readdir\f[] and for each
  1076. file/directory returned \f[B]getattr\f[] is called.
  1077. Meaning the policy of \f[B]getattr\f[] is responsible for choosing the
  1078. file/directory which is the source of the metadata you see in an
  1079. \f[B]ls\f[].
  1080. .SS statfs / statvfs
  1081. .PP
  1082. statvfs (http://linux.die.net/man/2/statvfs) normalizes the source
  1083. drives based on the fragment size and sums the number of adjusted blocks
  1084. and inodes.
  1085. This means you will see the combined space of all sources.
  1086. Total, used, and free.
  1087. The sources however are dedupped based on the drive so multiple sources
  1088. on the same drive will not result in double counting its space.
  1089. Filesystems mounted further down the tree of the branch will not be
  1090. included when checking the mount\[aq]s stats.
  1091. .PP
  1092. The options \f[C]statfs\f[] and \f[C]statfs_ignore\f[] can be used to
  1093. modify \f[C]statfs\f[] behavior.
  1094. .SH BUILD / UPDATE
  1095. .PP
  1096. \f[B]NOTE:\f[] Prebuilt packages can be found at and recommended for
  1097. most users: https://github.com/trapexit/mergerfs/releases \f[B]NOTE:\f[]
  1098. Only tagged releases are supported.
  1099. \f[C]master\f[] and other branches should be considered works in
  1100. progress.
  1101. .PP
  1102. First get the code from github (https://github.com/trapexit/mergerfs).
  1103. .IP
  1104. .nf
  1105. \f[C]
  1106. $\ git\ clone\ https://github.com/trapexit/mergerfs.git
  1107. $\ #\ or
  1108. $\ wget\ https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs\-<ver>.tar.gz
  1109. \f[]
  1110. .fi
  1111. .SS Debian / Ubuntu
  1112. .IP
  1113. .nf
  1114. \f[C]
  1115. $\ cd\ mergerfs
  1116. $\ sudo\ tools/install\-build\-pkgs
  1117. $\ make\ deb
  1118. $\ sudo\ dpkg\ \-i\ ../mergerfs_version_arch.deb
  1119. \f[]
  1120. .fi
  1121. .SS RHEL / CentOS /Fedora
  1122. .IP
  1123. .nf
  1124. \f[C]
  1125. $\ su\ \-
  1126. #\ cd\ mergerfs
  1127. #\ tools/install\-build\-pkgs
  1128. #\ make\ rpm
  1129. #\ rpm\ \-i\ rpmbuild/RPMS/<arch>/mergerfs\-<version>.<arch>.rpm
  1130. \f[]
  1131. .fi
  1132. .SS Generically
  1133. .PP
  1134. Have git, g++, make, python installed.
  1135. .IP
  1136. .nf
  1137. \f[C]
  1138. $\ cd\ mergerfs
  1139. $\ make
  1140. $\ sudo\ make\ install
  1141. \f[]
  1142. .fi
  1143. .SS Build options
  1144. .IP
  1145. .nf
  1146. \f[C]
  1147. $\ make\ help
  1148. usage:\ make
  1149. make\ USE_XATTR=0\ \ \ \ \ \ \-\ build\ program\ without\ xattrs\ functionality
  1150. make\ STATIC=1\ \ \ \ \ \ \ \ \ \-\ build\ static\ binary
  1151. make\ LTO=1\ \ \ \ \ \ \ \ \ \ \ \ \-\ build\ with\ link\ time\ optimization
  1152. \f[]
  1153. .fi
  1154. .SH RUNTIME CONFIG
  1155. .SS ioctl
  1156. .PP
  1157. The original runtime config API was via xattr calls.
  1158. This however became an issue when needing to disable xattr.
  1159. While slightly less convenient ioctl does not have the same problems and
  1160. will be the main API going forward.
  1161. .PP
  1162. The keys are the same as the command line option arguments as well as
  1163. the config file.
  1164. .SS requests / commands
  1165. .PP
  1166. All commands take a 4096 byte char buffer.
  1167. .IP \[bu] 2
  1168. read keys: get a nul \[aq]\[aq] delimited list of option keys
  1169. .IP \[bu] 2
  1170. _IOWR(0xDF,0,char[4096]) = 0xD000DF00
  1171. .IP \[bu] 2
  1172. on success ioctl return value is the total length
  1173. .IP \[bu] 2
  1174. read value: get an option value
  1175. .IP \[bu] 2
  1176. _IOWR(0xDF,1,char[4096]) = 0xD000DF01
  1177. .IP \[bu] 2
  1178. the key is passed in via the char buffer as a nul \[aq]\[aq] terminated
  1179. string
  1180. .IP \[bu] 2
  1181. on success ioctl return value is the total length
  1182. .IP \[bu] 2
  1183. write value: set an option value
  1184. .IP \[bu] 2
  1185. _IOW(0xDF,2,char[4096]) = 0x5000DF02
  1186. .IP \[bu] 2
  1187. the key and value is passed in via the char buffer as a nul \[aq]\[aq]
  1188. terminated string in the format of \f[C]key=value\f[]
  1189. .IP \[bu] 2
  1190. on success ioctl return value is 0
  1191. .IP \[bu] 2
  1192. file info: get mergerfs metadata info for a file
  1193. .IP \[bu] 2
  1194. _IOWR(0xDF,3,char[4096]) = 0xD000DF03
  1195. .IP \[bu] 2
  1196. the key is passed in via the char buffer as a nul \[aq]\[aq] terminated
  1197. string
  1198. .IP \[bu] 2
  1199. on success the ioctl return value is the total length
  1200. .IP \[bu] 2
  1201. keys:
  1202. .RS 2
  1203. .IP \[bu] 2
  1204. basepath: the base mount point for the file according to the getattr
  1205. policy
  1206. .IP \[bu] 2
  1207. relpath: the relative path of the file from the mount point
  1208. .IP \[bu] 2
  1209. fullpath: the full path of the underlying file according to the getattr
  1210. policy
  1211. .IP \[bu] 2
  1212. allpaths: a NUL \[aq]\[aq] delimited list of full paths to all files
  1213. found
  1214. .RE
  1215. .SS .mergerfs pseudo file (deprecated)
  1216. .PP
  1217. NOTE: this interface will be removed in mergerfs 3.0
  1218. .IP
  1219. .nf
  1220. \f[C]
  1221. <mountpoint>/.mergerfs
  1222. \f[]
  1223. .fi
  1224. .PP
  1225. There is a pseudo file available at the mount point which allows for the
  1226. runtime modification of certain \f[B]mergerfs\f[] options.
  1227. The file will not show up in \f[B]readdir\f[] but can be
  1228. \f[B]stat\f[]\[aq]ed and manipulated via
  1229. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls.
  1230. .PP
  1231. Any changes made at runtime are \f[B]not\f[] persisted.
  1232. If you wish for values to persist they must be included as options
  1233. wherever you configure the mounting of mergerfs (/etc/fstab).
  1234. .SS Keys
  1235. .PP
  1236. Use \f[C]xattr\ \-l\ /mountpoint/.mergerfs\f[] to see all supported
  1237. keys.
  1238. Some are informational and therefore read\-only.
  1239. \f[C]setxattr\f[] will return EINVAL (invalid argument) on read\-only
  1240. keys.
  1241. .SS Values
  1242. .PP
  1243. Same as the command line.
  1244. .SS user.mergerfs.branches
  1245. .PP
  1246. \f[B]NOTE:\f[] formerly \f[C]user.mergerfs.srcmounts\f[] but said key is
  1247. still supported.
  1248. .PP
  1249. Used to query or modify the list of branches.
  1250. When modifying there are several shortcuts to easy manipulation of the
  1251. list.
  1252. .PP
  1253. .TS
  1254. tab(@);
  1255. l l.
  1256. T{
  1257. Value
  1258. T}@T{
  1259. Description
  1260. T}
  1261. _
  1262. T{
  1263. [list]
  1264. T}@T{
  1265. set
  1266. T}
  1267. T{
  1268. +<[list]
  1269. T}@T{
  1270. prepend
  1271. T}
  1272. T{
  1273. +>[list]
  1274. T}@T{
  1275. append
  1276. T}
  1277. T{
  1278. \-[list]
  1279. T}@T{
  1280. remove all values provided
  1281. T}
  1282. T{
  1283. \-<
  1284. T}@T{
  1285. remove first in list
  1286. T}
  1287. T{
  1288. \->
  1289. T}@T{
  1290. remove last in list
  1291. T}
  1292. .TE
  1293. .PP
  1294. \f[C]xattr\ \-w\ user.mergerfs.branches\ +</mnt/drive3\ /mnt/pool/.mergerfs\f[]
  1295. .PP
  1296. The \f[C]=NC\f[], \f[C]=RO\f[], \f[C]=RW\f[] syntax works just as on the
  1297. command line.
  1298. .SS Example
  1299. .IP
  1300. .nf
  1301. \f[C]
  1302. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-l\ .mergerfs
  1303. user.mergerfs.branches:\ /mnt/a=RW:/mnt/b=RW
  1304. user.mergerfs.minfreespace:\ 4294967295
  1305. user.mergerfs.moveonenospc:\ false
  1306. \&...
  1307. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  1308. ff
  1309. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.category.search\ newest\ .mergerfs
  1310. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  1311. newest
  1312. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.branches\ +/mnt/c\ .mergerfs
  1313. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.branches\ .mergerfs
  1314. /mnt/a:/mnt/b:/mnt/c
  1315. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.branches\ =/mnt/c\ .mergerfs
  1316. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.branches\ .mergerfs
  1317. /mnt/c
  1318. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.branches\ \[aq]+</mnt/a:/mnt/b\[aq]\ .mergerfs
  1319. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.branches\ .mergerfs
  1320. /mnt/a:/mnt/b:/mnt/c
  1321. \f[]
  1322. .fi
  1323. .SS file / directory xattrs
  1324. .PP
  1325. While they won\[aq]t show up when using
  1326. listxattr (http://linux.die.net/man/2/listxattr) \f[B]mergerfs\f[]
  1327. offers a number of special xattrs to query information about the files
  1328. served.
  1329. To access the values you will need to issue a
  1330. getxattr (http://linux.die.net/man/2/getxattr) for one of the following:
  1331. .IP \[bu] 2
  1332. \f[B]user.mergerfs.basepath\f[]: the base mount point for the file given
  1333. the current getattr policy
  1334. .IP \[bu] 2
  1335. \f[B]user.mergerfs.relpath\f[]: the relative path of the file from the
  1336. perspective of the mount point
  1337. .IP \[bu] 2
  1338. \f[B]user.mergerfs.fullpath\f[]: the full path of the original file
  1339. given the getattr policy
  1340. .IP \[bu] 2
  1341. \f[B]user.mergerfs.allpaths\f[]: a NUL (\[aq]\[aq]) separated list of
  1342. full paths to all files found
  1343. .IP
  1344. .nf
  1345. \f[C]
  1346. [trapexit:/mnt/mergerfs]\ $\ ls
  1347. A\ B\ C
  1348. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.fullpath\ A
  1349. /mnt/a/full/path/to/A
  1350. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.basepath\ A
  1351. /mnt/a
  1352. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.relpath\ A
  1353. /full/path/to/A
  1354. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.allpaths\ A\ |\ tr\ \[aq]\\0\[aq]\ \[aq]\\n\[aq]
  1355. /mnt/a/full/path/to/A
  1356. /mnt/b/full/path/to/A
  1357. \f[]
  1358. .fi
  1359. .SH UPGRADE
  1360. .PP
  1361. mergerfs can be upgraded live by mounting on top of the previous
  1362. version.
  1363. Simply install the new version of mergerfs and follow the instructions
  1364. below.
  1365. .PP
  1366. Add \f[C]nonempty\f[] to your mergerfs option list and call mergerfs
  1367. again or if using \f[C]/etc/fstab\f[] call for it to mount again.
  1368. Existing open files and such will continue to work fine though they
  1369. won\[aq]t see runtime changes since any such change would be the new
  1370. mount.
  1371. If you plan on changing settings with the new mount you should / could
  1372. apply those before mounting the new version.
  1373. .IP
  1374. .nf
  1375. \f[C]
  1376. $\ sudo\ mount\ /mnt/mergerfs
  1377. $\ mount\ |\ grep\ mergerfs
  1378. media\ on\ /mnt/mergerfs\ type\ fuse.mergerfs\ (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
  1379. media\ on\ /mnt/mergerfs\ type\ fuse.mergerfs\ (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
  1380. \f[]
  1381. .fi
  1382. .SH TOOLING
  1383. .IP \[bu] 2
  1384. https://github.com/trapexit/mergerfs\-tools
  1385. .IP \[bu] 2
  1386. mergerfs.ctl: A tool to make it easier to query and configure mergerfs
  1387. at runtime
  1388. .IP \[bu] 2
  1389. mergerfs.fsck: Provides permissions and ownership auditing and the
  1390. ability to fix them
  1391. .IP \[bu] 2
  1392. mergerfs.dedup: Will help identify and optionally remove duplicate files
  1393. .IP \[bu] 2
  1394. mergerfs.dup: Ensure there are at least N copies of a file across the
  1395. pool
  1396. .IP \[bu] 2
  1397. mergerfs.balance: Rebalance files across drives by moving them from the
  1398. most filled to the least filled
  1399. .IP \[bu] 2
  1400. mergerfs.consolidate: move files within a single mergerfs directory to
  1401. the drive with most free space
  1402. .IP \[bu] 2
  1403. mergerfs.mktrash: Creates FreeDesktop.org Trash specification compatible
  1404. directories on a mergerfs mount
  1405. .IP \[bu] 2
  1406. https://github.com/trapexit/scorch
  1407. .IP \[bu] 2
  1408. scorch: A tool to help discover silent corruption of files and keep
  1409. track of files
  1410. .IP \[bu] 2
  1411. https://github.com/trapexit/bbf
  1412. .IP \[bu] 2
  1413. bbf (bad block finder): a tool to scan for and \[aq]fix\[aq] hard drive
  1414. bad blocks and find the files using those blocks
  1415. .SH CACHING
  1416. .SS page caching
  1417. .PP
  1418. https://en.wikipedia.org/wiki/Page_cache
  1419. .PP
  1420. tl;dr: * cache.files=off: Disables page caching.
  1421. Underlying files cached, mergerfs files are not.
  1422. * cache.files=partial: Enables page caching.
  1423. Underlying files cached, mergerfs files cached while open.
  1424. * cache.files=full: Enables page caching.
  1425. Underlying files cached, mergerfs files cached across opens.
  1426. * cache.files=auto\-full: Enables page caching.
  1427. Underlying files cached, mergerfs files cached across opens if mtime and
  1428. size are unchanged since previous open.
  1429. * cache.files=libfuse: follow traditional libfuse \f[C]direct_io\f[],
  1430. \f[C]kernel_cache\f[], and \f[C]auto_cache\f[] arguments.
  1431. .PP
  1432. FUSE, which mergerfs uses, offers a number of page caching modes.
  1433. mergerfs tries to simplify their use via the \f[C]cache.files\f[]
  1434. option.
  1435. It can and should replace usage of \f[C]direct_io\f[],
  1436. \f[C]kernel_cache\f[], and \f[C]auto_cache\f[].
  1437. .PP
  1438. Due to mergerfs using FUSE and therefore being a userland process
  1439. proxying existing filesystems the kernel will double cache the content
  1440. being read and written through mergerfs.
  1441. Once from the underlying filesystem and once from mergerfs (it sees them
  1442. as two separate entities).
  1443. Using \f[C]cache.files=off\f[] will keep the double caching from
  1444. happening by disabling caching of mergerfs but this has the side effect
  1445. that \f[I]all\f[] read and write calls will be passed to mergerfs which
  1446. may be slower than enabling caching, you lose shared \f[C]mmap\f[]
  1447. support which can affect apps such as rtorrent, and no read\-ahead will
  1448. take place.
  1449. The kernel will still cache the underlying filesystem data but that only
  1450. helps so much given mergerfs will still process all requests.
  1451. .PP
  1452. If you do enable file page caching,
  1453. \f[C]cache.files=partial|full|auto\-full\f[], you should also enable
  1454. \f[C]dropcacheonclose\f[] which will cause mergerfs to instruct the
  1455. kernel to flush the underlying file\[aq]s page cache when the file is
  1456. closed.
  1457. This behavior is the same as the rsync fadvise / drop cache patch and
  1458. Feh\[aq]s nocache project.
  1459. .PP
  1460. If most files are read once through and closed (like media) it is best
  1461. to enable \f[C]dropcacheonclose\f[] regardless of caching mode in order
  1462. to minimize buffer bloat.
  1463. .PP
  1464. It is difficult to balance memory usage, cache bloat & duplication, and
  1465. performance.
  1466. Ideally mergerfs would be able to disable caching for the files it
  1467. reads/writes but allow page caching for itself.
  1468. That would limit the FUSE overhead.
  1469. However, there isn\[aq]t a good way to achieve this.
  1470. It would need to open all files with O_DIRECT which places limitations
  1471. on the what underlying filesystems would be supported and complicates
  1472. the code.
  1473. .PP
  1474. kernel documentation:
  1475. https://www.kernel.org/doc/Documentation/filesystems/fuse\-io.txt
  1476. .SS entry & attribute caching
  1477. .PP
  1478. Given the relatively high cost of FUSE due to the kernel <\-> userspace
  1479. round trips there are kernel side caches for file entries and
  1480. attributes.
  1481. The entry cache limits the \f[C]lookup\f[] calls to mergerfs which ask
  1482. if a file exists.
  1483. The attribute cache limits the need to make \f[C]getattr\f[] calls to
  1484. mergerfs which provide file attributes (mode, size, type, etc.).
  1485. As with the page cache these should not be used if the underlying
  1486. filesystems are being manipulated at the same time as it could lead to
  1487. odd behavior or data corruption.
  1488. The options for setting these are \f[C]cache.entry\f[] and
  1489. \f[C]cache.negative_entry\f[] for the entry cache and
  1490. \f[C]cache.attr\f[] for the attributes cache.
  1491. \f[C]cache.negative_entry\f[] refers to the timeout for negative
  1492. responses to lookups (non\-existent files).
  1493. .SS writeback caching
  1494. .PP
  1495. When \f[C]cache.files\f[] is enabled the default is for it to perform
  1496. writethrough caching.
  1497. This behavior won\[aq]t help improve performance as each write still
  1498. goes one for one through the filesystem.
  1499. By enabling the FUSE writeback cache small writes may be aggregated by
  1500. the kernel and then sent to mergerfs as one larger request.
  1501. This can greatly improve the throughput for apps which write to files
  1502. inefficiently.
  1503. The amount the kernel can aggregate is limited by the size of a FUSE
  1504. message.
  1505. Read the \f[C]fuse_msg_size\f[] section for more details.
  1506. .PP
  1507. There is a small side effect as a result of enabling writeback caching.
  1508. Underlying files won\[aq]t ever be opened with O_APPEND or O_WRONLY.
  1509. The former because the kernel then manages append mode and the latter
  1510. because the kernel may request file data from mergerfs to populate the
  1511. write cache.
  1512. The O_APPEND change means that if a file is changed outside of mergerfs
  1513. it could lead to corruption as the kernel won\[aq]t know the end of the
  1514. file has changed.
  1515. That said any time you use caching you should keep from using the same
  1516. file outside of mergerfs at the same time.
  1517. .PP
  1518. Note that if an application is properly sizing writes then writeback
  1519. caching will have little or no effect.
  1520. It will only help with writes of sizes below the FUSE message size (128K
  1521. on older kernels, 1M on newer).
  1522. .SS policy caching
  1523. .PP
  1524. Policies are run every time a function (with a policy as mentioned
  1525. above) is called.
  1526. These policies can be expensive depending on mergerfs\[aq] setup and
  1527. client usage patterns.
  1528. Generally we wouldn\[aq]t want to cache policy results because it may
  1529. result in stale responses if the underlying drives are used directly.
  1530. .PP
  1531. The \f[C]open\f[] policy cache will cache the result of an \f[C]open\f[]
  1532. policy for a particular input for \f[C]cache.open\f[] seconds or until
  1533. the file is unlinked.
  1534. Each file close (release) will randomly chose to clean up the cache of
  1535. expired entries.
  1536. .PP
  1537. This cache is really only useful in cases where you have a large number
  1538. of branches and \f[C]open\f[] is called on the same files repeatedly
  1539. (like \f[B]Transmission\f[] which opens and closes a file on every
  1540. read/write presumably to keep file handle usage low).
  1541. .SS statfs caching
  1542. .PP
  1543. Of the syscalls used by mergerfs in policies the \f[C]statfs\f[] /
  1544. \f[C]statvfs\f[] call is perhaps the most expensive.
  1545. It\[aq]s used to find out the available space of a drive and whether it
  1546. is mounted read\-only.
  1547. Depending on the setup and usage pattern these queries can be relatively
  1548. costly.
  1549. When \f[C]cache.statfs\f[] is enabled all calls to \f[C]statfs\f[] by a
  1550. policy will be cached for the number of seconds its set to.
  1551. .PP
  1552. Example: If the create policy is \f[C]mfs\f[] and the timeout is 60 then
  1553. for that 60 seconds the same drive will be returned as the target for
  1554. creates because the available space won\[aq]t be updated for that time.
  1555. .SS symlink caching
  1556. .PP
  1557. As of version 4.20 Linux supports symlink caching.
  1558. Significant performance increases can be had in workloads which use a
  1559. lot of symlinks.
  1560. Setting \f[C]cache.symlinks=true\f[] will result in requesting symlink
  1561. caching from the kernel only if supported.
  1562. As a result its safe to enable it on systems prior to 4.20.
  1563. That said it is disabled by default for now.
  1564. You can see if caching is enabled by querying the xattr
  1565. \f[C]user.mergerfs.cache.symlinks\f[] but given it must be requested at
  1566. startup you can not change it at runtime.
  1567. .SS readdir caching
  1568. .PP
  1569. As of version 4.20 Linux supports readdir caching.
  1570. This can have a significant impact on directory traversal.
  1571. Especially when combined with entry (\f[C]cache.entry\f[]) and attribute
  1572. (\f[C]cache.attr\f[]) caching.
  1573. Setting \f[C]cache.readdir=true\f[] will result in requesting readdir
  1574. caching from the kernel on each \f[C]opendir\f[].
  1575. If the kernel doesn\[aq]t support readdir caching setting the option to
  1576. \f[C]true\f[] has no effect.
  1577. This option is configurable at runtime via xattr
  1578. \f[C]user.mergerfs.cache.readdir\f[].
  1579. .SS tiered caching
  1580. .PP
  1581. Some storage technologies support what some call "tiered" caching.
  1582. The placing of usually smaller, faster storage as a transparent cache to
  1583. larger, slower storage.
  1584. NVMe, SSD, Optane in front of traditional HDDs for instance.
  1585. .PP
  1586. MergerFS does not natively support any sort of tiered caching.
  1587. Most users have no use for such a feature and its inclusion would
  1588. complicate the code.
  1589. However, there are a few situations where a cache drive could help with
  1590. a typical mergerfs setup.
  1591. .IP "1." 3
  1592. Fast network, slow drives, many readers: You\[aq]ve a 10+Gbps network
  1593. with many readers and your regular drives can\[aq]t keep up.
  1594. .IP "2." 3
  1595. Fast network, slow drives, small\[aq]ish bursty writes: You have a
  1596. 10+Gbps network and wish to transfer amounts of data less than your
  1597. cache drive but wish to do so quickly.
  1598. .PP
  1599. With #1 its arguable if you should be using mergerfs at all.
  1600. RAID would probably be the better solution.
  1601. If you\[aq]re going to use mergerfs there are other tactics that may
  1602. help: spreading the data across drives (see the mergerfs.dup tool) and
  1603. setting \f[C]func.open=rand\f[], using \f[C]symlinkify\f[], or using
  1604. dm\-cache or a similar technology to add tiered cache to the underlying
  1605. device.
  1606. .PP
  1607. With #2 one could use dm\-cache as well but there is another solution
  1608. which requires only mergerfs and a cronjob.
  1609. .IP "1." 3
  1610. Create 2 mergerfs pools.
  1611. One which includes just the slow drives and one which has both the fast
  1612. drives (SSD,NVME,etc.) and slow drives.
  1613. .IP "2." 3
  1614. The \[aq]cache\[aq] pool should have the cache drives listed first.
  1615. .IP "3." 3
  1616. The best \f[C]create\f[] policies to use for the \[aq]cache\[aq] pool
  1617. would probably be \f[C]ff\f[], \f[C]epff\f[], \f[C]lfs\f[], or
  1618. \f[C]eplfs\f[].
  1619. The latter two under the assumption that the cache drive(s) are far
  1620. smaller than the backing drives.
  1621. If using path preserving policies remember that you\[aq]ll need to
  1622. manually create the core directories of those paths you wish to be
  1623. cached.
  1624. Be sure the permissions are in sync.
  1625. Use \f[C]mergerfs.fsck\f[] to check / correct them.
  1626. You could also tag the slow drives as \f[C]=NC\f[] though that\[aq]d
  1627. mean if the cache drives fill you\[aq]d get "out of space" errors.
  1628. .IP "4." 3
  1629. Enable \f[C]moveonenospc\f[] and set \f[C]minfreespace\f[]
  1630. appropriately.
  1631. To make sure there is enough room on the "slow" pool you might want to
  1632. set \f[C]minfreespace\f[] to at least as large as the size of the
  1633. largest cache drive if not larger.
  1634. This way in the worst case the whole of the cache drive(s) can be moved
  1635. to the other drives.
  1636. .IP "5." 3
  1637. Set your programs to use the cache pool.
  1638. .IP "6." 3
  1639. Save one of the below scripts or create you\[aq]re own.
  1640. .IP "7." 3
  1641. Use \f[C]cron\f[] (as root) to schedule the command at whatever
  1642. frequency is appropriate for your workflow.
  1643. .SS time based expiring
  1644. .PP
  1645. Move files from cache to backing pool based only on the last time the
  1646. file was accessed.
  1647. Replace \f[C]\-atime\f[] with \f[C]\-amin\f[] if you want minutes rather
  1648. than days.
  1649. May want to use the \f[C]fadvise\f[] / \f[C]\-\-drop\-cache\f[] version
  1650. of rsync or run rsync with the tool "nocache".
  1651. .IP
  1652. .nf
  1653. \f[C]
  1654. #!/bin/bash
  1655. if\ [\ $#\ !=\ 3\ ];\ then
  1656. \ \ echo\ "usage:\ $0\ <cache\-drive>\ <backing\-pool>\ <days\-old>"
  1657. \ \ exit\ 1
  1658. fi
  1659. CACHE="${1}"
  1660. BACKING="${2}"
  1661. N=${3}
  1662. find\ "${CACHE}"\ \-type\ f\ \-atime\ +${N}\ \-printf\ \[aq]%P\\n\[aq]\ |\ \\
  1663. \ \ rsync\ \-\-files\-from=\-\ \-axqHAXWES\ \-\-preallocate\ \-\-remove\-source\-files\ "${CACHE}/"\ "${BACKING}/"
  1664. \f[]
  1665. .fi
  1666. .SS percentage full expiring
  1667. .PP
  1668. Move the oldest file from the cache to the backing pool.
  1669. Continue till below percentage threshold.
  1670. .IP
  1671. .nf
  1672. \f[C]
  1673. #!/bin/bash
  1674. if\ [\ $#\ !=\ 3\ ];\ then
  1675. \ \ echo\ "usage:\ $0\ <cache\-drive>\ <backing\-pool>\ <percentage>"
  1676. \ \ exit\ 1
  1677. fi
  1678. CACHE="${1}"
  1679. BACKING="${2}"
  1680. PERCENTAGE=${3}
  1681. set\ \-o\ errexit
  1682. while\ [\ $(df\ \-\-output=pcent\ "${CACHE}"\ |\ grep\ \-v\ Use\ |\ cut\ \-d\[aq]%\[aq]\ \-f1)\ \-gt\ ${PERCENTAGE}\ ]
  1683. do
  1684. \ \ \ \ FILE=$(find\ "${CACHE}"\ \-type\ f\ \-printf\ \[aq]%A\@\ %P\\n\[aq]\ |\ \\
  1685. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sort\ |\ \\
  1686. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ head\ \-n\ 1\ |\ \\
  1687. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cut\ \-d\[aq]\ \[aq]\ \-f2\-)
  1688. \ \ \ \ test\ \-n\ "${FILE}"
  1689. \ \ \ \ rsync\ \-axqHAXWES\ \-\-preallocate\ \-\-remove\-source\-files\ "${CACHE}/./${FILE}"\ "${BACKING}/"
  1690. done
  1691. \f[]
  1692. .fi
  1693. .SH PERFORMANCE
  1694. .PP
  1695. mergerfs is at its core just a proxy and therefore its theoretical max
  1696. performance is that of the underlying devices.
  1697. However, given it is a FUSE filesystem working from userspace there is
  1698. an increase in overhead relative to kernel based solutions.
  1699. That said the performance can match the theoretical max but it depends
  1700. greatly on the system\[aq]s configuration.
  1701. Especially when adding network filesystems into the mix there are many
  1702. variables which can impact performance.
  1703. Drive speeds and latency, network speeds and latency, general
  1704. concurrency, read/write sizes, etc.
  1705. Unfortunately, given the number of variables it has been difficult to
  1706. find a single set of settings which provide optimal performance.
  1707. If you\[aq]re having performance issues please look over the suggestions
  1708. below (including the benchmarking section.)
  1709. .PP
  1710. NOTE: be sure to read about these features before changing them to
  1711. understand what behaviors it may impact
  1712. .IP \[bu] 2
  1713. enable (or disable) \f[C]splice_move\f[], \f[C]splice_read\f[], and
  1714. \f[C]splice_write\f[]
  1715. .IP \[bu] 2
  1716. disable \f[C]security_capability\f[] and/or \f[C]xattr\f[]
  1717. .IP \[bu] 2
  1718. increase cache timeouts \f[C]cache.attr\f[], \f[C]cache.entry\f[],
  1719. \f[C]cache.negative_entry\f[]
  1720. .IP \[bu] 2
  1721. enable (or disable) page caching (\f[C]cache.files\f[])
  1722. .IP \[bu] 2
  1723. enable \f[C]cache.writeback\f[]
  1724. .IP \[bu] 2
  1725. enable \f[C]cache.open\f[]
  1726. .IP \[bu] 2
  1727. enable \f[C]cache.statfs\f[]
  1728. .IP \[bu] 2
  1729. enable \f[C]cache.symlinks\f[]
  1730. .IP \[bu] 2
  1731. enable \f[C]cache.readdir\f[]
  1732. .IP \[bu] 2
  1733. change the number of worker threads
  1734. .IP \[bu] 2
  1735. disable \f[C]posix_acl\f[]
  1736. .IP \[bu] 2
  1737. disable \f[C]async_read\f[]
  1738. .IP \[bu] 2
  1739. test theoretical performance using \f[C]nullrw\f[] or mounting a ram
  1740. disk
  1741. .IP \[bu] 2
  1742. use \f[C]symlinkify\f[] if your data is largely static and read\-only
  1743. .IP \[bu] 2
  1744. use tiered cache drives
  1745. .IP \[bu] 2
  1746. use LVM and LVM cache to place a SSD in front of your HDDs
  1747. .PP
  1748. If you come across a setting that significantly impacts performance
  1749. please contact trapexit so he may investigate further.
  1750. .SH BENCHMARKING
  1751. .PP
  1752. Filesystems are complicated.
  1753. They do many things and many of those are interconnected.
  1754. Additionally, the OS, drivers, hardware, etc.
  1755. all can impact performance.
  1756. Therefore, when benchmarking, it is \f[B]necessary\f[] that the test
  1757. focus as narrowly as possible.
  1758. .PP
  1759. For most throughput is the key benchmark.
  1760. To test throughput \f[C]dd\f[] is useful but \f[B]must\f[] be used with
  1761. the correct settings in order to ensure the filesystem or device is
  1762. actually being tested.
  1763. The OS can and will cache data.
  1764. Without forcing synchronous reads and writes and/or disabling caching
  1765. the values returned will not be representative of the device\[aq]s true
  1766. performance.
  1767. .PP
  1768. When benchmarking through mergerfs ensure you only use 1 branch to
  1769. remove any possibility of the policies complicating the situation.
  1770. Benchmark the underlying filesystem first and then mount mergerfs over
  1771. it and test again.
  1772. If you\[aq]re experience speeds below your expectation you will need to
  1773. narrow down precisely which component is leading to the slowdown.
  1774. Preferably test the following in the order listed (but not combined).
  1775. .IP "1." 3
  1776. Enable \f[C]nullrw\f[] mode with \f[C]nullrw=true\f[].
  1777. This will effectively make reads and writes no\-ops.
  1778. Removing the underlying device / filesystem from the equation.
  1779. This will give us the top theoretical speeds.
  1780. .IP "2." 3
  1781. Mount mergerfs over \f[C]tmpfs\f[].
  1782. \f[C]tmpfs\f[] is a RAM disk.
  1783. Extremely high speed and very low latency.
  1784. This is a more realistic best case scenario.
  1785. Example: \f[C]mount\ \-t\ tmpfs\ \-o\ size=2G\ tmpfs\ /tmp/tmpfs\f[]
  1786. .IP "3." 3
  1787. Mount mergerfs over a local drive.
  1788. NVMe, SSD, HDD, etc.
  1789. If you have more than one I\[aq]d suggest testing each of them as drives
  1790. and/or controllers (their drivers) could impact performance.
  1791. .IP "4." 3
  1792. Finally, if you intend to use mergerfs with a network filesystem, either
  1793. as the source of data or to combine with another through mergerfs, test
  1794. each of those alone as above.
  1795. .PP
  1796. Once you find the component which has the performance issue you can do
  1797. further testing with different options to see if they impact
  1798. performance.
  1799. For reads and writes the most relevant would be: \f[C]cache.files\f[],
  1800. \f[C]async_read\f[], \f[C]splice_move\f[], \f[C]splice_read\f[],
  1801. \f[C]splice_write\f[].
  1802. Less likely but relevant when using NFS or with certain filesystems
  1803. would be \f[C]security_capability\f[], \f[C]xattr\f[], and
  1804. \f[C]posix_acl\f[].
  1805. If you find a specific system, drive, filesystem, controller, etc.
  1806. that performs poorly contact trapexit so he may investigate further.
  1807. .PP
  1808. Sometimes the problem is really the application accessing or writing
  1809. data through mergerfs.
  1810. Some software use small buffer sizes which can lead to more requests and
  1811. therefore greater overhead.
  1812. You can test this out yourself by replace \f[C]bs=1M\f[] in the examples
  1813. below with \f[C]ibs\f[] or \f[C]obs\f[] and using a size of \f[C]512\f[]
  1814. instead of \f[C]1M\f[].
  1815. In one example test using \f[C]nullrw\f[] the write speed dropped from
  1816. 4.9GB/s to 69.7MB/s when moving from \f[C]1M\f[] to \f[C]512\f[].
  1817. Similar results were had when testing reads.
  1818. Small writes overhead may be improved by leveraging a write cache but in
  1819. casual tests little gain was found.
  1820. More tests will need to be done before this feature would become
  1821. available.
  1822. If you have an app that appears slow with mergerfs it could be due to
  1823. this.
  1824. Contact trapexit so he may investigate further.
  1825. .SS write benchmark
  1826. .IP
  1827. .nf
  1828. \f[C]
  1829. $\ dd\ if=/dev/zero\ of=/mnt/mergerfs/1GB.file\ bs=1M\ count=1024\ oflag=nocache\ conv=fdatasync\ status=progress
  1830. \f[]
  1831. .fi
  1832. .SS read benchmark
  1833. .IP
  1834. .nf
  1835. \f[C]
  1836. $\ dd\ if=/mnt/mergerfs/1GB.file\ of=/dev/null\ bs=1M\ count=1024\ iflag=nocache\ conv=fdatasync\ status=progress
  1837. \f[]
  1838. .fi
  1839. .SH TIPS / NOTES
  1840. .IP \[bu] 2
  1841. \f[B]use_ino\f[] will only work when used with mergerfs 2.18.0 and
  1842. above.
  1843. .IP \[bu] 2
  1844. Run mergerfs as \f[C]root\f[] (with \f[B]allow_other\f[]) unless
  1845. you\[aq]re merging paths which are owned by the same user otherwise
  1846. strange permission issues may arise.
  1847. .IP \[bu] 2
  1848. https://github.com/trapexit/backup\-and\-recovery\-howtos : A set of
  1849. guides / howtos on creating a data storage system, backing it up,
  1850. maintaining it, and recovering from failure.
  1851. .IP \[bu] 2
  1852. If you don\[aq]t see some directories and files you expect in a merged
  1853. point or policies seem to skip drives be sure the user has permission to
  1854. all the underlying directories.
  1855. Use \f[C]mergerfs.fsck\f[] to audit the drive for out of sync
  1856. permissions.
  1857. .IP \[bu] 2
  1858. Do \f[B]not\f[] use \f[C]cache.files=off\f[] if you expect applications
  1859. (such as rtorrent) to use mmap (http://linux.die.net/man/2/mmap) files.
  1860. Shared mmap is not currently supported in FUSE w/ page caching disabled.
  1861. Enabling \f[C]dropcacheonclose\f[] is recommended when
  1862. \f[C]cache.files=partial|full|auto\-full\f[].
  1863. .IP \[bu] 2
  1864. Since POSIX functions give only a singular error or success its
  1865. difficult to determine the proper behavior when applying the function to
  1866. multiple targets.
  1867. \f[B]mergerfs\f[] will return an error only if all attempts of an action
  1868. fail.
  1869. Any success will lead to a success returned.
  1870. This means however that some odd situations may arise.
  1871. .IP \[bu] 2
  1872. Kodi (http://kodi.tv), Plex (http://plex.tv),
  1873. Subsonic (http://subsonic.org), etc.
  1874. can use directory mtime (http://linux.die.net/man/2/stat) to more
  1875. efficiently determine whether to scan for new content rather than simply
  1876. performing a full scan.
  1877. If using the default \f[B]getattr\f[] policy of \f[B]ff\f[] it\[aq]s
  1878. possible those programs will miss an update on account of it returning
  1879. the first directory found\[aq]s \f[B]stat\f[] info and its a later
  1880. directory on another mount which had the \f[B]mtime\f[] recently
  1881. updated.
  1882. To fix this you will want to set \f[B]func.getattr=newest\f[].
  1883. Remember though that this is just \f[B]stat\f[].
  1884. If the file is later \f[B]open\f[]\[aq]ed or \f[B]unlink\f[]\[aq]ed and
  1885. the policy is different for those then a completely different file or
  1886. directory could be acted on.
  1887. .IP \[bu] 2
  1888. Some policies mixed with some functions may result in strange behaviors.
  1889. Not that some of these behaviors and race conditions couldn\[aq]t happen
  1890. outside \f[B]mergerfs\f[] but that they are far more likely to occur on
  1891. account of the attempt to merge together multiple sources of data which
  1892. could be out of sync due to the different policies.
  1893. .IP \[bu] 2
  1894. For consistency its generally best to set \f[B]category\f[] wide
  1895. policies rather than individual \f[B]func\f[]\[aq]s.
  1896. This will help limit the confusion of tools such as
  1897. rsync (http://linux.die.net/man/1/rsync).
  1898. However, the flexibility is there if needed.
  1899. .SH KNOWN ISSUES / BUGS
  1900. .SS kernel issues & bugs
  1901. .PP
  1902. <https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs>
  1903. .SS directory mtime is not being updated
  1904. .PP
  1905. Remember that the default policy for \f[C]getattr\f[] is \f[C]ff\f[].
  1906. The information for the first directory found will be returned.
  1907. If it wasn\[aq]t the directory which had been updated then it will
  1908. appear outdated.
  1909. .PP
  1910. The reason this is the default is because any other policy would be more
  1911. expensive and for many applications it is unnecessary.
  1912. To always return the directory with the most recent mtime or a faked
  1913. value based on all found would require a scan of all drives.
  1914. .PP
  1915. If you always want the directory information from the one with the most
  1916. recent mtime then use the \f[C]newest\f[] policy for \f[C]getattr\f[].
  1917. .SS \[aq]mv /mnt/pool/foo /mnt/disk1/foo\[aq] removes \[aq]foo\[aq]
  1918. .PP
  1919. This is not a bug.
  1920. .PP
  1921. Run in verbose mode to better understand what\[aq]s happening:
  1922. .IP
  1923. .nf
  1924. \f[C]
  1925. $\ mv\ \-v\ /mnt/pool/foo\ /mnt/disk1/foo
  1926. copied\ \[aq]/mnt/pool/foo\[aq]\ \->\ \[aq]/mnt/disk1/foo\[aq]
  1927. removed\ \[aq]/mnt/pool/foo\[aq]
  1928. $\ ls\ /mnt/pool/foo
  1929. ls:\ cannot\ access\ \[aq]/mnt/pool/foo\[aq]:\ No\ such\ file\ or\ directory
  1930. \f[]
  1931. .fi
  1932. .PP
  1933. \f[C]mv\f[], when working across devices, is copying the source to
  1934. target and then removing the source.
  1935. Since the source \f[B]is\f[] the target in this case, depending on the
  1936. unlink policy, it will remove the just copied file and other files
  1937. across the branches.
  1938. .PP
  1939. If you want to move files to one drive just copy them there and use
  1940. mergerfs.dedup to clean up the old paths or manually remove them from
  1941. the branches directly.
  1942. .SS cached memory appears greater than it should be
  1943. .PP
  1944. Use \f[C]cache.files=off\f[] and/or \f[C]dropcacheonclose=true\f[].
  1945. See the section on page caching.
  1946. .SS NFS clients returning ESTALE / Stale file handle
  1947. .PP
  1948. NFS does not like out of band changes.
  1949. That is especially true of inode values.
  1950. .PP
  1951. Be sure to use the following options:
  1952. .IP \[bu] 2
  1953. noforget
  1954. .IP \[bu] 2
  1955. use_ino
  1956. .IP \[bu] 2
  1957. inodecalc=path\-hash
  1958. .SS rtorrent fails with ENODEV (No such device)
  1959. .PP
  1960. Be sure to set \f[C]cache.files=partial|full|auto\-full\f[] or turn off
  1961. \f[C]direct_io\f[].
  1962. rtorrent and some other applications use
  1963. mmap (http://linux.die.net/man/2/mmap) to read and write to files and
  1964. offer no fallback to traditional methods.
  1965. FUSE does not currently support mmap while using \f[C]direct_io\f[].
  1966. There may be a performance penalty on writes with \f[C]direct_io\f[] off
  1967. as well as the problem of double caching but it\[aq]s the only way to
  1968. get such applications to work.
  1969. If the performance loss is too high for other apps you can mount
  1970. mergerfs twice.
  1971. Once with \f[C]direct_io\f[] enabled and one without it.
  1972. Be sure to set \f[C]dropcacheonclose=true\f[] if not using
  1973. \f[C]direct_io\f[].
  1974. .SS Plex doesn\[aq]t work with mergerfs
  1975. .PP
  1976. It does.
  1977. If you\[aq]re trying to put Plex\[aq]s config / metadata / database on
  1978. mergerfs you can\[aq]t set \f[C]cache.files=off\f[] because Plex is
  1979. using sqlite3 with mmap enabled.
  1980. Shared mmap is not supported by Linux\[aq]s FUSE implementation when
  1981. page caching is disabled.
  1982. To fix this place the data elsewhere (preferable) or enable
  1983. \f[C]cache.files\f[] (with \f[C]dropcacheonclose=true\f[]).
  1984. Sqlite3 does not need mmap but the developer needs to fall back to
  1985. standard IO if mmap fails.
  1986. .PP
  1987. If the issue is that scanning doesn\[aq]t seem to pick up media then be
  1988. sure to set \f[C]func.getattr=newest\f[] though generally a full scan
  1989. will pick up all media anyway.
  1990. .SS When a program tries to move or rename a file it fails
  1991. .PP
  1992. Please read the section above regarding rename & link (#rename--link).
  1993. .PP
  1994. The problem is that many applications do not properly handle
  1995. \f[C]EXDEV\f[] errors which \f[C]rename\f[] and \f[C]link\f[] may return
  1996. even though they are perfectly valid situations which do not indicate
  1997. actual drive or OS errors.
  1998. The error will only be returned by mergerfs if using a path preserving
  1999. policy as described in the policy section above.
  2000. If you do not care about path preservation simply change the mergerfs
  2001. policy to the non\-path preserving version.
  2002. For example: \f[C]\-o\ category.create=mfs\f[]
  2003. .PP
  2004. Ideally the offending software would be fixed and it is recommended that
  2005. if you run into this problem you contact the software\[aq]s author and
  2006. request proper handling of \f[C]EXDEV\f[] errors.
  2007. .SS my 32bit software has problems
  2008. .PP
  2009. Some software have problems with 64bit inode values.
  2010. The symptoms can include EOVERFLOW errors when trying to list files.
  2011. You can address this by setting \f[C]inodecalc\f[] to one of the 32bit
  2012. based algos as described in the relevant section.
  2013. .SS Samba: Moving files / directories fails
  2014. .PP
  2015. Workaround: Copy the file/directory and then remove the original rather
  2016. than move.
  2017. .PP
  2018. This isn\[aq]t an issue with Samba but some SMB clients.
  2019. GVFS\-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed
  2020. to handle certain error codes correctly.
  2021. Particularly \f[B]STATUS_NOT_SAME_DEVICE\f[] which comes from the
  2022. \f[B]EXDEV\f[] which is returned by \f[B]rename\f[] when the call is
  2023. crossing mount points.
  2024. When a program gets an \f[B]EXDEV\f[] it needs to explicitly take an
  2025. alternate action to accomplish its goal.
  2026. In the case of \f[B]mv\f[] or similar it tries \f[B]rename\f[] and on
  2027. \f[B]EXDEV\f[] falls back to a manual copying of data between the two
  2028. locations and unlinking the source.
  2029. In these older versions of GVFS\-fuse if it received \f[B]EXDEV\f[] it
  2030. would translate that into \f[B]EIO\f[].
  2031. This would cause \f[B]mv\f[] or most any application attempting to move
  2032. files around on that SMB share to fail with a IO error.
  2033. .PP
  2034. GVFS\-fuse v1.22.0 (https://bugzilla.gnome.org/show_bug.cgi?id=734568)
  2035. and above fixed this issue but a large number of systems use the older
  2036. release.
  2037. On Ubuntu the version can be checked by issuing
  2038. \f[C]apt\-cache\ showpkg\ gvfs\-fuse\f[].
  2039. Most distros released in 2015 seem to have the updated release and will
  2040. work fine but older systems may not.
  2041. Upgrading gvfs\-fuse or the distro in general will address the problem.
  2042. .PP
  2043. In Apple\[aq]s MacOSX 10.9 they replaced Samba (client and server) with
  2044. their own product.
  2045. It appears their new client does not handle \f[B]EXDEV\f[] either and
  2046. responds similar to older release of gvfs on Linux.
  2047. .SS Trashing files occasionally fails
  2048. .PP
  2049. This is the same issue as with Samba.
  2050. \f[C]rename\f[] returns \f[C]EXDEV\f[] (in our case that will really
  2051. only happen with path preserving policies like \f[C]epmfs\f[]) and the
  2052. software doesn\[aq]t handle the situation well.
  2053. This is unfortunately a common failure of software which moves files
  2054. around.
  2055. The standard indicates that an implementation \f[C]MAY\f[] choose to
  2056. support non\-user home directory trashing of files (which is a
  2057. \f[C]MUST\f[]).
  2058. The implementation \f[C]MAY\f[] also support "top directory trashes"
  2059. which many probably do.
  2060. .PP
  2061. To create a \f[C]$topdir/.Trash\f[] directory as defined in the standard
  2062. use the mergerfs\-tools (https://github.com/trapexit/mergerfs-tools)
  2063. tool \f[C]mergerfs.mktrash\f[].
  2064. .SS tar: Directory renamed before its status could be extracted
  2065. .PP
  2066. Make sure to use the \f[C]use_ino\f[] option.
  2067. .SS Supplemental user groups
  2068. .PP
  2069. Due to the overhead of
  2070. getgroups/setgroups (http://linux.die.net/man/2/setgroups) mergerfs
  2071. utilizes a cache.
  2072. This cache is opportunistic and per thread.
  2073. Each thread will query the supplemental groups for a user when that
  2074. particular thread needs to change credentials and will keep that data
  2075. for the lifetime of the thread.
  2076. This means that if a user is added to a group it may not be picked up
  2077. without the restart of mergerfs.
  2078. However, since the high level FUSE API\[aq]s (at least the standard
  2079. version) thread pool dynamically grows and shrinks it\[aq]s possible
  2080. that over time a thread will be killed and later a new thread with no
  2081. cache will start and query the new data.
  2082. .PP
  2083. The gid cache uses fixed storage to simplify the design and be
  2084. compatible with older systems which may not have C++11 compilers.
  2085. There is enough storage for 256 users\[aq] supplemental groups.
  2086. Each user is allowed up to 32 supplemental groups.
  2087. Linux >= 2.6.3 allows up to 65535 groups per user but most other *nixs
  2088. allow far less.
  2089. NFS allowing only 16.
  2090. The system does handle overflow gracefully.
  2091. If the user has more than 32 supplemental groups only the first 32 will
  2092. be used.
  2093. If more than 256 users are using the system when an uncached user is
  2094. found it will evict an existing user\[aq]s cache at random.
  2095. So long as there aren\[aq]t more than 256 active users this should be
  2096. fine.
  2097. If either value is too low for your needs you will have to modify
  2098. \f[C]gidcache.hpp\f[] to increase the values.
  2099. Note that doing so will increase the memory needed by each thread.
  2100. .PP
  2101. While not a bug some users have found when using containers that
  2102. supplemental groups defined inside the container don\[aq]t work properly
  2103. with regard to permissions.
  2104. This is expected as mergerfs lives outside the container and therefore
  2105. is querying the host\[aq]s group database.
  2106. There might be a hack to work around this (make mergerfs read the
  2107. /etc/group file in the container) but it is not yet implemented and
  2108. would be limited to Linux and the /etc/group DB.
  2109. Preferably users would mount in the host group file into the containers
  2110. or use a standard shared user & groups technology like NIS or LDAP.
  2111. .SS mergerfs or libfuse crashing
  2112. .PP
  2113. First...
  2114. always upgrade to the latest version unless told otherwise.
  2115. .PP
  2116. If using mergerfs below 2.22.0:
  2117. .PP
  2118. If suddenly the mergerfs mount point disappears and
  2119. \f[C]Transport\ endpoint\ is\ not\ connected\f[] is returned when
  2120. attempting to perform actions within the mount directory \f[B]and\f[]
  2121. the version of libfuse (use \f[C]mergerfs\ \-v\f[] to find the version)
  2122. is older than \f[C]2.9.4\f[] its likely due to a bug in libfuse.
  2123. Affected versions of libfuse can be found in Debian Wheezy, Ubuntu
  2124. Precise and others.
  2125. .PP
  2126. In order to fix this please install newer versions of libfuse.
  2127. If using a Debian based distro (Debian,Ubuntu,Mint) you can likely just
  2128. install newer versions of
  2129. libfuse (https://packages.debian.org/unstable/libfuse2) and
  2130. fuse (https://packages.debian.org/unstable/fuse) from the repo of a
  2131. newer release.
  2132. .PP
  2133. If using mergerfs at or above 2.22.0:
  2134. .PP
  2135. First upgrade if possible, check the known bugs section, and contact
  2136. trapexit.
  2137. .SS mergerfs appears to be crashing or exiting
  2138. .PP
  2139. There seems to be an issue with Linux version \f[C]4.9.0\f[] and above
  2140. in which an invalid message appears to be transmitted to libfuse (used
  2141. by mergerfs) causing it to exit.
  2142. No messages will be printed in any logs as it\[aq]s not a proper crash.
  2143. Debugging of the issue is still ongoing and can be followed via the
  2144. fuse\-devel
  2145. thread (https://sourceforge.net/p/fuse/mailman/message/35662577).
  2146. .SS rm: fts_read failed: No such file or directory
  2147. .PP
  2148. Please update.
  2149. This is only happened to mergerfs versions at or below v2.25.x and will
  2150. not occur in more recent versions.
  2151. .SH FAQ
  2152. .SS How well does mergerfs scale? Is it "production ready?"
  2153. .PP
  2154. Users have reported running mergerfs on everything from a Raspberry Pi
  2155. to dual socket Xeon systems with >20 cores.
  2156. I\[aq]m aware of at least a few companies which use mergerfs in
  2157. production.
  2158. Open Media Vault (https://www.openmediavault.org) includes mergerfs as
  2159. its sole solution for pooling drives.
  2160. The author of mergerfs had it running for over 300 days managing 16+
  2161. drives with reasonably heavy 24/7 read and write usage.
  2162. Stopping only after the machine\[aq]s power supply died.
  2163. .PP
  2164. Most serious issues (crashes or data corruption) have been due to kernel
  2165. bugs (https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs).
  2166. All of which are fixed in stable releases.
  2167. .SS Can mergerfs be used with drives which already have data / are in
  2168. use?
  2169. .PP
  2170. Yes.
  2171. MergerFS is a proxy and does \f[B]NOT\f[] interfere with the normal form
  2172. or function of the drives / mounts / paths it manages.
  2173. .PP
  2174. MergerFS is \f[B]not\f[] a traditional filesystem.
  2175. MergerFS is \f[B]not\f[] RAID.
  2176. It does \f[B]not\f[] manipulate the data that passes through it.
  2177. It does \f[B]not\f[] shard data across drives.
  2178. It merely shards some \f[B]behavior\f[] and aggregates others.
  2179. .SS Can mergerfs be removed without affecting the data?
  2180. .PP
  2181. See the previous question\[aq]s answer.
  2182. .SS What policies should I use?
  2183. .PP
  2184. Unless you\[aq]re doing something more niche the average user is
  2185. probably best off using \f[C]mfs\f[] for \f[C]category.create\f[].
  2186. It will spread files out across your branches based on available space.
  2187. Use \f[C]mspmfs\f[] if you want to try to colocate the data a bit more.
  2188. You may want to use \f[C]lus\f[] if you prefer a slightly different
  2189. distribution of data if you have a mix of smaller and larger drives.
  2190. Generally though \f[C]mfs\f[], \f[C]lus\f[], or even \f[C]rand\f[] are
  2191. good for the general use case.
  2192. If you are starting with an imbalanced pool you can use the tool
  2193. \f[B]mergerfs.balance\f[] to redistribute files across the pool.
  2194. .PP
  2195. If you really wish to try to colocate files based on directory you can
  2196. set \f[C]func.create\f[] to \f[C]epmfs\f[] or similar and
  2197. \f[C]func.mkdir\f[] to \f[C]rand\f[] or \f[C]eprand\f[] depending on if
  2198. you just want to colocate generally or on specific branches.
  2199. Either way the \f[I]need\f[] to colocate is rare.
  2200. For instance: if you wish to remove the drive regularly and want the
  2201. data to predictably be on that drive or if you don\[aq]t use backup at
  2202. all and don\[aq]t wish to replace that data piecemeal.
  2203. In which case using path preservation can help but will require some
  2204. manual attention.
  2205. Colocating after the fact can be accomplished using the
  2206. \f[B]mergerfs.consolidate\f[] tool.
  2207. If you don\[aq]t need strict colocation which the \f[C]ep\f[] policies
  2208. provide then you can use the \f[C]msp\f[] based policies which will walk
  2209. back the path till finding a branch that works.
  2210. .PP
  2211. Ultimately there is no correct answer.
  2212. It is a preference or based on some particular need.
  2213. mergerfs is very easy to test and experiment with.
  2214. I suggest creating a test setup and experimenting to get a sense of what
  2215. you want.
  2216. .PP
  2217. The reason \f[C]mfs\f[] is not the default \f[C]category.create\f[]
  2218. policy is historical.
  2219. When/if a 3.X gets released it will be changed to minimize confusion
  2220. people often have with path preserving policies.
  2221. .SS What settings should I use?
  2222. .PP
  2223. Depends on what features you want.
  2224. Generally speaking there are no "wrong" settings.
  2225. All settings are performance or feature related.
  2226. The best bet is to read over the available options and choose what fits
  2227. your situation.
  2228. If something isn\[aq]t clear from the documentation please reach out and
  2229. the documentation will be improved.
  2230. .PP
  2231. That said, for the average person, the following should be fine:
  2232. .PP
  2233. \f[C]\-o\ use_ino,cache.files=off,dropcacheonclose=true,allow_other,category.create=mfs\f[]
  2234. .SS Why are all my files ending up on 1 drive?!
  2235. .PP
  2236. Did you start with empty drives?
  2237. Did you explicitly configure a \f[C]category.create\f[] policy?
  2238. Are you using an \f[C]existing\ path\f[] / \f[C]path\ preserving\f[]
  2239. policy?
  2240. .PP
  2241. The default create policy is \f[C]epmfs\f[].
  2242. That is a path preserving algorithm.
  2243. With such a policy for \f[C]mkdir\f[] and \f[C]create\f[] with a set of
  2244. empty drives it will select only 1 drive when the first directory is
  2245. created.
  2246. Anything, files or directories, created in that first directory will be
  2247. placed on the same branch because it is preserving paths.
  2248. .PP
  2249. This catches a lot of new users off guard but changing the default would
  2250. break the setup for many existing users.
  2251. If you do not care about path preservation and wish your files to be
  2252. spread across all your drives change to \f[C]mfs\f[] or similar policy
  2253. as described above.
  2254. If you do want path preservation you\[aq]ll need to perform the manual
  2255. act of creating paths on the drives you want the data to land on before
  2256. transferring your data.
  2257. Setting \f[C]func.mkdir=epall\f[] can simplify managing path
  2258. preservation for \f[C]create\f[].
  2259. Or use \f[C]func.mkdir=rand\f[] if you\[aq]re interested in just
  2260. grouping together directory content by drive.
  2261. .SS Do hard links work?
  2262. .PP
  2263. Yes.
  2264. You need to use \f[C]use_ino\f[] to support proper reporting of inodes
  2265. but they work regardless.
  2266. See also the option \f[C]inodecalc\f[].
  2267. .PP
  2268. What mergerfs does not do is fake hard links across branches.
  2269. Read the section "rename & link" for how it works.
  2270. .SS Does mergerfs support CoW / copy\-on\-write?
  2271. .PP
  2272. Not in the sense of a filesystem like BTRFS or ZFS nor in the overlayfs
  2273. or aufs sense.
  2274. It does offer a
  2275. cow\-shell (http://manpages.ubuntu.com/manpages/bionic/man1/cow-shell.1.html)
  2276. like hard link breaking (copy to temp file then rename over original)
  2277. which can be useful when wanting to save space by hardlinking duplicate
  2278. files but wish to treat each name as if it were a unique and separate
  2279. file.
  2280. .SS Why can\[aq]t I see my files / directories?
  2281. .PP
  2282. It\[aq]s almost always a permissions issue.
  2283. Unlike mhddfs and unionfs\-fuse, which runs as root and attempts to
  2284. access content as such, mergerfs always changes its credentials to that
  2285. of the caller.
  2286. This means that if the user does not have access to a file or directory
  2287. than neither will mergerfs.
  2288. However, because mergerfs is creating a union of paths it may be able to
  2289. read some files and directories on one drive but not another resulting
  2290. in an incomplete set.
  2291. .PP
  2292. Whenever you run into a split permission issue (seeing some but not all
  2293. files) try using
  2294. mergerfs.fsck (https://github.com/trapexit/mergerfs-tools) tool to check
  2295. for and fix the mismatch.
  2296. If you aren\[aq]t seeing anything at all be sure that the basic
  2297. permissions are correct.
  2298. The user and group values are correct and that directories have their
  2299. executable bit set.
  2300. A common mistake by users new to Linux is to \f[C]chmod\ \-R\ 644\f[]
  2301. when they should have \f[C]chmod\ \-R\ u=rwX,go=rX\f[].
  2302. .PP
  2303. If using a network filesystem such as NFS, SMB, CIFS (Samba) be sure to
  2304. pay close attention to anything regarding permissioning and users.
  2305. Root squashing and user translation for instance has bitten a few
  2306. mergerfs users.
  2307. Some of these also affect the use of mergerfs from container platforms
  2308. such as Docker.
  2309. .SS Is my OS\[aq]s libfuse needed for mergerfs to work?
  2310. .PP
  2311. No.
  2312. Normally \f[C]mount.fuse\f[] is needed to get mergerfs (or any FUSE
  2313. filesystem to mount using the \f[C]mount\f[] command but in vendoring
  2314. the libfuse library the \f[C]mount.fuse\f[] app has been renamed to
  2315. \f[C]mount.mergerfs\f[] meaning the filesystem type in \f[C]fstab\f[]
  2316. can simply be \f[C]mergerfs\f[].
  2317. That said there should be no harm in having it installed and continuing
  2318. to using \f[C]fuse.mergerfs\f[] as the type in \f[C]/etc/fstab\f[].
  2319. .PP
  2320. If \f[C]mergerfs\f[] doesn\[aq]t work as a type it could be due to how
  2321. the \f[C]mount.mergerfs\f[] tool was installed.
  2322. Must be in \f[C]/sbin/\f[] with proper permissions.
  2323. .SS Why was libfuse embedded into mergerfs?
  2324. .IP "1." 3
  2325. A significant number of users use mergerfs on distros with old versions
  2326. of libfuse which have serious bugs.
  2327. Requiring updated versions of libfuse on those distros isn\[aq]t
  2328. practical (no package offered, user inexperience, etc.).
  2329. The only practical way to provide a stable runtime on those systems was
  2330. to "vendor" / embed the library into the project.
  2331. .IP "2." 3
  2332. mergerfs was written to use the high level API.
  2333. There are a number of limitations in the HLAPI that make certain
  2334. features difficult or impossible to implement.
  2335. While some of these features could be patched into newer versions of
  2336. libfuse without breaking the public API some of them would require hacky
  2337. code to provide backwards compatibility.
  2338. While it may still be worth working with upstream to address these
  2339. issues in future versions, since the library needs to be vendored for
  2340. stability and compatibility reasons it is preferable / easier to modify
  2341. the API.
  2342. Longer term the plan is to rewrite mergerfs to use the low level API.
  2343. .SS Why did support for system libfuse get removed?
  2344. .PP
  2345. See above first.
  2346. .PP
  2347. If/when mergerfs is rewritten to use the low\-level API then it\[aq]ll
  2348. be plausible to support system libfuse but till then its simply too much
  2349. work to manage the differences across the versions.
  2350. .SS Why use mergerfs over mhddfs?
  2351. .PP
  2352. mhddfs is no longer maintained and has some known stability and security
  2353. issues (see below).
  2354. MergerFS provides a superset of mhddfs\[aq] features and should offer
  2355. the same or maybe better performance.
  2356. .PP
  2357. Below is an example of mhddfs and mergerfs setup to work similarly.
  2358. .PP
  2359. \f[C]mhddfs\ \-o\ mlimit=4G,allow_other\ /mnt/drive1,/mnt/drive2\ /mnt/pool\f[]
  2360. .PP
  2361. \f[C]mergerfs\ \-o\ minfreespace=4G,allow_other,category.create=ff\ /mnt/drive1:/mnt/drive2\ /mnt/pool\f[]
  2362. .SS Why use mergerfs over aufs?
  2363. .PP
  2364. aufs is mostly abandoned and no longer available in many distros.
  2365. .PP
  2366. While aufs can offer better peak performance mergerfs provides more
  2367. configurability and is generally easier to use.
  2368. mergerfs however does not offer the overlay / copy\-on\-write (CoW)
  2369. features which aufs and overlayfs have.
  2370. .SS Why use mergerfs over unionfs?
  2371. .PP
  2372. UnionFS is more like aufs than mergerfs in that it offers overlay / CoW
  2373. features.
  2374. If you\[aq]re just looking to create a union of drives and want
  2375. flexibility in file/directory placement then mergerfs offers that
  2376. whereas unionfs is more for overlaying RW filesystems over RO ones.
  2377. .SS Why use mergerfs over overlayfs?
  2378. .PP
  2379. Same reasons as with unionfs.
  2380. .SS Why use mergerfs over LVM/ZFS/BTRFS/RAID0 drive concatenation /
  2381. striping?
  2382. .PP
  2383. With simple JBOD / drive concatenation / stripping / RAID0 a single
  2384. drive failure will result in full pool failure.
  2385. mergerfs performs a similar function without the possibility of
  2386. catastrophic failure and the difficulties in recovery.
  2387. Drives may fail, however, all other data will continue to be accessible.
  2388. .PP
  2389. When combined with something like SnapRaid (http://www.snapraid.it)
  2390. and/or an offsite backup solution you can have the flexibility of JBOD
  2391. without the single point of failure.
  2392. .SS Why use mergerfs over ZFS?
  2393. .PP
  2394. MergerFS is not intended to be a replacement for ZFS.
  2395. MergerFS is intended to provide flexible pooling of arbitrary drives
  2396. (local or remote), of arbitrary sizes, and arbitrary filesystems.
  2397. For \f[C]write\ once,\ read\ many\f[] usecases such as bulk media
  2398. storage.
  2399. Where data integrity and backup is managed in other ways.
  2400. In that situation ZFS can introduce a number of costs and limitations as
  2401. described
  2402. here (http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html),
  2403. here (https://markmcb.com/2020/01/07/five-years-of-btrfs/), and
  2404. here (https://utcc.utoronto.ca/~cks/space/blog/solaris/ZFSWhyNoRealReshaping).
  2405. .SS Why use mergerfs over UnRAID?
  2406. .PP
  2407. UnRAID is a full OS and its storage layer, as I understand, is
  2408. proprietary and closed source.
  2409. Users who have experience with both have said they prefer the
  2410. flexibility offered by mergerfs and for some the fact it is free and
  2411. open source is important.
  2412. .PP
  2413. There are a number of UnRAID users who use mergerfs as well though
  2414. I\[aq]m not entirely familiar with the use case.
  2415. .SS What should mergerfs NOT be used for?
  2416. .IP \[bu] 2
  2417. databases: Even if the database stored data in separate files (mergerfs
  2418. wouldn\[aq]t offer much otherwise) the higher latency of the indirection
  2419. will kill performance.
  2420. If it is a lightly used SQLITE database then it may be fine but
  2421. you\[aq]ll need to test.
  2422. .IP \[bu] 2
  2423. VM images: For the same reasons as databases.
  2424. VM images are accessed very aggressively and mergerfs will introduce too
  2425. much latency (if it works at all).
  2426. .IP \[bu] 2
  2427. As replacement for RAID: mergerfs is just for pooling branches.
  2428. If you need that kind of device performance aggregation or high
  2429. availability you should stick with RAID.
  2430. .SS Can drives be written to directly? Outside of mergerfs while pooled?
  2431. .PP
  2432. Yes, however it\[aq]s not recommended to use the same file from within
  2433. the pool and from without at the same time (particularly writing).
  2434. Especially if using caching of any kind (cache.files, cache.entry,
  2435. cache.attr, cache.negative_entry, cache.symlinks, cache.readdir, etc.)
  2436. as there could be a conflict between cached data and not.
  2437. .SS Why do I get an "out of space" / "no space left on device" / ENOSPC
  2438. error even though there appears to be lots of space available?
  2439. .PP
  2440. First make sure you\[aq]ve read the sections above about policies, path
  2441. preservation, branch filtering, and the options \f[B]minfreespace\f[],
  2442. \f[B]moveonenospc\f[], \f[B]statfs\f[], and \f[B]statfs_ignore\f[].
  2443. .PP
  2444. mergerfs is simply presenting a union of the content within multiple
  2445. branches.
  2446. The reported free space is an aggregate of space available within the
  2447. pool (behavior modified by \f[B]statfs\f[] and \f[B]statfs_ignore\f[]).
  2448. It does not represent a contiguous space.
  2449. In the same way that read\-only filesystems, those with quotas, or
  2450. reserved space report the full theoretical space available.
  2451. .PP
  2452. Due to path preservation, branch tagging, read\-only status, and
  2453. \f[B]minfreespace\f[] settings it is perfectly valid that
  2454. \f[C]ENOSPC\f[] / "out of space" / "no space left on device" be
  2455. returned.
  2456. It is doing what was asked of it: filtering possible branches due to
  2457. those settings.
  2458. Only one error can be returned and if one of the reasons for filtering a
  2459. branch was \f[B]minfreespace\f[] then it will be returned as such.
  2460. \f[B]moveonenospc\f[] is only relevant to writing a file which is too
  2461. large for the drive its currently on.
  2462. .PP
  2463. It is also possible that the filesystem selected has run out of inodes.
  2464. Use \f[C]df\ \-i\f[] to list the total and available inodes per
  2465. filesystem.
  2466. .PP
  2467. If you don\[aq]t care about path preservation then simply change the
  2468. \f[C]create\f[] policy to one which isn\[aq]t.
  2469. \f[C]mfs\f[] is probably what most are looking for.
  2470. The reason it\[aq]s not default is because it was originally set to
  2471. \f[C]epmfs\f[] and changing it now would change people\[aq]s setup.
  2472. Such a setting change will likely occur in mergerfs 3.
  2473. .SS Why does the total available space in mergerfs not equal outside?
  2474. .PP
  2475. Are you using ext2/3/4?
  2476. With reserve for root?
  2477. mergerfs uses available space for statfs calculations.
  2478. If you\[aq]ve reserved space for root then it won\[aq]t show up.
  2479. .PP
  2480. You can remove the reserve by running:
  2481. \f[C]tune2fs\ \-m\ 0\ <device>\f[]
  2482. .SS Can mergerfs mounts be exported over NFS?
  2483. .PP
  2484. Yes, however if you do anything which may changes files out of band
  2485. (including for example using the \f[C]newest\f[] policy) it will result
  2486. in "stale file handle" errors unless properly setup.
  2487. .PP
  2488. Be sure to use the following options:
  2489. .IP \[bu] 2
  2490. noforget
  2491. .IP \[bu] 2
  2492. use_ino
  2493. .IP \[bu] 2
  2494. inodecalc=path\-hash
  2495. .SS Can mergerfs mounts be exported over Samba / SMB?
  2496. .PP
  2497. Yes.
  2498. While some users have reported problems it appears to always be related
  2499. to how Samba is setup in relation to permissions.
  2500. .SS Can mergerfs mounts be used over SSHFS?
  2501. .PP
  2502. Yes.
  2503. .SS I notice massive slowdowns of writes when enabling cache.files.
  2504. .PP
  2505. When file caching is enabled in any form (\f[C]cache.files!=off\f[] or
  2506. \f[C]direct_io=false\f[]) it will issue \f[C]getxattr\f[] requests for
  2507. \f[C]security.capability\f[] prior to \f[I]every single write\f[].
  2508. This will usually result in a performance degradation, especially when
  2509. using a network filesystem (such as NFS or CIFS/SMB/Samba.)
  2510. Unfortunately at this moment the kernel is not caching the response.
  2511. .PP
  2512. To work around this situation mergerfs offers a few solutions.
  2513. .IP "1." 3
  2514. Set \f[C]security_capability=false\f[].
  2515. It will short circuit any call and return \f[C]ENOATTR\f[].
  2516. This still means though that mergerfs will receive the request before
  2517. every write but at least it doesn\[aq]t get passed through to the
  2518. underlying filesystem.
  2519. .IP "2." 3
  2520. Set \f[C]xattr=noattr\f[].
  2521. Same as above but applies to \f[I]all\f[] calls to getxattr.
  2522. Not just \f[C]security.capability\f[].
  2523. This will not be cached by the kernel either but mergerfs\[aq] runtime
  2524. config system will still function.
  2525. .IP "3." 3
  2526. Set \f[C]xattr=nosys\f[].
  2527. Results in mergerfs returning \f[C]ENOSYS\f[] which \f[I]will\f[] be
  2528. cached by the kernel.
  2529. No future xattr calls will be forwarded to mergerfs.
  2530. The downside is that also means the xattr based config and query
  2531. functionality won\[aq]t work either.
  2532. .IP "4." 3
  2533. Disable file caching.
  2534. If you aren\[aq]t using applications which use \f[C]mmap\f[] it\[aq]s
  2535. probably simpler to just disable it all together.
  2536. The kernel won\[aq]t send the requests when caching is disabled.
  2537. .SS What are these .fuse_hidden files?
  2538. .PP
  2539. Please upgrade.
  2540. mergerfs >= 2.26.0 will not have these temporary files.
  2541. See the notes on \f[C]unlink\f[].
  2542. .SS It\[aq]s mentioned that there are some security issues with mhddfs.
  2543. What are they? How does mergerfs address them?
  2544. .PP
  2545. mhddfs (https://github.com/trapexit/mhddfs) manages running as
  2546. \f[B]root\f[] by calling
  2547. getuid() (https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  2548. and if it returns \f[B]0\f[] then it will
  2549. chown (http://linux.die.net/man/1/chown) the file.
  2550. Not only is that a race condition but it doesn\[aq]t handle other
  2551. situations.
  2552. Rather than attempting to simulate POSIX ACL behavior the proper way to
  2553. manage this is to use seteuid (http://linux.die.net/man/2/seteuid) and
  2554. setegid (http://linux.die.net/man/2/setegid), in effect becoming the
  2555. user making the original call, and perform the action as them.
  2556. This is what mergerfs does and why mergerfs should always run as root.
  2557. .PP
  2558. In Linux setreuid syscalls apply only to the thread.
  2559. GLIBC hides this away by using realtime signals to inform all threads to
  2560. change credentials.
  2561. Taking after \f[B]Samba\f[], mergerfs uses
  2562. \f[B]syscall(SYS_setreuid,...)\f[] to set the callers credentials for
  2563. that thread only.
  2564. Jumping back to \f[B]root\f[] as necessary should escalated privileges
  2565. be needed (for instance: to clone paths between drives).
  2566. .PP
  2567. For non\-Linux systems mergerfs uses a read\-write lock and changes
  2568. credentials only when necessary.
  2569. If multiple threads are to be user X then only the first one will need
  2570. to change the processes credentials.
  2571. So long as the other threads need to be user X they will take a readlock
  2572. allowing multiple threads to share the credentials.
  2573. Once a request comes in to run as user Y that thread will attempt a
  2574. write lock and change to Y\[aq]s credentials when it can.
  2575. If the ability to give writers priority is supported then that flag will
  2576. be used so threads trying to change credentials don\[aq]t starve.
  2577. This isn\[aq]t the best solution but should work reasonably well
  2578. assuming there are few users.
  2579. .SH SUPPORT
  2580. .PP
  2581. Filesystems are complex and difficult to debug.
  2582. mergerfs, while being just a proxy of sorts, is also very difficult to
  2583. debug given the large number of possible settings it can have itself and
  2584. the massive number of environments it can run in.
  2585. When reporting on a suspected issue \f[B]please, please\f[] include as
  2586. much of the below information as possible otherwise it will be difficult
  2587. or impossible to diagnose.
  2588. Also please make sure to read all of the above documentation as it
  2589. includes nearly every known system or user issue previously encountered.
  2590. .PP
  2591. \f[B]Please make sure you are using the latest
  2592. release (https://github.com/trapexit/mergerfs/releases) or have tried it
  2593. in comparison. Old versions, which are often included in distros like
  2594. Debian and Ubuntu, are not ever going to be updated and your bug may
  2595. have been addressed already.\f[]
  2596. .SS Information to include in bug reports
  2597. .IP \[bu] 2
  2598. Version of mergerfs: \f[C]mergerfs\ \-V\f[]
  2599. .IP \[bu] 2
  2600. mergerfs settings: from \f[C]/etc/fstab\f[] or command line execution
  2601. .IP \[bu] 2
  2602. Version of Linux: \f[C]uname\ \-a\f[]
  2603. .IP \[bu] 2
  2604. Versions of any additional software being used
  2605. .IP \[bu] 2
  2606. List of drives, their filesystems, and sizes (before and after issue):
  2607. \f[C]df\ \-h\f[]
  2608. .IP \[bu] 2
  2609. \f[B]All\f[] information about the relevant branches and paths:
  2610. permissions, etc.
  2611. .IP \[bu] 2
  2612. A \f[C]strace\f[] of the app having problems:
  2613. .IP \[bu] 2
  2614. \f[C]strace\ \-f\ \-o\ /tmp/app.strace.txt\ <cmd>\f[]
  2615. .IP \[bu] 2
  2616. A \f[C]strace\f[] of mergerfs while the program is trying to do whatever
  2617. it\[aq]s failing to do:
  2618. .IP \[bu] 2
  2619. \f[C]strace\ \-f\ \-p\ <mergerfsPID>\ \-o\ /tmp/mergerfs.strace.txt\f[]
  2620. .IP \[bu] 2
  2621. \f[B]Precise\f[] directions on replicating the issue.
  2622. Do not leave \f[B]anything\f[] out.
  2623. .IP \[bu] 2
  2624. Try to recreate the problem in the simplest way using standard programs.
  2625. .SS Contact / Issue submission
  2626. .IP \[bu] 2
  2627. github.com: https://github.com/trapexit/mergerfs/issues
  2628. .IP \[bu] 2
  2629. email: trapexit\@spawn.link
  2630. .IP \[bu] 2
  2631. twitter: https://twitter.com/_trapexit
  2632. .IP \[bu] 2
  2633. reddit: https://www.reddit.com/user/trapexit
  2634. .IP \[bu] 2
  2635. discord: https://discord.gg/MpAr69V
  2636. .SS Support development
  2637. .PP
  2638. This software is free to use and released under a very liberal license
  2639. (ISC).
  2640. That said if you like this software and would like to support its
  2641. development donations are welcome.
  2642. .PP
  2643. At the moment my preference would be GitHub Sponsors only because I am
  2644. part of the matching program.
  2645. That said please use whatever platform you prefer.
  2646. .IP \[bu] 2
  2647. PayPal: https://paypal.me/trapexit
  2648. .IP \[bu] 2
  2649. GitHub Sponsors: https://github.com/sponsors/trapexit
  2650. .IP \[bu] 2
  2651. Patreon: https://www.patreon.com/trapexit
  2652. .IP \[bu] 2
  2653. SubscribeStar: https://www.subscribestar.com/trapexit
  2654. .IP \[bu] 2
  2655. Ko\-Fi: https://ko\-fi.com/trapexit
  2656. .IP \[bu] 2
  2657. Open Collective: https://opencollective.com/trapexit
  2658. .IP \[bu] 2
  2659. Bitcoin (BTC): 1DfoUd2m5WCxJAMvcFuvDpT4DR2gWX2PWb
  2660. .IP \[bu] 2
  2661. Bitcoin Cash (BCH): qrf257j0l09yxty4kur8dk2uma8p5vntdcpks72l8z
  2662. .IP \[bu] 2
  2663. Ethereum (ETH): 0xb486C0270fF75872Fc51d85879b9c15C380E66CA
  2664. .IP \[bu] 2
  2665. Litecoin (LTC): LW1rvHRPWtm2NUEMhJpP4DjHZY1FaJ1WYs
  2666. .IP \[bu] 2
  2667. Monero (XMR):
  2668. 8AuU7PeK1fVhGP9yug8fdgKBssvUQoBVFKGhtT5DzWQt7fcTKC1SUx3Eb7xCAiVt3McWJp2Z9gX2wU7SPhh1GfWYBTCs6SS
  2669. .IP \[bu] 2
  2670. Basic Attention Token (BAT): 0xE651d4900B4C305284Da43E2e182e9abE149A87A
  2671. .IP \[bu] 2
  2672. LBRY Credits (LBC): bFusyoZPkSuzM2Pr8mcthgvkymaosJZt5r
  2673. .IP \[bu] 2
  2674. Zcash (ZEC): t1ZwTgmbQF23DJrzqbAmw8kXWvU2xUkkhTt
  2675. .IP \[bu] 2
  2676. Zcoin (XZC): a8L5Vz35KdCQe7Y7urK2pcCGau7JsqZ5Gw
  2677. .IP \[bu] 2
  2678. Other crypto currencies: contact me for address
  2679. .SH LINKS
  2680. .IP \[bu] 2
  2681. https://spawn.link
  2682. .IP \[bu] 2
  2683. https://github.com/trapexit/mergerfs
  2684. .IP \[bu] 2
  2685. https://github.com/trapexit/mergerfs/wiki
  2686. .IP \[bu] 2
  2687. https://github.com/trapexit/mergerfs\-tools
  2688. .IP \[bu] 2
  2689. https://github.com/trapexit/scorch
  2690. .IP \[bu] 2
  2691. https://github.com/trapexit/bbf
  2692. .IP \[bu] 2
  2693. https://github.com/trapexit/backup\-and\-recovery\-howtos
  2694. .SH AUTHORS
  2695. Antonio SJ Musumeci <trapexit@spawn.link>.