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.

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