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.

2747 lines
102 KiB

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