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.

2926 lines
109 KiB

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