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.

2609 lines
100 KiB

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