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.

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