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.

2885 lines
107 KiB

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