mirror of https://github.com/trapexit/mergerfs.git
Antonio SJ Musumeci
2 weeks ago
69 changed files with 2000 additions and 1565 deletions
-
11mkdocs/README.md
-
2mkdocs/docs/benchmarking.md
-
54mkdocs/docs/config/branches.md
-
187mkdocs/docs/config/cache.md
-
21mkdocs/docs/config/deprecated_options.md
-
14mkdocs/docs/config/export-support.md
-
21mkdocs/docs/config/flush-on-close.md
-
23mkdocs/docs/config/follow-symlinks.md
-
17mkdocs/docs/config/func_readdir.md
-
152mkdocs/docs/config/functions_categories_and_policies.md
-
29mkdocs/docs/config/fuse_msg_size.md
-
75mkdocs/docs/config/inodecalc.md
-
17mkdocs/docs/config/link-exdev.md
-
13mkdocs/docs/config/link_cow.md
-
26mkdocs/docs/config/nfsopenhack.md
-
20mkdocs/docs/config/nullrw.md
-
91mkdocs/docs/config/options.md
-
23mkdocs/docs/config/pin-threads.md
-
38mkdocs/docs/config/readahead.md
-
21mkdocs/docs/config/rename-exdev.md
-
59mkdocs/docs/config/rename_and_link.md
-
26mkdocs/docs/config/statfs.md
-
23mkdocs/docs/config/symlinkify.md
-
12mkdocs/docs/config/terminology.md
-
53mkdocs/docs/config/threads.md
-
27mkdocs/docs/config/xattr.md
-
2mkdocs/docs/error_handling.md
-
33mkdocs/docs/faq/compatibility_and_integration.md
-
31mkdocs/docs/faq/configuration_and_policies.md
-
5mkdocs/docs/faq/limit_drive_spinup.md
-
23mkdocs/docs/faq/recommendations_and_warnings.md
-
31mkdocs/docs/faq/reliability_and_scalability.md
-
47mkdocs/docs/faq/technical_behavior_and_limitations.md
-
35mkdocs/docs/faq/usage_and_functionality.md
-
90mkdocs/docs/index.md
-
271mkdocs/docs/known_issues_bugs.md
-
2mkdocs/docs/media_and_publicity.md
-
54mkdocs/docs/pages/documentation/basic_setup.md
-
213mkdocs/docs/pages/documentation/caching.md
-
35mkdocs/docs/pages/documentation/how_it_works.md
-
195mkdocs/docs/pages/documentation/known_issues_bugs.md
-
8mkdocs/docs/pages/documentation/links.md
-
39mkdocs/docs/pages/documentation/performance.md
-
65mkdocs/docs/pages/documentation/support.md
-
9mkdocs/docs/pages/documentation/terminology.md
-
43mkdocs/docs/pages/documentation/tips_notes.md
-
64mkdocs/docs/pages/faq/general_information_and_overview.md
-
148mkdocs/docs/pages/wiki/installing_mergerfs_on_a_synology_nas.md
-
45mkdocs/docs/pages/wiki/kernel_issues_and_bugs.md
-
4mkdocs/docs/pages/wiki/links.md
-
34mkdocs/docs/pages/wiki/projects_using_mergerfs.md
-
96mkdocs/docs/pages/wiki/real_world_deployments.md
-
60mkdocs/docs/pages/wiki/systemd.md
-
4mkdocs/docs/pages/wiki/testimonials.md
-
43mkdocs/docs/performance.md
-
100mkdocs/docs/project_comparisons.md
-
189mkdocs/docs/quickstart.md
-
56mkdocs/docs/related_projects.md
-
39mkdocs/docs/remote_filesystems.md
-
23mkdocs/docs/runtime_interfaces.md
-
32mkdocs/docs/setup/build.md
-
62mkdocs/docs/setup/installation.md
-
2mkdocs/docs/setup/upgrade.md
-
17mkdocs/docs/sponsorship_and_donations.md
-
45mkdocs/docs/support.md
-
43mkdocs/docs/tips_notes.md
-
42mkdocs/docs/tooling.md
-
129mkdocs/mkdocs.yml
-
2mkdocs/requirements.txt
@ -1,4 +1,4 @@ |
|||
# BENCHMARKING |
|||
# Benchmarking |
|||
|
|||
Filesystems are complicated. They do many things and many of those are |
|||
interconnected. Additionally, the OS, drivers, hardware, etc. can all |
@ -0,0 +1,54 @@ |
|||
# branches |
|||
|
|||
The 'branches' argument is a colon (':') delimited list of paths to be |
|||
pooled together. It does not matter if the paths are on the same or |
|||
different filesystems nor does it matter the filesystem type (within |
|||
reason). Used and available space will not be duplicated for paths on |
|||
the same filesystem and any features which aren't supported by the |
|||
underlying filesystem (such as file attributes or extended attributes) |
|||
will return the appropriate errors. |
|||
|
|||
Branches currently have two options which can be set. A type which |
|||
impacts whether or not the branch is included in a policy calculation |
|||
and a individual minfreespace value. The values are set by prepending |
|||
an `=` at the end of a branch designation and using commas as |
|||
delimiters. Example: `/mnt/drive=RW,1234` |
|||
|
|||
### branch mode |
|||
|
|||
- RW: (read/write) - Default behavior. Will be eligible in all policy |
|||
categories. |
|||
- RO: (read-only) - Will be excluded from `create` and `action` |
|||
policies. Same as a read-only mounted filesystem would be (though |
|||
faster to process). |
|||
- NC: (no-create) - Will be excluded from `create` policies. You can't |
|||
create on that branch but you can change or delete. |
|||
|
|||
### minfreespace |
|||
|
|||
Same purpose and syntax as the global option but specific to the |
|||
branch. If not set the global value is used. |
|||
|
|||
### globbing |
|||
|
|||
To make it easier to include multiple branches mergerfs supports |
|||
[globbing](http://linux.die.net/man/7/glob). **The globbing tokens |
|||
MUST be escaped when using via the shell else the shell itself will |
|||
apply the glob itself.** |
|||
|
|||
``` |
|||
# mergerfs /mnt/hdd\*:/mnt/ssd /media |
|||
``` |
|||
|
|||
The above line will use all mount points in /mnt prefixed with **hdd** |
|||
and **ssd**. |
|||
|
|||
To have the pool mounted at boot or otherwise accessible from related |
|||
tools use `/etc/fstab`. |
|||
|
|||
``` |
|||
# <file system> <mount point> <type> <options> <dump> <pass> |
|||
/mnt/hdd*:/mnt/ssd /media mergerfs minfreespace=16G 0 0 |
|||
``` |
|||
|
|||
**NOTE:** The globbing is done at mount or when updated using the runtime API. If a new directory is added matching the glob after the fact it will not be automatically included. |
@ -0,0 +1,187 @@ |
|||
# caching |
|||
|
|||
## cache.files |
|||
|
|||
Controls how [page caching](https://en.wikipedia.org/wiki/Page_cache) |
|||
works for mergerfs itself. Not the underlying filesystems. |
|||
|
|||
* `cache.files=off`: Disables page caching for mergerfs. |
|||
* `cache.files=partial`: Enables page caching. Files are cached |
|||
while open. |
|||
* `cache.files=full`: Enables page caching. Files are cached across |
|||
opens. |
|||
* `cache.files=auto-full`: Enables page caching. Files are cached |
|||
across opens if mtime and size are unchanged since previous open. |
|||
* `cache.files=per-process`: Enable page caching (equivalent to |
|||
`cache.files=partial`) only for processes whose 'comm' name matches |
|||
one of the values defined in cache.files.process-names. If the name |
|||
does not match the file open is equivalent to `cache.files=off`. |
|||
|
|||
|
|||
Generally, enabling the page cache actually *harms* |
|||
performance[^1]. In part because it can lead to buffer bloat due to |
|||
the kernel caching both the underlying filesystem's file content as |
|||
well as the file through mergerfs. However, if you want to confirm |
|||
performance differences it is recommended that you perform some |
|||
benchmark to confirm which option works best for your setup. |
|||
|
|||
Why then would you want to enable page caching if it consumes ~2x the |
|||
RAM as normal and is on average slower? Because it is the only way to |
|||
support |
|||
[mmap](https://man7.org/linux/man-pages/man2/mmap.2.html). `mmap` is a |
|||
way for programs to treat a file as if it is a contiguous RAM buffer |
|||
which is regularly used by a number of programs such as those that |
|||
leverage **sqlite3**. Despite `mmap` not being supported by all |
|||
filesystems it is unfortunately common for software to not have an |
|||
option to use regular file IO instead of `mmap`. |
|||
|
|||
The good thing is that in Linux v6.6[^2] and above FUSE can now |
|||
transparently enable page caching when mmap is requested. This means |
|||
it should be safe to set `cache.files=off`. However, on Linux v6.5 and |
|||
below you will need to configure `cache.files` as you need. |
|||
|
|||
|
|||
[^1]: This is not unique to mergerfs and affects all FUSE |
|||
filesystems. It is something that the FUSE community hopes to |
|||
investigate at some point but as of early 2025 there are a number |
|||
of major reworking going on with FUSE which needs to be finished |
|||
first. |
|||
[^2]: [https://kernelnewbies.org/Linux_6.6#FUSE](https://kernelnewbies.org/Linux_6.6#FUSE) |
|||
|
|||
|
|||
## cache.entry |
|||
|
|||
* `cache.entry=UINT`: Sets the number of seconds to cache |
|||
entry queries. Defaults to `1`. |
|||
|
|||
The kernel must ask mergerfs about the existence of files. The entry |
|||
cache caches that those details which limits the number of requests |
|||
sent to mergerfs. |
|||
|
|||
The risk of setting this value, as with most any cache, is related to |
|||
[out-of-band](https://en.wikipedia.org/wiki/Out-of-band) changes. If |
|||
the filesystems are changed outside mergerfs there is a risk of files |
|||
which have been removed continuing to show as available. It will fail |
|||
gracefully if a phantom file is actioned on in some way so there is |
|||
little risk in setting the value much higher. Especially if there are |
|||
no out-of-band changes. |
|||
|
|||
|
|||
## cache.negative_entry |
|||
|
|||
* `cache.negative_entry=UINT`: Sets the number of seconds to cache |
|||
negative entry queries. Defaults to `1`. |
|||
|
|||
This is a cache for negative entry query responses. Such as when a |
|||
file which does not exist is referenced. |
|||
|
|||
The risk of setting this value, as with most any cache, is related to |
|||
[out-of-band](https://en.wikipedia.org/wiki/Out-of-band) changes. If |
|||
the filesystems are changed outside mergerfs there is a risk of files |
|||
which have been added outside mergerfs not appearing correctly till |
|||
the cache entry times out if there had been a request for the same |
|||
name within mergerfs which didn't exist. This is mostly an |
|||
inconvenience. |
|||
|
|||
|
|||
## cache.attr |
|||
|
|||
* `cache.attr=UINT`: Sets the number of seconds to cache file |
|||
attributes. Defaults to `1`. |
|||
|
|||
This is a cache for file attributes and metadata such as that which is |
|||
collected by the |
|||
[stat](https://man7.org/linux/man-pages/man2/stat.2.html) system call |
|||
which is used when you run commands such as `find` or `ls -lh`. |
|||
|
|||
As with other caches the risk of enabling the attribute cache is if |
|||
changes are made to the file out-of-band there could be |
|||
inconsistencies between the actual file and the cached details which |
|||
could result in different issues depending on how the data is used. If |
|||
the simultaneous writing of a file from inside and outside is unlikely |
|||
then you should be safe. That said any simultaneous, uncoordinated |
|||
manipulation of a file can lead to unexpected results. |
|||
|
|||
|
|||
## cache.statfs |
|||
|
|||
* `cache.statfs=UINT`: Sets the number of seconds to cache `statfs` |
|||
calls used by policies. Defaults to `0`. |
|||
|
|||
A number of policies require looking up the available space of the |
|||
branches being considered. This is accomplished by calling |
|||
[statfs](https://man7.org/linux/man-pages/man2/statfs.2.html). This |
|||
call however is a bit expensive so this cache reduces the overhead by |
|||
limiting how often the calls are actually made. |
|||
|
|||
This will mean that if the available space of branches changed |
|||
somewhat rapidly there is a risk of `create` or `mkdir` calls made |
|||
within the timeout period ending up on the same branch. This however |
|||
should even itself out over time. |
|||
|
|||
|
|||
## cache.symlinks |
|||
|
|||
* `cache.symlinks=BOOL`: Enable kernel caching of symlink |
|||
values. Defaults to `false`. |
|||
|
|||
As of Linux v4.20 there is an ability to cache the value of symlinks |
|||
so that the kernel does not need to make a request to mergerfs every |
|||
single time a |
|||
[readlink](https://man7.org/linux/man-pages/man2/readlink.2.html) |
|||
request is made. While not a common usage pattern, if software very |
|||
regularly queries symlink values, the use of this cache could |
|||
significantly improve performance. |
|||
|
|||
mergerfs will not error if the kernel used does not support symlink |
|||
caching. |
|||
|
|||
As with other caches the main risk in enabling it is if you are |
|||
manipulating symlinks from both within and without the mergerfs |
|||
mount. Should the value be changed outside of mergerfs then it will |
|||
not be reflected in the mergerfs mount till the cached value is |
|||
invalidated. |
|||
|
|||
|
|||
## cache.readdir |
|||
|
|||
* `cache.readdir=BOOL`: Enable kernel caching of readdir |
|||
results. Defaults to `false`. |
|||
|
|||
As of Linux v4.20 it supports readdir caching. This can have a |
|||
significant impact on directory traversal. Especially when combined |
|||
with entry (`cache.entry`) and attribute (`cache.attr`) caching. If |
|||
the kernel doesn't support readdir caching setting the option to true |
|||
has no effect. This option is configurable at runtime via xattr |
|||
user.mergerfs.cache.readdir. |
|||
|
|||
## cache.writeback |
|||
|
|||
* `cache.writeback=BOOL`: Enable writeback cache. Defaults to `false`. |
|||
|
|||
When `cache.files` is enabled the default is for it to perform |
|||
writethrough caching. This behavior won't help improve performance as |
|||
each write still goes one for one through the filesystem. By enabling |
|||
the FUSE writeback cache small writes *may* be aggregated by the |
|||
kernel and then sent to mergerfs as one larger request. This can |
|||
greatly improve the throughput for apps which write to files |
|||
inefficiently. The amount the kernel can aggregate is limited by the |
|||
size of a FUSE message. Read the fuse_msg_size section for more |
|||
details. |
|||
|
|||
There is a side effect as a result of enabling writeback |
|||
caching. Underlying files won't ever be opened with O_APPEND or |
|||
O_WRONLY. The former because the kernel then manages append mode and |
|||
the latter because the kernel may request file data from mergerfs to |
|||
populate the write cache. The O_APPEND change means that if a file is |
|||
changed outside of mergerfs it could lead to corruption as the kernel |
|||
won't know the end of the file has changed. That said any time you use |
|||
caching you should keep from writing to the same file outside of |
|||
mergerfs at the same time. |
|||
|
|||
Note that if an application is properly sizing writes then writeback |
|||
caching will have little or no effect. It will only help with writes |
|||
of sizes below the FUSE message size (128K on older kernels, 1M on |
|||
newer). Even then its effectiveness might not be great. Given the side |
|||
effects of enabling this feature it is recommended that its benefits |
|||
be proved out with benchmarks. |
@ -0,0 +1,21 @@ |
|||
# Deprecated Options |
|||
|
|||
These are old, deprecated options which may no longer have any |
|||
function or have been replaced. |
|||
|
|||
* **direct_io**: Bypass page cache. Use `cache.files=off` |
|||
instead. |
|||
* **kernel_cache**: Do not invalidate data cache on file open. Use |
|||
`cache.files=full` instead. |
|||
* **auto_cache**: Invalidate data cache if file mtime or |
|||
size change. Use `cache.files=auto-full` instead. (default: false) |
|||
* **async_read**: Perform reads asynchronously. Use |
|||
`async_read=true` instead. |
|||
* **sync_read**: Perform reads synchronously. Use |
|||
`async_read=false` instead. |
|||
* **splice_read**: Does nothing. |
|||
* **splice_write**: Does nothing. |
|||
* **splice_move**: Does nothing. |
|||
* **allow_other**: mergerfs v2.35.0 and above sets this FUSE option |
|||
automatically if running as root. |
|||
* **use_ino**: Effectively replaced with `inodecalc`. |
@ -0,0 +1,14 @@ |
|||
# export-support |
|||
|
|||
* `export-support=true|false` |
|||
* Defaults to `true`. |
|||
|
|||
In theory, this flag should not be exposed to the end user. It is a |
|||
low-level FUSE flag which indicates whether or not the kernel can send |
|||
certain kinds of messages to it for the purposes of using it with |
|||
NFS. mergerfs does support these messages but due to bugs and quirks |
|||
found in the kernel and mergerfs this option is provided just in case |
|||
it is needed for debugging. |
|||
|
|||
Given that this flag is set when the FUSE connection is first |
|||
initiated it is not possible to change during run time. |
@ -0,0 +1,21 @@ |
|||
# flush-on-close |
|||
|
|||
By default, FUSE would issue a flush before the release of a file |
|||
descriptor. This was considered a bit aggressive and a feature added |
|||
to give the FUSE server the ability to choose when that happens. |
|||
|
|||
* `flush-on-close=always` |
|||
* `flush-on-close=never` |
|||
* `flush-on-close=opened-for-write` |
|||
* Defaults to `opened-for-write`. |
|||
|
|||
For now it defaults to `opened-for-write` which is less aggressive |
|||
than the behavior before this feature was added. It should not be a |
|||
problem because the flush is really only relevant when a file is |
|||
written to. Given flush is irrelevant for many filesystems in the |
|||
future a branch specific flag may be added so only files opened on a |
|||
specific branch would be flushed on close. |
|||
|
|||
## References |
|||
|
|||
* [https://lkml.kernel.org/linux-fsdevel/20211024132607.1636952-1-amir73il@gmail.com/T/](https://lkml.kernel.org/linux-fsdevel/20211024132607.1636952-1-amir73il@gmail.com/T/) |
@ -0,0 +1,23 @@ |
|||
# follow-symlinks |
|||
|
|||
This feature, when enabled, will cause symlinks to be interpreted by |
|||
mergerfs as their target. |
|||
|
|||
When there is a getattr/stat request for a file mergerfs will check if |
|||
the file is a symlink and depending on the `follow-symlinks` setting |
|||
will replace the information about the symlink with that of that which |
|||
it points to. |
|||
|
|||
When unlink'ing or rmdir'ing the followed symlink it will remove the |
|||
symlink itself and not that which it points to. |
|||
|
|||
* `follow-symlinks=never`: Behave as normal. Symlinks are treated as such. |
|||
* `follow-symlinks=directory`: Resolve symlinks only which point to directories. |
|||
* `follow-symlinks=regular`: Resolve symlinks only which point to regular files. |
|||
* `follow-symlinks=all`: Resolve all symlinks to that which they point |
|||
to. Symlinks which do not point to anything are left as is. |
|||
* Defaults to `never`. |
|||
|
|||
**WARNING:** This feature should be considered experimental. There |
|||
might be edge cases yet found. If you find any odd behaviors please |
|||
file a ticket on [github](https://github.com/trapexit/mergerfs/issues/new?assignees=&labels=bug%2C+investigating&projects=&template=bug_report.md&title=). |
@ -0,0 +1,17 @@ |
|||
# func.readdir |
|||
|
|||
examples: `func.readdir=seq`, `func.readdir=cor:4` |
|||
|
|||
`readdir` has policies to control how it reads directory content. |
|||
|
|||
| Policy | Description | |
|||
| ------ | ----------- | |
|||
| seq | "sequential" : Iterate sequentially over branches in the order defined in `branches`. This is the default and traditional behavior found prior to the readdir policy introduction. This will be increasingly slower as more branches are added to the pool. Especially if needing to wait for drives to spin up or network filesystems to respond. | |
|||
| cosr | "concurrent open, sequential read" : Concurrently open branch directories using a thread pool and process them in the order defined in `branches`. This keeps memory and CPU usage low while also reducing the time spent waiting on branches to respond. Number of threads defaults to the number of logical cores. Can be overwritten via the syntax `func.readdir=cosr:N` where `N` is the number of threads. | |
|||
| cor | "concurrent open and read" : Concurrently open branch directories and immediately start reading their contents using a thread pool. This will result in slightly higher memory and CPU usage but reduced latency. Particularly when using higher latency / slower speed network filesystem branches. Unlike `seq` and `cosr` the order of files could change due the async nature of the thread pool. This should not be a problem since the order of files listed in not guaranteed. Number of threads defaults to the number of logical cores. Can be overwritten via the syntax `func.readdir=cor:N` where `N` is the number of threads. | |
|||
|
|||
Keep in mind that `readdir` mostly just provides a list of file names |
|||
in a directory and possibly some basic metadata about said files. To |
|||
know details about the files, as one would see from commands like |
|||
`find` or `ls`, it is required to call `stat` on the file which is |
|||
controlled by `fuse.getattr`. |
@ -0,0 +1,29 @@ |
|||
# fuse_msg_size |
|||
|
|||
* `fuse_msg_size=UINT` |
|||
* Defaults to `256` |
|||
|
|||
FUSE applications communicate with the kernel over a special character |
|||
device: `/dev/fuse`. A large portion of the overhead associated with |
|||
FUSE is the cost of going back and forth between user space and kernel |
|||
space over that device. Generally speaking, the fewer trips needed the |
|||
better the performance will be. Reducing the number of trips can be |
|||
done a number of ways. Kernel level caching and increasing message |
|||
sizes being two significant ones. When it comes to reads and writes if |
|||
the message size is doubled the number of trips are approximately |
|||
halved. |
|||
|
|||
In Linux v4.20 a new feature was added allowing the negotiation of the |
|||
max message size. Since the size is in multiples of |
|||
[pages](https://en.wikipedia.org/wiki/Page_(computer_memory)) the |
|||
feature is called `max_pages`. There is a maximum `max_pages` value of |
|||
256 (1MiB) and minimum of 1 (4KiB). The default used by Linux >=4.20, |
|||
and hardcoded value used before 4.20, is 32 (128KiB). In mergerfs it's |
|||
referred to as fuse_msg_size to make it clear what it impacts and |
|||
provide some abstraction. |
|||
|
|||
Since there should be no downsides to increasing `fuse_msg_size`, |
|||
outside a minor increase in RAM usage due to larger message buffers, |
|||
mergerfs defaults the value to 256. On kernels before v4.20 the value |
|||
has no effect. The reason the value is configurable is to enable |
|||
experimentation and benchmarking. |
@ -0,0 +1,75 @@ |
|||
# inodecalc |
|||
|
|||
Inodes (`st_ino`) are unique identifiers within a filesystem. Each |
|||
mounted filesystem has device ID (st_dev) as well and together they |
|||
can uniquely identify a file on the whole of the system. Entries on |
|||
the same device with the same inode are in fact references to the same |
|||
underlying file. It is a many to one relationship between names and an |
|||
inode. Directories, however, do not have multiple links on most |
|||
systems due to the complexity they add. |
|||
|
|||
FUSE allows the server (mergerfs) to set inode values but not device |
|||
IDs. Creating an inode value is somewhat complex in mergerfs' case as |
|||
files aren't really in its control. If a policy changes what directory |
|||
or file is to be selected or something changes out of band it becomes |
|||
unclear what value should be used. Most software does not to care what |
|||
the values are but those that do often break if a value changes |
|||
unexpectedly. The tool find will abort a directory walk if it sees a |
|||
directory inode change. NFS can return stale handle errors if the |
|||
inode changes out of band. File dedup tools will usually leverage |
|||
device ids and inodes as a shortcut in searching for duplicate files |
|||
and would resort to full file comparisons should it find different |
|||
inode values. |
|||
|
|||
mergerfs offers multiple ways to calculate the inode in hopes of |
|||
covering different usecases. |
|||
|
|||
* `passthrough`: Passes through the underlying inode value. Mostly |
|||
intended for testing as using this does not address any of the |
|||
problems mentioned above and could confuse file deduplication |
|||
software as inodes from different filesystems can be the same. |
|||
* `path-hash`: Hashes the relative path of the entry in question. The |
|||
underlying file's values are completely ignored. This means the |
|||
inode value will always be the same for that file path. This is |
|||
useful when using NFS and you make changes out of band such as copy |
|||
data between branches. This also means that entries that do point to |
|||
the same file will not be recognizable via inodes. That does not |
|||
mean hard links don't work. They will. |
|||
* `path-hash32`: 32bit version of path-hash. |
|||
* `devino-hash`: Hashes the device id and inode of the underlying |
|||
entry. This won't prevent issues with NFS should the policy pick a |
|||
different file or files move out of band but will present the same |
|||
inode for underlying files that do too. |
|||
* `devino-hash32`: 32bit version of devino-hash. |
|||
* `hybrid-hash`: Performs path-hash on directories and devino-hash on |
|||
other file types. Since directories can't have hard links the static |
|||
value won't make a difference and the files will get values useful |
|||
for finding duplicates. Probably the best to use if not using |
|||
NFS. As such it is the default. |
|||
* `hybrid-hash32`: 32bit version of hybrid-hash. |
|||
|
|||
32bit versions are provided as there is some software which does not |
|||
handle 64bit inodes well. |
|||
|
|||
While there is a risk of hash collision in tests of a couple of |
|||
million entries there were zero collisions. Unlike a typical |
|||
filesystem FUSE filesystems can reuse inodes and not refer to the same |
|||
entry. The internal identifier used to reference a file in FUSE is |
|||
different from the inode value presented. The former is the nodeid and |
|||
is actually a tuple of 2 64bit values: nodeid and generation. This |
|||
tuple is not client facing. The inode that is presented to the client |
|||
is passed through the kernel uninterpreted. |
|||
|
|||
From FUSE docs for `use_ino`: |
|||
|
|||
> Honor the st_ino field in the functions getattr() and |
|||
> fill_dir(). This value is used to fill in the st_ino field |
|||
> in the stat(2), lstat(2), fstat(2) functions and the d_ino |
|||
> field in the readdir(2) function. The filesystem does not |
|||
> have to guarantee uniqueness, however some applications |
|||
> rely on this value being unique for the whole filesystem. |
|||
> Note that this does *not* affect the inode that libfuse |
|||
> and the kernel use internally (also called the "nodeid"). |
|||
|
|||
**NOTE:** As of version 2.35.0 the use_ino option has been |
|||
removed. mergerfs should always be managing inode values. |
@ -0,0 +1,17 @@ |
|||
# link-exdev |
|||
|
|||
If using path preservation and a `link` fails with `EXDEV` make a call |
|||
to `symlink` where the target is the `oldlink` and the `linkpath` is |
|||
the newpath. The target value is determined by the value of |
|||
`link-exdev`. |
|||
|
|||
* `link-exdev=passthrough`: Return EXDEV as normal. |
|||
* `link-exdev=rel-symlink`: A relative path from the newpath. |
|||
* `link-exdev=abs-base-symlink`: An absolute value using the |
|||
underlying branch. |
|||
* `link-exdev=abs-pool-symlink`: An absolute value using the mergerfs |
|||
mount point. |
|||
* Defaults to `passthrough`. |
|||
|
|||
**NOTE:** It is possible that some applications check the file they |
|||
link. In those cases, it is possible it will error or complain. |
@ -0,0 +1,13 @@ |
|||
# link_cow |
|||
|
|||
* `link_cow=true|false` |
|||
* Defaults to `false` |
|||
|
|||
This feature offers similar functionality to what |
|||
[cow-shell](https://manpages.ubuntu.com/manpages/noble/man1/cow-shell.1.html) |
|||
offers. |
|||
|
|||
When enabled if mergerfs is asked to open a file to write and the link |
|||
count on the file is greater than 1 it will copy the file to a |
|||
temporary new file and then rename it over the original. This will |
|||
atomically "break" the link. After that it will open the new file. |
@ -0,0 +1,26 @@ |
|||
# nfsopenhack |
|||
|
|||
* `nfsopenhack=off`: No hack applied. |
|||
* `nfsopenhack=git`: Apply hack if path includes `/.git/`. |
|||
* `nfsopenhack=all`: Apply hack on all empty read-only files opened |
|||
for writing. |
|||
* Defaults to `off`. |
|||
|
|||
NFS is not fully POSIX compliant and historically certain behaviors, |
|||
such as opening files with `O_EXCL`, are not or not well |
|||
supported. When mergerfs (or any FUSE filesystem) is exported over NFS |
|||
some of these issues come up due to how NFS and FUSE interact. |
|||
|
|||
This hack addresses the issue where the creation of a file with a |
|||
read-only mode but with a read/write or write only flag. Normally this |
|||
is perfectly valid but NFS chops the one open call into multiple |
|||
calls. Exactly how it is translated depends on the configuration and |
|||
versions of the NFS server and clients but it results in a permission |
|||
error because a normal user is not allowed to open a read-only file as |
|||
writable. |
|||
|
|||
Even though it's a more niche situation this hack breaks normal |
|||
security and behavior and as such is `off` by default. If set to `git` |
|||
it will only perform the hack when the path in question includes |
|||
`/.git/`. `all` will result in it applying anytime a read-only file |
|||
which is empty is opened for writing. |
@ -0,0 +1,20 @@ |
|||
# nullrw |
|||
|
|||
* `nullrw=true|false` |
|||
* Defaults to `false`. |
|||
|
|||
Due to how FUSE works there is an overhead to all requests made to a |
|||
FUSE filesystem that wouldn't exist for an in kernel one. Meaning that |
|||
even a simple passthrough will have some slowdown. However, generally |
|||
the overhead is minimal in comparison to the cost of the underlying |
|||
I/O. By disabling the underlying I/O we can test the theoretical |
|||
performance boundaries. |
|||
|
|||
By enabling `nullrw` mergerfs will work as it always does **except** |
|||
that all reads and writes will be no-ops. A write will succeed (the |
|||
size of the write will be returned as if it were successful) but |
|||
mergerfs does nothing with the data it was given. Similarly a read |
|||
will return the size requested but won't touch the buffer. |
|||
|
|||
See the [benchmarking](../benchmarking.md) section for suggestions on |
|||
how to test. |
@ -0,0 +1,23 @@ |
|||
# pin-threads |
|||
|
|||
Simple strategies for pinning read and/or process threads. If process |
|||
threads are not enabled then the strategy simply works on the read |
|||
threads. Invalid values are ignored. |
|||
|
|||
* `pin-threads=R1L`: All read threads pinned to a single logical CPU. |
|||
* `pin-threads=R1P`: All read threads pinned to a single physical CPU. |
|||
* `pin-threads=RP1L`: All read and process threads pinned to a single logical CPU. |
|||
* `pin-threads=RP1P`: All read and process threads pinned to a single physical CPU. |
|||
* `pin-threads=R1LP1L`: All read threads pinned to a single logical |
|||
CPU, all process threads pinned to a (if possible) different logical |
|||
CPU. |
|||
* `pin-threads=R1PP1P`: All read threads pinned to a single physical |
|||
CPU, all process threads pinned to a (if possible) different logical |
|||
CPU. |
|||
* `pin-threads=RPSL`: All read and process threads are spread across |
|||
all logical CPUs. |
|||
* `pin-threads=RPSP`: All read and process threads are spread across |
|||
all physical CPUs. |
|||
* `pin-threads=R1PPSP`: All read threads are pinned to a single |
|||
physical CPU while process threads are spread across all other |
|||
physical CPUs. |
@ -0,0 +1,38 @@ |
|||
# readahead |
|||
|
|||
Sets the mergerfs and underlying filesystem `readahead` values. The |
|||
value unit is in kibibytes. |
|||
|
|||
* `readahead=1024` |
|||
|
|||
While the max size of messages sent between the kernel and mergerfs is |
|||
configurable via the [fuse_msg_size](fuse_msg_size.md) option that |
|||
doesn't mean that is the size used by the kernel for read and |
|||
writes. |
|||
|
|||
Linux has a max read/write size of 2GB. Since the max FUSE message |
|||
size is just over 1MB the kernel will break up read and write requests |
|||
with buffers larger than that 1MB. |
|||
|
|||
When page caching is disabled (`cache.files=off`), besides the kernel |
|||
breaking up requests with larger buffers, requests are effectively one |
|||
for one to mergerfs. A read or write request for X bytes is made to |
|||
the kernel and a request for X bytes is made to mergerfs. No |
|||
[readahead](https://en.wikipedia.org/wiki/Readahead) behavior will |
|||
occur because there is no page cache available for it to store that |
|||
data. In FUSE this is referred to as "direct IO". Note that "direct |
|||
IO" is not the same as `O_DIRECT`. |
|||
|
|||
When page caching is enabled the kernel can and will utilize |
|||
`readahead`. However, there are two values which impact the size of |
|||
the `readahead` requests. The filesystem's `readahead` value and the |
|||
FUSE `max_readahead` value. Whichever is lowest is used. The default |
|||
`max_readahead` in mergerfs is maxed out meaning only the filesystem |
|||
`readahead` value is relevant. |
|||
|
|||
Preferably this value would be set by the user externally since it is |
|||
a generic feature but there is no standard way to do so mergerfs added |
|||
this feature to make it easier to set. |
|||
|
|||
There is currently no way to set separate values for different |
|||
branches through mergerfs. |
@ -0,0 +1,21 @@ |
|||
# rename-exdev |
|||
|
|||
If using path preservation and a `rename` fails with `EXDEV`: |
|||
|
|||
1. Move file from `/branch/a/b/c` to `/branch/.mergerfs_rename_exdev/a/b/c`. |
|||
2. symlink the rename's `newpath` to the moved file. |
|||
|
|||
The `target` value is determined by the value of `rename-exdev`. |
|||
|
|||
* `rename-exdev=passthrough`: Return `EXDEV` as normal. |
|||
* `rename-exdev=rel-symlink`: A relative path from the `newpath`. |
|||
* `rename-exdev=abs-symlink`: An absolute value using the mergerfs |
|||
mount point. |
|||
* Defaults to `passthrough`. |
|||
|
|||
**NOTE:** It is possible that some applications check the file they |
|||
rename. In those cases it is possible it will error or complain. |
|||
|
|||
**NOTE:** The reason `abs-symlink` is not split into two like |
|||
`link-exdev` is due to the complexities in managing absolute base |
|||
symlinks when multiple `oldpaths` exist. |
@ -0,0 +1,59 @@ |
|||
# rename and link |
|||
|
|||
**NOTE:** If you're receiving errors from software when files are |
|||
moved / renamed / linked then you should consider changing the create |
|||
policy to one which is **not** path preserving, enabling |
|||
`ignorepponrename`, or contacting the author of the offending software |
|||
and requesting that `EXDEV` (cross device / improper link) be properly |
|||
handled. |
|||
|
|||
`rename` and `link` are arguably the most complicated functions to |
|||
create in a union filesystem. `rename` only works within a single |
|||
filesystem or device. If a rename can't be done due to the source and |
|||
destination paths existing on different mount points it will return |
|||
**-1** with **errno = EXDEV** (cross device / improper link). So if a |
|||
`rename`'s source and target are on different filesystems within the |
|||
pool it creates an issue. |
|||
|
|||
Originally mergerfs would return EXDEV whenever a rename was requested |
|||
which was cross directory in any way. This made the code simple and |
|||
was technically compliant with POSIX requirements. However, many |
|||
applications fail to handle EXDEV at all and treat it as a normal |
|||
error or otherwise handle it poorly. Such apps include: gvfsd-fuse |
|||
v1.20.3 and prior, Finder / CIFS/SMB client in Apple OSX 10.9+, |
|||
NZBGet, Samba's recycling bin feature. |
|||
|
|||
As a result a compromise was made in order to get most software to |
|||
work while still obeying mergerfs' policies. Below is the basic logic. |
|||
|
|||
* If using a **create** policy which tries to preserve directory paths (epff,eplfs,eplus,epmfs) |
|||
* Using the **rename** policy get the list of files to rename |
|||
* For each file attempt rename: |
|||
* If failure with ENOENT (no such file or directory) run **create** policy |
|||
* If create policy returns the same branch as currently evaluating then clone the path |
|||
* Re-attempt rename |
|||
* If **any** of the renames succeed the higher level rename is considered a success |
|||
* If **no** renames succeed the first error encountered will be returned |
|||
* On success: |
|||
* Remove the target from all branches with no source file |
|||
* Remove the source from all branches which failed to rename |
|||
* If using a **create** policy which does **not** try to preserve directory paths |
|||
* Using the **rename** policy get the list of files to rename |
|||
* Using the **getattr** policy get the target path |
|||
* For each file attempt rename: |
|||
* If the source branch != target branch: |
|||
* Clone target path from target branch to source branch |
|||
* Rename |
|||
* If **any** of the renames succeed the higher level rename is considered a success |
|||
* If **no** renames succeed the first error encountered will be returned |
|||
* On success: |
|||
* Remove the target from all branches with no source file |
|||
* Remove the source from all branches which failed to rename |
|||
|
|||
The removals are subject to normal entitlement checks. If the unlink |
|||
fails it will fail silently. |
|||
|
|||
The above behavior will help minimize the likelihood of EXDEV being |
|||
returned but it will still be possible. |
|||
|
|||
**link** uses the same strategy but without the removals. |
@ -0,0 +1,26 @@ |
|||
# statfs / statvfs |
|||
|
|||
* `statfs=base`: Aggregate details from all branches using their base directory. |
|||
* `statfs=full`: Aggregate details using the full path of the file |
|||
requested. Limiting it to only branches where the file exists. |
|||
* Defaults to `base`. |
|||
|
|||
[statvfs](http://linux.die.net/man/2/statvfs) normalizes the source |
|||
filesystems based on the fragment size and sums the number of adjusted |
|||
blocks and inodes. This means you will see the combined space of all |
|||
sources. Total, used, and free. The sources however are dedupped based |
|||
on the filesystem so multiple sources on the same drive will not result in |
|||
double counting its space. Other filesystems mounted further down the tree |
|||
of the branch will not be included when checking the mount's stats. |
|||
|
|||
## statfs_ignore |
|||
|
|||
Modifies how `statfs` works. Will cause it to ignore branches of a |
|||
certain mode. |
|||
|
|||
* `statfs_ignore=none`: Include all branches. |
|||
* `statfs_ignore=ro`: Ignore available space for branches mounted as |
|||
read-only or have a mode `RO` or `NC`. |
|||
* `statfs_ignore=nc`: Ignore available space for branches with a mode |
|||
of `NC`. |
|||
* Defaults to `none`. |
@ -0,0 +1,23 @@ |
|||
# symlinkify |
|||
|
|||
* `symlinkify=true|false` |
|||
* Defaults to `false`. |
|||
|
|||
Due to the levels of indirection introduced by mergerfs and the |
|||
underlying technology FUSE there can be varying levels of performance |
|||
degradation. This feature will turn non-directories which are not |
|||
writable into symlinks to the original file found by the `readlink` |
|||
policy after the mtime and ctime are older than the timeout. |
|||
|
|||
**WARNING:** The current implementation has a known issue in which if |
|||
the file is open and being used when the file is converted to a |
|||
symlink then the application which has that file open will receive an |
|||
error when using it. This is unlikely to occur in practice but is |
|||
something to keep in mind. |
|||
|
|||
**WARNING:** Some backup solutions, such as CrashPlan, do not backup |
|||
the target of a symlink. If using this feature it will be necessary to |
|||
point any backup software to the original filesystems or configure the |
|||
software to follow symlinks if such an option is |
|||
available. Alternatively, create two mounts. One for backup and one |
|||
for general consumption. |
@ -0,0 +1,12 @@ |
|||
# Terminology |
|||
|
|||
- `branch`: A base path used in the pool. Keep in mind that mergerfs |
|||
does not work on devices or even filesystems but on paths. It can |
|||
accomidate for multiple paths pointing to the same filesystem. |
|||
- `pool`: The mergerfs mount. The union of the branches. The instance |
|||
of mergerfs. You can have as many pools as you wish. |
|||
- `relative path`: The path in the pool relative to the branch and mount. |
|||
- `function`: A filesystem call (open, unlink, create, getattr, rmdir, etc.) |
|||
- `category`: A collection of functions based on basic behavior (action, create, search). |
|||
- `policy`: The algorithm used to select a file or files when performing a function. |
|||
- `path preservation`: Aspect of some policies which includes checking the path for which a file would be created. |
@ -0,0 +1,53 @@ |
|||
# threads |
|||
|
|||
There are multiple thread pools used in mergerfs to provide |
|||
parallel behaviors. |
|||
|
|||
|
|||
## read-thread-count |
|||
|
|||
The number of threads used to read (and possibly process) messages |
|||
from the kernel. |
|||
|
|||
* `read-thread-count=0`: Create a thread pool sized to the number of |
|||
logical CPUs. |
|||
* `read-thread-count=N` where `N>0`: Create a thread pool of `N` threads. |
|||
* `read-thread-count=N` where `N<0`: Create a thread pool of `CPUCount / |
|||
-N` threads. |
|||
* `read-thread-count=-1` where `process-thread-count=-1`: Creates `2` |
|||
read threads and `max(2,CPUCount-2)` process threads. |
|||
* Defaults to `0`. |
|||
|
|||
When `process-thread-count=-1` (the default) this option sets the |
|||
number of threads which read and then process requests from the |
|||
kernel. |
|||
|
|||
When `process-thread-count` is set to anything else mergerfs will |
|||
create two thread pools. A "read" thread pool which just reads from |
|||
the kernel and hands off requests to the "process" thread pool. |
|||
|
|||
Generally, only 1 or 2 "read" threads are necessary. |
|||
|
|||
|
|||
## process-thread-count |
|||
|
|||
When enabled this sets the number of threads in the message processing pool. |
|||
|
|||
* `process-thread-count=-1`: Process thread pool is disabled. |
|||
* `process-thread-count=0`: Create a thread pool sized to the number |
|||
of logical CPUs. |
|||
* `process-thread-count=N` where `N>0`: Create a thread pool of `N` threads. |
|||
* `process-thread-count=N` where `N<-1`: Create a thread pool of `CPUCount / |
|||
-N` threads. |
|||
* Defaults to `-1`. |
|||
|
|||
|
|||
## process-thread-queue-depth |
|||
|
|||
* `process-thread-queue-depth=N` where `N>0`: Sets the number of outstanding |
|||
requests that a process thread can have to N. If requests come in |
|||
faster than can be processed and the max queue depth hit then |
|||
queuing the request will block in order to limit memory growth. |
|||
* `process-thread-queue-depth=0`: Sets the queue depth to the thread |
|||
pool count. |
|||
* Defaults to `0`. |
@ -0,0 +1,27 @@ |
|||
# xattr |
|||
|
|||
* `xattr=passthrough`: Passes through all requests to underlying file. |
|||
* `xattr=noattr`: mergerfs receives the request but returns `NOATTR`. |
|||
* `xattr=nosys`: Tells the kernel to reject all `xattr` requests. |
|||
* Defaults to `passthrough`. |
|||
|
|||
Runtime extended attribute support can be managed via the `xattr` |
|||
option. By default it will passthrough any xattr calls. Given xattr |
|||
support is rarely used and can have significant performance |
|||
implications mergerfs allows it to be disabled at runtime. The |
|||
performance problems mostly comes when file caching is enabled. The |
|||
kernel will send a `getxattr` for `security.capability` *before every |
|||
single write*. It doesn't cache the responses to any `getxattr`. This |
|||
might be addressed in the future but for now mergerfs can really only |
|||
offer the following workarounds. |
|||
|
|||
`noattr` will cause mergerfs to short circuit all xattr calls and |
|||
return ENOATTR where appropriate. mergerfs still gets all the requests |
|||
but they will not be forwarded on to the underlying filesystems. The |
|||
runtime control will still function in this mode. |
|||
|
|||
`nosys` will cause mergerfs to return `ENOSYS` for any xattr call. The |
|||
difference with `noattr` is that the kernel will cache this fact and |
|||
itself short circuit future calls. This is more efficient than |
|||
`noattr` but will cause mergerfs' runtime control via the hidden file |
|||
to stop working. |
@ -1,4 +1,4 @@ |
|||
# ERROR HANDLING |
|||
# Error Handling |
|||
|
|||
POSIX filesystem functions offer a single return code meaning that |
|||
there is some complication regarding the handling of multiple branches |
@ -1,5 +1,10 @@ |
|||
# Limiting drive spinup |
|||
|
|||
## How can I setup my system to limit drive spinup? |
|||
|
|||
TL;DR: You really can't. Not through mergerfs alone. |
|||
|
|||
|
|||
mergerfs is a proxy. Not a cache. It proxies calls between client software and underlying filesystems. If a client does an `open`, `readdir`, `stat`, etc. it must translate that into something that makes sense across N filesystems. For `readdir` that means running the call against all branches and aggregating the output. For `open` that means finding the file to open and doing so. The only way to find the file to open is to scan across all branches and sort the results and pick one. There is no practical way to do otherwise. Especially given so many mergerfs users expect out of band changes to "just work." |
|||
|
|||
The best way to limit spinup of drives is to limit their usage at the client level. Meaning keeping software from interacting with the filesystem all together. |
@ -0,0 +1,31 @@ |
|||
# Reliability and Scalability |
|||
|
|||
## Is mergerfs "production ready?" |
|||
|
|||
Yes. |
|||
|
|||
mergerfs has been around for over a decade and used by many users on |
|||
their systems. Typically running 24/7 with constant load. |
|||
|
|||
At least a few companies are believed to use mergerfs in production |
|||
environments. A number of [NAS focused operating |
|||
systems](../related_projects.md) includes mergerfs as a solution for |
|||
pooling filesystems. |
|||
|
|||
Most serious issues (crashes or data corruption) have been due to |
|||
[kernel bugs](../known_issues_bugs.md#fuse-and-linux-kernel). All of |
|||
which are fixed in stable releases. |
|||
|
|||
|
|||
## How well does mergerfs scale? |
|||
|
|||
Users have reported running mergerfs on everything from a Raspberry Pi |
|||
to multi-socket Xeon enterprise servers. |
|||
|
|||
Users have pooled everything from USB thumb drives to enterprise NVME |
|||
SSDs to remote filesystems and rclone mounts. |
|||
|
|||
The cost of many calls can be `O(n)` meaning adding more branches to |
|||
the pool will increase the cost of certain functions but there are a |
|||
number of caches and stategies in place to limit overhead where |
|||
possible. |
@ -1,35 +1,77 @@ |
|||
# mergerfs - a featureful union filesystem |
|||
|
|||
## DESCRIPTION |
|||
**mergerfs** is a |
|||
[FUSE](https://en.wikipedia.org/wiki/Filesystem_in_Userspace) based |
|||
[union filesystem](https://en.wikipedia.org/wiki/Union_mount) geared |
|||
towards simplifying storage and management of files across numerous |
|||
commodity storage devices. It is similar to **mhddfs**, **unionfs**, |
|||
and **aufs**. |
|||
|
|||
**mergerfs** is a union filesystem geared towards simplifying storage |
|||
and management of files across numerous commodity storage devices. It |
|||
is similar to **mhddfs**, **unionfs**, and **aufs**. |
|||
## Features |
|||
|
|||
## FEATURES |
|||
* Logicially combine numerous filesystems/paths into a single |
|||
mount point |
|||
* Combine paths of the same or different filesystems |
|||
* Ability to add or remove filesystems/paths without impacting the |
|||
rest of the data |
|||
* Unaffected by individual filesystem failure |
|||
* Configurable file selection and creation placement |
|||
* Works with filesystems of any size |
|||
* Works with filesystems of almost any type |
|||
* Ignore read-only filesystems when creating files |
|||
* Hard link copy-on-write / CoW |
|||
* Runtime configurable |
|||
* Support for extended attributes (xattrs) |
|||
* Support for file attributes (chattr) |
|||
* Support for POSIX ACLs |
|||
|
|||
- Configurable behaviors / file placement |
|||
- Ability to add or remove filesystems at will |
|||
- Resistance to individual filesystem failure |
|||
- Support for extended attributes (xattrs) |
|||
- Support for file attributes (chattr) |
|||
- Runtime configurable (via xattrs) |
|||
- Works with heterogeneous filesystem types |
|||
- Moving of file when filesystem runs out of space while writing |
|||
- Ignore read-only filesystems when creating files |
|||
- Turn read-only files into symlinks to underlying file |
|||
- Hard link copy-on-write / CoW |
|||
- Support for POSIX ACLs |
|||
- Misc other things |
|||
|
|||
## SYNOPSIS |
|||
## Non-features |
|||
|
|||
mergerfs -o<options> <branches> <mountpoint> |
|||
* Read/write overlay on top of readonly filesystem like OverlayFS |
|||
* File whiteout |
|||
* RAID like parity calculation |
|||
* Redundency |
|||
* Splitting of files across branches |
|||
|
|||
## DOCUMENTATION |
|||
|
|||
- [https://trapexit.github.io/mergerfs/](https://trapexit.github.io/mergerfs/) |
|||
## How it works |
|||
|
|||
## TOOLS |
|||
mergerfs logically merges multiple filesystem paths together. It acts |
|||
as a proxy to the underlying filesystem paths. Combining the |
|||
behaviors of some functions and being a selector for others. |
|||
|
|||
- [mergerfs tools](https://github.com/trapexit/mergerfs-tools) |
|||
When the contents of a directory are requested mergerfs combines the |
|||
list of files from each directory, deduplicating entries, and returns |
|||
that list. |
|||
|
|||
When a file or directory is created a policy is first run to determine |
|||
which branch will be selected for the creation. |
|||
|
|||
For functions which chant attributes or remove the file the behavior |
|||
may be applied to all instances found. |
|||
|
|||
Read more about [policies here](config/functions_categories_and_policies.md). |
|||
|
|||
### Visualization |
|||
|
|||
``` |
|||
A + B = C |
|||
/disk1 /disk2 /merged |
|||
| | | |
|||
+-- /dir1 +-- /dir1 +-- /dir1 |
|||
| | | | | | |
|||
| +-- file1 | +-- file2 | +-- file1 |
|||
| | +-- file3 | +-- file2 |
|||
+-- /dir2 | | +-- file3 |
|||
| | +-- /dir3 | |
|||
| +-- file4 | +-- /dir2 |
|||
| +-- file5 | | |
|||
+-- file6 | +-- file4 |
|||
| |
|||
+-- /dir3 |
|||
| | |
|||
| +-- file5 |
|||
| |
|||
+-- file6 |
|||
``` |
@ -0,0 +1,271 @@ |
|||
# Known Issues and Bugs |
|||
|
|||
## mergerfs |
|||
|
|||
### Supplemental user groups |
|||
|
|||
Due to the overhead of |
|||
[getgroups/setgroups](http://linux.die.net/man/2/setgroups) mergerfs |
|||
utilizes a cache. This cache is opportunistic and per thread. Each |
|||
thread will query the supplemental groups for a user when that |
|||
particular thread needs to change credentials and will keep that data |
|||
for the lifetime of the thread. This means that if a user is added to |
|||
a group it may not be picked up without the restart of |
|||
mergerfs. In the future this may be improved to allow a periodic or |
|||
manual clearing of the cache. |
|||
|
|||
While not a bug some users have found when using containers that |
|||
supplemental groups defined inside the container don't work as |
|||
expected. Since mergerfs lives outside the container it is querying |
|||
the host's group database. Effectively containers have their own user |
|||
and group definitions unless setup otherwise just as different systems |
|||
would. |
|||
|
|||
Users should mount in the host group file into the containers or use a |
|||
standard shared user & groups technology like NIS or LDAP. |
|||
|
|||
|
|||
### directory mtime is not being updated |
|||
|
|||
Remember that the default policy for `getattr` is `ff`. The |
|||
information for the first directory found will be returned. If it |
|||
wasn't the directory which had been updated then it will appear |
|||
outdated. |
|||
|
|||
The reason this is the default is because any other policy would be |
|||
more expensive and for many applications it is unnecessary. To always |
|||
return the directory with the most recent mtime or a faked value based |
|||
on all found would require a scan of all filesystems. |
|||
|
|||
If you always want the directory information from the one with the |
|||
most recent mtime then use the `newest` policy for `getattr`. |
|||
|
|||
|
|||
### 'mv /mnt/pool/foo /mnt/disk1/foo' removes 'foo' |
|||
|
|||
This is not a bug. |
|||
|
|||
Run in verbose mode to better understand what's happening: |
|||
|
|||
``` |
|||
$ mv -v /mnt/pool/foo /mnt/disk1/foo |
|||
copied '/mnt/pool/foo' -> '/mnt/disk1/foo' |
|||
removed '/mnt/pool/foo' |
|||
$ ls /mnt/pool/foo |
|||
ls: cannot access '/mnt/pool/foo': No such file or directory |
|||
``` |
|||
|
|||
`mv`, when working across devices, is copying the source to target and |
|||
then removing the source. Since the source **is** the target in this |
|||
case, depending on the unlink policy, it will remove the just copied |
|||
file and other files across the branches. |
|||
|
|||
If you want to move files to one filesystem just copy them there and |
|||
use mergerfs.dedup to clean up the old paths or manually remove them |
|||
from the branches directly. |
|||
|
|||
|
|||
### cached memory appears greater than it should be |
|||
|
|||
Use `cache.files=off` and/or `dropcacheonclose=true`. See the section |
|||
on [page caching](config/cache.md). |
|||
|
|||
|
|||
### NFS clients returning ESTALE / Stale file handle |
|||
|
|||
NFS generally does not like out of band changes. Take a look at the |
|||
section on NFS in the [remote-filesystems](remote_filesystems.md) for |
|||
more details. |
|||
|
|||
|
|||
### rtorrent fails with ENODEV (No such device) |
|||
|
|||
Be sure to set |
|||
[cache.files=partial|full|auto-full|per-process](config/cache.md) |
|||
or use Linux kernel v6.6 or above. rtorrent and some other |
|||
applications use [mmap](http://linux.die.net/man/2/mmap) to read and |
|||
write to files and offer no fallback to traditional methods. |
|||
|
|||
|
|||
### Plex / Jellyfin doesn't work with mergerfs |
|||
|
|||
It does. If you're trying to put the software's config / metadata / |
|||
database on mergerfs you can't set |
|||
[cache.files=off](config/cache.md) (unless you use Linux v6.6 or |
|||
above) because Plex is using **sqlite3** with **mmap** enabled. |
|||
|
|||
That said it is recommended that config and runtime files be stored on |
|||
SSDs on a regular filesystem for performance reasons and if you are |
|||
using HDDs in your pool to help limit spinup. |
|||
|
|||
Other software that leverages **sqlite3** which require **mmap** |
|||
includes Radarr, Sonarr, Lidarr. |
|||
|
|||
It is recommended that you reach out to the developers of the software |
|||
you're having troubles with and asking them to add a fallback to |
|||
regular file IO when **mmap** is unavailable. It is not only more |
|||
compatible and resilient but also can be more performant in certain |
|||
situations. |
|||
|
|||
If the issue is that quick scanning doesn't seem to pick up media then |
|||
be sure to set `func.getattr=newest`, though generally, a full scan |
|||
will pick up all media anyway. |
|||
|
|||
|
|||
### When a program tries to move or rename a file it fails |
|||
|
|||
Please read the docs regarding [rename and |
|||
link](config/functions_categories_and_policies.md#rename-and-link). |
|||
|
|||
The problem is that many applications do not properly handle `EXDEV` |
|||
errors which `rename` and `link` may return even though they are |
|||
perfectly valid situations which do not indicate actual device, |
|||
filesystem, or OS errors. The error will only be returned by mergerfs |
|||
if using a path preserving policy as described in the policy section |
|||
above. If you do not care about path preservation simply change the |
|||
mergerfs policy to the non-path preserving version. For example: `-o |
|||
category.create=mfs` Ideally the offending software would be fixed and |
|||
it is recommended that if you run into this problem you contact the |
|||
software's author and request proper handling of `EXDEV` errors. |
|||
|
|||
|
|||
### my 32bit software has problems |
|||
|
|||
Some software have problems with 64bit inode values. The symptoms can |
|||
include EOVERFLOW errors when trying to list files. You can address |
|||
this by setting `inodecalc` to one of the 32bit based algos as |
|||
described in the relevant section. |
|||
|
|||
### Moving files and directories fails with Samba |
|||
|
|||
Workaround: Copy the file/directory and then remove the original |
|||
rather than move. |
|||
|
|||
This isn't an issue with Samba but some SMB clients. GVFS-fuse v1.20.3 |
|||
and prior (found in Ubuntu 14.04 among others) failed to handle |
|||
certain error codes correctly. Particularly `STATUS_NOT_SAME_DEVICE` |
|||
which comes from the `EXDEV` that is returned by `rename` when the |
|||
call is crossing mount points. When a program gets an `EXDEV` it needs |
|||
to explicitly take an alternate action to accomplish its goal. In the |
|||
case of `mv` or similar it tries `rename` and on `EXDEV` falls back to |
|||
a copying the file to the destination and deleting the source. In |
|||
these older versions of GVFS-fuse if it received `EXDEV` it would |
|||
translate that into `EIO`. This would cause `mv` or most any |
|||
application attempting to move files around on that SMB share to fail |
|||
with a generic IO error. |
|||
|
|||
[GVFS-fuse v1.22.0](https://bugzilla.gnome.org/show_bug.cgi?id=734568) |
|||
and above fixed this issue but a large number of systems use the older |
|||
release. On Ubuntu, the version can be checked by issuing `apt-cache |
|||
showpkg gvfs-fuse`. Most distros released in 2015 seem to have the |
|||
updated release and will work fine but older systems may |
|||
not. Upgrading gvfs-fuse or the distro in general will address the |
|||
problem. |
|||
|
|||
In Apple's MacOSX 10.9 they replaced Samba (client and server) with |
|||
their own product. It appears their new client does not handle |
|||
`EXDEV` either and responds similarly to older releases of gvfs on |
|||
Linux. |
|||
|
|||
|
|||
### Trashing files occasionally fails |
|||
|
|||
This is the same issue as with Samba. `rename` returns `EXDEV` (in our |
|||
case that will really only happen with path preserving policies like |
|||
`epmfs`) and the software doesn't handle the situation well. This is |
|||
unfortunately a common failure of software which moves files |
|||
around. The standard indicates that an implementation **MAY** choose |
|||
to support non-user home directory trashing of files (which is a |
|||
**MUST**). The implementation **MAY** also support "top directory |
|||
trashes" which many probably do. |
|||
|
|||
To create a `$topdir/.Trash` directory as defined in the standard use |
|||
the [mergerfs-tools](https://github.com/trapexit/mergerfs-tools) tool |
|||
`mergerfs.mktrash`. |
|||
|
|||
|
|||
## FUSE and Linux kernel |
|||
|
|||
There have been a number of kernel issues / bugs over the years which |
|||
mergerfs has run into. Here is a list of them for reference and |
|||
posterity. |
|||
|
|||
|
|||
### NFS and EIO errors |
|||
|
|||
[https://lore.kernel.org/linux-fsdevel/20240228160213.1988854-1-mszeredi@redhat.com/T/](https://lore.kernel.org/linux-fsdevel/20240228160213.1988854-1-mszeredi@redhat.com/T/) |
|||
|
|||
Over the years some users have reported that while exporting mergerfs |
|||
via NFS, after significant filesystem activity, not only will the NFS |
|||
client start returning ESTALE and EIO errors but mergerfs itself would |
|||
start returning EIO errors. The problem was that no one could |
|||
reliability reproduce the issue. After a string of reports in late |
|||
2023 and early 2024 more investigation was done. |
|||
|
|||
In Linux 5.14 new validation was put into FUSE which caught a few |
|||
invalid situations and would tag a FUSE node as invalid if a check |
|||
failed. Such checks include invalid file type, changing of type from |
|||
one request to another, a size greater than 63bit, and the generation |
|||
of a inode changing while in use. |
|||
|
|||
What happened was that mergerfs was using a different fixed, non-zero |
|||
value for the generation of all nodes as it was suggested that unique |
|||
inode + generation pairs are needed for proper integration with |
|||
NFS. That non-zero value was being sent back to the kernel when a |
|||
lookup request was made for root. The reason this was hard to track |
|||
down was because NFS almost uniquely uses an API which can lead to a |
|||
lookup of the root node that simply won't happen under normal |
|||
workloads and usage. And that lookup will only happen if child nodes |
|||
of the root were forgotten but NFS still had a handle to that node and |
|||
later asked for details about it. It would trigger a set of requests |
|||
to lookup info on those nodes. |
|||
|
|||
This wasn't a bug in FUSE but mergerfs. However, the incorrect |
|||
behavior of mergerfs lead to FUSE behave in an unexpected and |
|||
incorrect manner. It would issue a lookup of the "parent of a child of |
|||
the root" and mergerfs would send the invalid generation value. As a |
|||
result the kernel would mark the root node as "bad" which would then |
|||
trigger the kernel to issue a "forget root" message. In between those |
|||
it would issue a request for the parent of the root... which doesn't |
|||
exist. |
|||
|
|||
So the kernel was doing two invalid things. Requesting the parent of |
|||
the root and then when that failed issuing a forget for the |
|||
root. These led to chasing after the wrong possible causes. |
|||
|
|||
The change was for FUSE to revert the marking of root node bad if the |
|||
generation is non-zero and warn about it. It will mark the node bad |
|||
but not unhash/forget/remove it. |
|||
|
|||
mergerfs in v2.40.1 ensures that generation for root is always 0 on |
|||
lookup which should work across any kernel version. |
|||
|
|||
|
|||
### Truncated files |
|||
|
|||
This was a bug with `mmap` and `FUSE` on 32bit platforms. Should be fixed in all LTS releases. |
|||
|
|||
* [https://marc.info/?l=linux-fsdevel&m=155550785230874&w=2](https://marc.info/?l=linux-fsdevel&m=155550785230874&w=2) |
|||
|
|||
|
|||
### Crashing on OpenVZ |
|||
|
|||
There was a bug in the OpenVZ kernel with regard to how it handles `ioctl` calls. It was making invalid requests which would lead to crashes due to mergerfs not expecting them. |
|||
|
|||
* [https://bugs.openvz.org/browse/OVZ-7145](https://bugs.openvz.org/browse/OVZ-7145) |
|||
* [https://www.mail-archive.com/devel@openvz.org/msg37096.html](https://www.mail-archive.com/devel@openvz.org/msg37096.html) |
|||
|
|||
|
|||
### Really bad mmap performance |
|||
|
|||
There was a bug in caching which affects overall performance of `mmap` through `FUSE` in Linux 4.x kernels. It is fixed in 4.4.10 and 4.5.4. |
|||
|
|||
* [https://lkml.org/lkml/2016/3/16/260](https://lkml.org/lkml/2016/3/16/260) |
|||
* [https://lkml.org/lkml/2016/5/11/59](https://lkml.org/lkml/2016/5/11/59) |
|||
|
|||
|
|||
### Heavy load and memory pressure leads to kernel panic |
|||
|
|||
* [https://lkml.org/lkml/2016/9/14/527](https://lkml.org/lkml/2016/9/14/527) |
|||
* [https://lkml.org/lkml/2016/10/4/1](https://lkml.org/lkml/2016/10/4/1) |
|||
* [https://www.theregister.com/2016/10/05/linus_torvalds_admits_buggy_crap_made_it_into_linux_48/](https://www.theregister.com/2016/10/05/linus_torvalds_admits_buggy_crap_made_it_into_linux_48/) |
@ -1,4 +1,4 @@ |
|||
# Featured Media and Publicity |
|||
# Media and Publicity |
|||
|
|||
## Tutorials / Articles |
|||
|
@ -1,54 +0,0 @@ |
|||
# BASIC SETUP |
|||
|
|||
If you don't already know that you have a special use case then just |
|||
start with one of the following option sets. |
|||
|
|||
#### You need `mmap` (used by rtorrent and many sqlite3 base software) |
|||
|
|||
`cache.files=auto-full,dropcacheonclose=true,category.create=mfs` |
|||
|
|||
or if you are on a Linux kernel >= 6.6.x mergerfs will enable a mode |
|||
that allows shared mmap when `cache.files=off`. To be sure of the best |
|||
performance between `cache.files=off` and `cache.files=auto-full` |
|||
you'll need to do your own benchmarking but often `off` is faster. |
|||
|
|||
#### You don't need `mmap` |
|||
|
|||
`cache.files=off,dropcacheonclose=true,category.create=mfs` |
|||
|
|||
### Command Line |
|||
|
|||
`mergerfs -o cache.files=auto-full,dropcacheonclose=true,category.create=mfs /mnt/hdd0:/mnt/hdd1 /media` |
|||
|
|||
### /etc/fstab |
|||
|
|||
`/mnt/hdd0:/mnt/hdd1 /media mergerfs cache.files=auto-full,dropcacheonclose=true,category.create=mfs 0 0` |
|||
|
|||
### systemd mount |
|||
|
|||
https://github.com/trapexit/mergerfs/wiki/systemd |
|||
|
|||
``` |
|||
[Unit] |
|||
Description=mergerfs service |
|||
|
|||
[Service] |
|||
Type=simple |
|||
KillMode=none |
|||
ExecStart=/usr/bin/mergerfs \ |
|||
-f \ |
|||
-o cache.files=auto-full \ |
|||
-o dropcacheonclose=true \ |
|||
-o category.create=mfs \ |
|||
/mnt/hdd0:/mnt/hdd1 \ |
|||
/media |
|||
ExecStop=/bin/fusermount -uz /media |
|||
Restart=on-failure |
|||
|
|||
[Install] |
|||
WantedBy=default.target |
|||
``` |
|||
|
|||
See the mergerfs [wiki for real world |
|||
deployments](https://github.com/trapexit/mergerfs/wiki/Real-World-Deployments) |
|||
for comparisons / ideas. |
@ -1,213 +0,0 @@ |
|||
# CACHING |
|||
|
|||
#### page caching |
|||
|
|||
https://en.wikipedia.org/wiki/Page_cache |
|||
|
|||
- cache.files=off: Disables page caching. Underlying files cached, |
|||
mergerfs files are not. |
|||
- cache.files=partial: Enables page caching. Underlying files cached, |
|||
mergerfs files cached while open. |
|||
- cache.files=full: Enables page caching. Underlying files cached, |
|||
mergerfs files cached across opens. |
|||
- cache.files=auto-full: Enables page caching. Underlying files |
|||
cached, mergerfs files cached across opens if mtime and size are |
|||
unchanged since previous open. |
|||
- cache.files=libfuse: follow traditional libfuse `direct_io`, |
|||
`kernel_cache`, and `auto_cache` arguments. |
|||
- cache.files=per-process: Enable page caching (equivalent to |
|||
`cache.files=partial`) only for processes whose 'comm' name matches |
|||
one of the values defined in `cache.files.process-names`. If the |
|||
name does not match the file open is equivalent to |
|||
`cache.files=off`. |
|||
|
|||
FUSE, which mergerfs uses, offers a number of page caching modes. mergerfs tries to simplify their use via the `cache.files` |
|||
option. It can and should replace usage of `direct_io`, |
|||
`kernel_cache`, and `auto_cache`. |
|||
|
|||
Due to mergerfs using FUSE and therefore being a userland process |
|||
proxying existing filesystems the kernel will double cache the content |
|||
being read and written through mergerfs. Once from the underlying |
|||
filesystem and once from mergerfs (it sees them as two separate |
|||
entities). Using `cache.files=off` will keep the double caching from |
|||
happening by disabling caching of mergerfs but this has the side |
|||
effect that _all_ read and write calls will be passed to mergerfs |
|||
which may be slower than enabling caching, you lose shared `mmap` |
|||
support which can affect apps such as rtorrent, and no read-ahead will |
|||
take place. The kernel will still cache the underlying filesystem data |
|||
but that only helps so much given mergerfs will still process all |
|||
requests. |
|||
|
|||
If you do enable file page caching, |
|||
`cache.files=partial|full|auto-full`, you should also enable |
|||
`dropcacheonclose` which will cause mergerfs to instruct the kernel to |
|||
flush the underlying file's page cache when the file is closed. This |
|||
behavior is the same as the rsync fadvise / drop cache patch and Feh's |
|||
nocache project. |
|||
|
|||
If most files are read once through and closed (like media) it is best |
|||
to enable `dropcacheonclose` regardless of caching mode in order to |
|||
minimize buffer bloat. |
|||
|
|||
It is difficult to balance memory usage, cache bloat & duplication, |
|||
and performance. Ideally, mergerfs would be able to disable caching for |
|||
the files it reads/writes but allow page caching for itself. That |
|||
would limit the FUSE overhead. However, there isn't a good way to |
|||
achieve this. It would need to open all files with O_DIRECT which |
|||
places limitations on what the underlying filesystems would be |
|||
supported and complicates the code. |
|||
|
|||
kernel documentation: https://www.kernel.org/doc/Documentation/filesystems/fuse-io.txt |
|||
|
|||
#### entry & attribute caching |
|||
|
|||
Given the relatively high cost of FUSE due to the kernel <-> userspace |
|||
round trips there are kernel side caches for file entries and |
|||
attributes. The entry cache limits the `lookup` calls to mergerfs |
|||
which ask if a file exists. The attribute cache limits the need to |
|||
make `getattr` calls to mergerfs which provide file attributes (mode, |
|||
size, type, etc.). As with the page cache these should not be used if |
|||
the underlying filesystems are being manipulated at the same time as |
|||
it could lead to odd behavior or data corruption. The options for |
|||
setting these are `cache.entry` and `cache.negative_entry` for the |
|||
entry cache and `cache.attr` for the attributes |
|||
cache. `cache.negative_entry` refers to the timeout for negative |
|||
responses to lookups (non-existent files). |
|||
|
|||
#### writeback caching |
|||
|
|||
When `cache.files` is enabled the default is for it to perform |
|||
writethrough caching. This behavior won't help improve performance as |
|||
each write still goes one for one through the filesystem. By enabling |
|||
the FUSE writeback cache small writes may be aggregated by the kernel |
|||
and then sent to mergerfs as one larger request. This can greatly |
|||
improve the throughput for apps which write to files |
|||
inefficiently. The amount the kernel can aggregate is limited by the |
|||
size of a FUSE message. Read the `fuse_msg_size` section for more |
|||
details. |
|||
|
|||
There is a small side effect as a result of enabling writeback |
|||
caching. Underlying files won't ever be opened with O_APPEND or |
|||
O_WRONLY. The former because the kernel then manages append mode and |
|||
the latter because the kernel may request file data from mergerfs to |
|||
populate the write cache. The O_APPEND change means that if a file is |
|||
changed outside of mergerfs it could lead to corruption as the kernel |
|||
won't know the end of the file has changed. That said any time you use |
|||
caching you should keep from using the same file outside of mergerfs |
|||
at the same time. |
|||
|
|||
Note that if an application is properly sizing writes then writeback |
|||
caching will have little or no effect. It will only help with writes |
|||
of sizes below the FUSE message size (128K on older kernels, 1M on |
|||
newer). |
|||
|
|||
#### statfs caching |
|||
|
|||
Of the syscalls used by mergerfs in policies the `statfs` / `statvfs` |
|||
call is perhaps the most expensive. It's used to find out the |
|||
available space of a filesystem and whether it is mounted |
|||
read-only. Depending on the setup and usage pattern these queries can |
|||
be relatively costly. When `cache.statfs` is enabled all calls to |
|||
`statfs` by a policy will be cached for the number of seconds its set |
|||
to. |
|||
|
|||
Example: If the create policy is `mfs` and the timeout is 60 then for |
|||
that 60 seconds the same filesystem will be returned as the target for |
|||
creates because the available space won't be updated for that time. |
|||
|
|||
#### symlink caching |
|||
|
|||
As of version 4.20 Linux supports symlink caching. Significant |
|||
performance increases can be had in workloads which use a lot of |
|||
symlinks. Setting `cache.symlinks=true` will result in requesting |
|||
symlink caching from the kernel only if supported. As a result it's |
|||
safe to enable it on systems prior to 4.20. That said it is disabled |
|||
by default for now. You can see if caching is enabled by querying the |
|||
xattr `user.mergerfs.cache.symlinks` but given it must be requested at |
|||
startup you can not change it at runtime. |
|||
|
|||
#### readdir caching |
|||
|
|||
As of version 4.20 Linux supports readdir caching. This can have a |
|||
significant impact on directory traversal. Especially when combined |
|||
with entry (`cache.entry`) and attribute (`cache.attr`) |
|||
caching. Setting `cache.readdir=true` will result in requesting |
|||
readdir caching from the kernel on each `opendir`. If the kernel |
|||
doesn't support readdir caching setting the option to `true` has no |
|||
effect. This option is configurable at runtime via xattr |
|||
`user.mergerfs.cache.readdir`. |
|||
|
|||
#### tiered caching |
|||
|
|||
Some storage technologies support what some call "tiered" caching. The |
|||
placing of usually smaller, faster storage as a transparent cache to |
|||
larger, slower storage. NVMe, SSD, Optane in front of traditional HDDs |
|||
for instance. |
|||
|
|||
mergerfs does not natively support any sort of tiered caching. Most |
|||
users have no use for such a feature and its inclusion would |
|||
complicate the code. However, there are a few situations where a cache |
|||
filesystem could help with a typical mergerfs setup. |
|||
|
|||
1. Fast network, slow filesystems, many readers: You've a 10+Gbps network |
|||
with many readers and your regular filesystems can't keep up. |
|||
2. Fast network, slow filesystems, small'ish bursty writes: You have a |
|||
10+Gbps network and wish to transfer amounts of data less than your |
|||
cache filesystem but wish to do so quickly. |
|||
|
|||
With #1 it's arguable if you should be using mergerfs at all. RAID |
|||
would probably be the better solution. If you're going to use mergerfs |
|||
there are other tactics that may help: spreading the data across |
|||
filesystems (see the mergerfs.dup tool) and setting `func.open=rand`, |
|||
using `symlinkify`, or using dm-cache or a similar technology to add |
|||
tiered cache to the underlying device. |
|||
|
|||
With #2 one could use dm-cache as well but there is another solution |
|||
which requires only mergerfs and a cronjob. |
|||
|
|||
1. Create 2 mergerfs pools. One which includes just the slow devices |
|||
and one which has both the fast devices (SSD,NVME,etc.) and slow |
|||
devices. |
|||
2. The 'cache' pool should have the cache filesystems listed first. |
|||
3. The best `create` policies to use for the 'cache' pool would |
|||
probably be `ff`, `epff`, `lfs`, or `eplfs`. The latter two under |
|||
the assumption that the cache filesystem(s) are far smaller than the |
|||
backing filesystems. If using path preserving policies remember that |
|||
you'll need to manually create the core directories of those paths |
|||
you wish to be cached. Be sure the permissions are in sync. Use |
|||
`mergerfs.fsck` to check / correct them. You could also set the |
|||
slow filesystems mode to `NC` though that'd mean if the cache |
|||
filesystems fill you'd get "out of space" errors. |
|||
4. Enable `moveonenospc` and set `minfreespace` appropriately. To make |
|||
sure there is enough room on the "slow" pool you might want to set |
|||
`minfreespace` to at least as large as the size of the largest |
|||
cache filesystem if not larger. This way in the worst case the |
|||
whole of the cache filesystem(s) can be moved to the other drives. |
|||
5. Set your programs to use the cache pool. |
|||
6. Save one of the below scripts or create you're own. |
|||
7. Use `cron` (as root) to schedule the command at whatever frequency |
|||
is appropriate for your workflow. |
|||
|
|||
##### time based expiring |
|||
|
|||
Move files from cache to backing pool based only on the last time the |
|||
file was accessed. Replace `-atime` with `-amin` if you want minutes |
|||
rather than days. May want to use the `fadvise` / `--drop-cache` |
|||
version of rsync or run rsync with the tool "nocache". |
|||
|
|||
_NOTE:_ The arguments to these scripts include the cache |
|||
**filesystem** itself. Not the pool with the cache filesystem. You |
|||
could have data loss if the source is the cache pool. |
|||
|
|||
[mergerfs.time-based-mover](https://raw.githubusercontent.com/trapexit/mergerfs/refs/heads/latest-release/tools/mergerfs.time-based-mover) |
|||
|
|||
##### percentage full expiring |
|||
|
|||
Move the oldest file from the cache to the backing pool. Continue till |
|||
below percentage threshold. |
|||
|
|||
_NOTE:_ The arguments to these scripts include the cache |
|||
**filesystem** itself. Not the pool with the cache filesystem. You |
|||
could have data loss if the source is the cache pool. |
|||
|
|||
[mergerfs.percent-full-mover](https://raw.githubusercontent.com/trapexit/mergerfs/refs/heads/latest-release/tools/mergerfs.percent-full-mover) |
@ -1,35 +0,0 @@ |
|||
# HOW IT WORKS |
|||
|
|||
mergerfs logically merges multiple paths together. Think a union of |
|||
sets. The file/s or directory/s acted on or presented through mergerfs |
|||
are based on the policy chosen for that particular action. Read more |
|||
about policies below. |
|||
|
|||
``` |
|||
A + B = C |
|||
/disk1 /disk2 /merged |
|||
| | | |
|||
+-- /dir1 +-- /dir1 +-- /dir1 |
|||
| | | | | | |
|||
| +-- file1 | +-- file2 | +-- file1 |
|||
| | +-- file3 | +-- file2 |
|||
+-- /dir2 | | +-- file3 |
|||
| | +-- /dir3 | |
|||
| +-- file4 | +-- /dir2 |
|||
| +-- file5 | | |
|||
+-- file6 | +-- file4 |
|||
| |
|||
+-- /dir3 |
|||
| | |
|||
| +-- file5 |
|||
| |
|||
+-- file6 |
|||
``` |
|||
|
|||
mergerfs does **not** support the copy-on-write (CoW) or whiteout |
|||
behaviors found in **aufs** and **overlayfs**. You can **not** mount a |
|||
read-only filesystem and write to it. However, mergerfs will ignore |
|||
read-only filesystems when creating new files so you can mix |
|||
read-write and read-only filesystems. It also does **not** split data |
|||
across filesystems. It is not RAID0 / striping. It is simply a union of |
|||
other filesystems. |
@ -1,195 +0,0 @@ |
|||
# KNOWN ISSUES / BUGS |
|||
|
|||
#### kernel issues & bugs |
|||
|
|||
[https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs](https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs) |
|||
|
|||
#### directory mtime is not being updated |
|||
|
|||
Remember that the default policy for `getattr` is `ff`. The |
|||
information for the first directory found will be returned. If it |
|||
wasn't the directory which had been updated then it will appear |
|||
outdated. |
|||
|
|||
The reason this is the default is because any other policy would be |
|||
more expensive and for many applications it is unnecessary. To always |
|||
return the directory with the most recent mtime or a faked value based |
|||
on all found would require a scan of all filesystems. |
|||
|
|||
If you always want the directory information from the one with the |
|||
most recent mtime then use the `newest` policy for `getattr`. |
|||
|
|||
#### 'mv /mnt/pool/foo /mnt/disk1/foo' removes 'foo' |
|||
|
|||
This is not a bug. |
|||
|
|||
Run in verbose mode to better understand what's happening: |
|||
|
|||
``` |
|||
$ mv -v /mnt/pool/foo /mnt/disk1/foo |
|||
copied '/mnt/pool/foo' -> '/mnt/disk1/foo' |
|||
removed '/mnt/pool/foo' |
|||
$ ls /mnt/pool/foo |
|||
ls: cannot access '/mnt/pool/foo': No such file or directory |
|||
``` |
|||
|
|||
`mv`, when working across devices, is copying the source to target and |
|||
then removing the source. Since the source **is** the target in this |
|||
case, depending on the unlink policy, it will remove the just copied |
|||
file and other files across the branches. |
|||
|
|||
If you want to move files to one filesystem just copy them there and |
|||
use mergerfs.dedup to clean up the old paths or manually remove them |
|||
from the branches directly. |
|||
|
|||
#### cached memory appears greater than it should be |
|||
|
|||
Use `cache.files=off` and/or `dropcacheonclose=true`. See the section |
|||
on page caching. |
|||
|
|||
#### NFS clients returning ESTALE / Stale file handle |
|||
|
|||
NFS generally does not like out of band changes. Take a look at the |
|||
section on NFS in the [remote-filesystems](remote_filesystems.md) for |
|||
more details. |
|||
|
|||
#### rtorrent fails with ENODEV (No such device) |
|||
|
|||
Be sure to set |
|||
`cache.files=partial|full|auto-full|per-processe`. rtorrent and some |
|||
other applications use [mmap](http://linux.die.net/man/2/mmap) to read |
|||
and write to files and offer no fallback to traditional methods. FUSE |
|||
does not currently support mmap while using `direct_io`. There may be |
|||
a performance penalty on writes with `direct_io` off as well as the |
|||
problem of double caching but it's the only way to get such |
|||
applications to work. If the performance loss is too high for other |
|||
apps you can mount mergerfs twice. Once with `direct_io` enabled and |
|||
one without it. Be sure to set `dropcacheonclose=true` if not using |
|||
`direct_io`. |
|||
|
|||
#### Plex doesn't work with mergerfs |
|||
|
|||
It does. If you're trying to put Plex's config / metadata / database |
|||
on mergerfs you can't set `cache.files=off` because Plex is using |
|||
sqlite3 with mmap enabled. Shared mmap is not supported by Linux's |
|||
FUSE implementation when page caching is disabled. To fix this place |
|||
the data elsewhere (preferable) or enable `cache.files` (with |
|||
`dropcacheonclose=true`). Sqlite3 does not need mmap but the developer |
|||
needs to fall back to standard IO if mmap fails. |
|||
|
|||
This applies to other software: Radarr, Sonarr, Lidarr, Jellyfin, etc. |
|||
|
|||
I would recommend reaching out to the developers of the software |
|||
you're having troubles with and asking them to add a fallback to |
|||
regular file IO when mmap is unavailable. |
|||
|
|||
If the issue is that scanning doesn't seem to pick up media then be |
|||
sure to set `func.getattr=newest`, though generally, a full scan will |
|||
pick up all media anyway. |
|||
|
|||
#### When a program tries to move or rename a file it fails |
|||
|
|||
Please read the section above regarding [rename and link](functions_categories_and_policies.md#rename-and-link). |
|||
|
|||
The problem is that many applications do not properly handle `EXDEV` |
|||
errors which `rename` and `link` may return even though they are |
|||
perfectly valid situations which do not indicate actual device, |
|||
filesystem, or OS errors. The error will only be returned by mergerfs |
|||
if using a path preserving policy as described in the policy section |
|||
above. If you do not care about path preservation simply change the |
|||
mergerfs policy to the non-path preserving version. For example: `-o |
|||
category.create=mfs` Ideally the offending software would be fixed and |
|||
it is recommended that if you run into this problem you contact the |
|||
software's author and request proper handling of `EXDEV` errors. |
|||
|
|||
#### my 32bit software has problems |
|||
|
|||
Some software have problems with 64bit inode values. The symptoms can |
|||
include EOVERFLOW errors when trying to list files. You can address |
|||
this by setting `inodecalc` to one of the 32bit based algos as |
|||
described in the relevant section. |
|||
|
|||
#### Samba: Moving files / directories fails |
|||
|
|||
Workaround: Copy the file/directory and then remove the original |
|||
rather than move. |
|||
|
|||
This isn't an issue with Samba but some SMB clients. GVFS-fuse v1.20.3 |
|||
and prior (found in Ubuntu 14.04 among others) failed to handle |
|||
certain error codes correctly. Particularly **STATUS_NOT_SAME_DEVICE** |
|||
which comes from the **EXDEV** which is returned by **rename** when |
|||
the call is crossing mount points. When a program gets an **EXDEV** it |
|||
needs to explicitly take an alternate action to accomplish its |
|||
goal. In the case of **mv** or similar it tries **rename** and on |
|||
**EXDEV** falls back to a manual copying of data between the two |
|||
locations and unlinking the source. In these older versions of |
|||
GVFS-fuse if it received **EXDEV** it would translate that into |
|||
**EIO**. This would cause **mv** or most any application attempting to |
|||
move files around on that SMB share to fail with a IO error. |
|||
|
|||
[GVFS-fuse v1.22.0](https://bugzilla.gnome.org/show_bug.cgi?id=734568) |
|||
and above fixed this issue but a large number of systems use the older |
|||
release. On Ubuntu, the version can be checked by issuing `apt-cache |
|||
showpkg gvfs-fuse`. Most distros released in 2015 seem to have the |
|||
updated release and will work fine but older systems may |
|||
not. Upgrading gvfs-fuse or the distro in general will address the |
|||
problem. |
|||
|
|||
In Apple's MacOSX 10.9 they replaced Samba (client and server) with |
|||
their own product. It appears their new client does not handle |
|||
**EXDEV** either and responds similarly to older releases of gvfs on |
|||
Linux. |
|||
|
|||
#### Trashing files occasionally fails |
|||
|
|||
This is the same issue as with Samba. `rename` returns `EXDEV` (in our |
|||
case that will really only happen with path preserving policies like |
|||
`epmfs`) and the software doesn't handle the situation well. This is |
|||
unfortunately a common failure of software which moves files |
|||
around. The standard indicates that an implementation `MAY` choose to |
|||
support non-user home directory trashing of files (which is a |
|||
`MUST`). The implementation `MAY` also support "top directory trashes" |
|||
which many probably do. |
|||
|
|||
To create a `$topdir/.Trash` directory as defined in the standard use |
|||
the [mergerfs-tools](https://github.com/trapexit/mergerfs-tools) tool |
|||
`mergerfs.mktrash`. |
|||
|
|||
#### Supplemental user groups |
|||
|
|||
Due to the overhead of |
|||
[getgroups/setgroups](http://linux.die.net/man/2/setgroups) mergerfs |
|||
utilizes a cache. This cache is opportunistic and per thread. Each |
|||
thread will query the supplemental groups for a user when that |
|||
particular thread needs to change credentials and will keep that data |
|||
for the lifetime of the thread. This means that if a user is added to |
|||
a group it may not be picked up without the restart of |
|||
mergerfs. However, since the high level FUSE API's (at least the |
|||
standard version) thread pool dynamically grows and shrinks it's |
|||
possible that over time a thread will be killed and later a new thread |
|||
with no cache will start and query the new data. |
|||
|
|||
The gid cache uses fixed storage to simplify the design and be |
|||
compatible with older systems which may not have C++11 |
|||
compilers. There is enough storage for 256 users' supplemental |
|||
groups. Each user is allowed up to 32 supplemental groups. Linux >= |
|||
2.6.3 allows up to 65535 groups per user but most other \*nixs allow |
|||
far less. NFS allows only 16. The system does handle overflow |
|||
gracefully. If the user has more than 32 supplemental groups only the |
|||
first 32 will be used. If more than 256 users are using the system |
|||
when an uncached user is found it will evict an existing user's cache |
|||
at random. So long as there aren't more than 256 active users this |
|||
should be fine. If either value is too low for your needs you will |
|||
have to modify `gidcache.hpp` to increase the values. Note that doing |
|||
so will increase the memory needed by each thread. |
|||
|
|||
While not a bug some users have found when using containers that |
|||
supplemental groups defined inside the container don't work properly |
|||
with regard to permissions. This is expected as mergerfs lives outside |
|||
the container and therefore is querying the host's group |
|||
database. There might be a hack to work around this (make mergerfs |
|||
read the /etc/group file in the container) but it is not yet |
|||
implemented and would be limited to Linux and the /etc/group |
|||
DB. Preferably users would mount in the host group file into the |
|||
containers or use a standard shared user & groups technology like NIS |
|||
or LDAP. |
@ -1,8 +0,0 @@ |
|||
# LINKS |
|||
|
|||
- https://spawn.link |
|||
- https://github.com/trapexit/mergerfs |
|||
- https://github.com/trapexit/mergerfs/wiki |
|||
- https://github.com/trapexit/mergerfs-tools |
|||
- https://github.com/trapexit/scorch |
|||
- https://github.com/trapexit/bbf |
@ -1,39 +0,0 @@ |
|||
# PERFORMANCE |
|||
|
|||
mergerfs is at its core just a proxy and therefore its theoretical max |
|||
performance is that of the underlying devices. However, given it is a |
|||
FUSE filesystem working from userspace there is an increase in |
|||
overhead relative to kernel based solutions. That said the performance |
|||
can match the theoretical max but it depends greatly on the system's |
|||
configuration. Especially when adding network filesystems into the mix |
|||
there are many variables which can impact performance. Device speeds |
|||
and latency, network speeds and latency, general concurrency, |
|||
read/write sizes, etc. Unfortunately, given the number of variables it |
|||
has been difficult to find a single set of settings which provide |
|||
optimal performance. If you're having performance issues please look |
|||
over the suggestions below (including the benchmarking section.) |
|||
|
|||
NOTE: be sure to read about these features before changing them to |
|||
understand what behaviors it may impact |
|||
|
|||
- disable `security_capability` and/or `xattr` |
|||
- increase cache timeouts `cache.attr`, `cache.entry`, `cache.negative_entry` |
|||
- enable (or disable) page caching (`cache.files`) |
|||
- enable `parallel-direct-writes` |
|||
- enable `cache.writeback` |
|||
- enable `cache.statfs` |
|||
- enable `cache.symlinks` |
|||
- enable `cache.readdir` |
|||
- change the number of worker threads |
|||
- disable `posix_acl` |
|||
- disable `async_read` |
|||
- test theoretical performance using `nullrw` or mounting a ram disk |
|||
- use `symlinkify` if your data is largely static and read-only |
|||
- use tiered cache devices |
|||
- use LVM and LVM cache to place a SSD in front of your HDDs |
|||
- increase readahead: `readahead=1024` |
|||
|
|||
If you come across a setting that significantly impacts performance |
|||
please contact trapexit so he may investigate further. Please test |
|||
both against your normal setup, a singular branch, and with |
|||
`nullrw=true` |
@ -1,65 +0,0 @@ |
|||
# SUPPORT |
|||
|
|||
Filesystems are complex and difficult to debug. mergerfs, while being |
|||
just a proxy of sorts, can be difficult to debug given the large |
|||
number of possible settings it can have itself and the number of |
|||
environments it can run in. When reporting on a suspected issue |
|||
**please** include as much of the below information as possible |
|||
otherwise it will be difficult or impossible to diagnose. Also please |
|||
read the above documentation as it provides details on many previously |
|||
encountered questions/issues. |
|||
|
|||
**Please make sure you are using the [latest |
|||
release](https://github.com/trapexit/mergerfs/releases) or have tried |
|||
it in comparison. Old versions, which are often included in distros |
|||
like Debian and Ubuntu, are not ever going to be updated and the issue |
|||
you are encountering may have been addressed already.** |
|||
|
|||
**For commercial support or feature requests please [contact me |
|||
directly.](mailto:support@spawn.link)** |
|||
|
|||
#### Information to include in bug reports |
|||
|
|||
- [Information about the broader problem along with any attempted |
|||
solutions.](https://xyproblem.info) |
|||
- Solution already ruled out and why. |
|||
- Version of mergerfs: `mergerfs --version` |
|||
- mergerfs settings / arguments: from fstab, systemd unit, command |
|||
line, OMV plugin, etc. |
|||
- Version of the OS: `uname -a` and `lsb_release -a` |
|||
- List of branches, their filesystem types, sizes (before and after issue): `df -h` |
|||
- **All** information about the relevant paths and files: permissions, ownership, etc. |
|||
- **All** information about the client app making the requests: version, uid/gid |
|||
- Runtime environment: |
|||
- Is mergerfs running within a container? |
|||
- Are the client apps using mergerfs running in a container? |
|||
- A `strace` of the app having problems: |
|||
- `strace -fvTtt -s 256 -o /tmp/app.strace.txt <cmd>` |
|||
- A `strace` of mergerfs while the program is trying to do whatever it is failing to do: |
|||
- `strace -fvTtt -s 256 -p <mergerfsPID> -o /tmp/mergerfs.strace.txt` |
|||
- **Precise** directions on replicating the issue. Do not leave **anything** out. |
|||
- Try to recreate the problem in the simplest way using standard programs: `ln`, `mv`, `cp`, `ls`, `dd`, etc. |
|||
|
|||
#### Contact / Issue submission |
|||
|
|||
- github.com: https://github.com/trapexit/mergerfs/issues |
|||
- discord: https://discord.gg/MpAr69V |
|||
- reddit: https://www.reddit.com/r/mergerfs |
|||
|
|||
#### Donations |
|||
|
|||
https://github.com/trapexit/support |
|||
|
|||
Development and support of a project like mergerfs requires a |
|||
significant amount of time and effort. The software is released under |
|||
the very liberal ISC license and is therefore free to use for personal |
|||
or commercial uses. |
|||
|
|||
If you are a personal user and find mergerfs and its support valuable |
|||
and would like to support the project financially it would be very |
|||
much appreciated. |
|||
|
|||
If you are using mergerfs commercially please consider sponsoring the |
|||
project to ensure it continues to be maintained and receive |
|||
updates. If custom features are needed feel free to [contact me |
|||
directly](mailto:support@spawn.link). |
@ -1,9 +0,0 @@ |
|||
# TERMINOLOGY |
|||
|
|||
- branch: A base path used in the pool. |
|||
- pool: The mergerfs mount. The union of the branches. |
|||
- relative path: The path in the pool relative to the branch and mount. |
|||
- function: A filesystem call (open, unlink, create, getattr, rmdir, etc.) |
|||
- category: A collection of functions based on basic behavior (action, create, search). |
|||
- policy: The algorithm used to select a file when performing a function. |
|||
- path preservation: Aspect of some policies which includes checking the path for which a file would be created. |
@ -1,43 +0,0 @@ |
|||
# TIPS / NOTES |
|||
|
|||
- This document is literal and thorough. If a suspected feature isn't |
|||
mentioned it doesn't exist. If certain libfuse arguments aren't |
|||
listed they probably shouldn't be used. |
|||
- Ensure you're using the latest version. |
|||
- Run mergerfs as `root`. mergerfs is designed and intended to be run |
|||
as `root` and may exibit incorrect behavior if run otherwise.. |
|||
- If you don't see some directories and files you expect, policies |
|||
seem to skip branches, you get strange permission errors, etc. be |
|||
sure the underlying filesystems' permissions are all the same. Use |
|||
`mergerfs.fsck` to audit the filesystem for out of sync permissions. |
|||
- If you still have permission issues be sure you are using POSIX ACL |
|||
compliant filesystems. mergerfs doesn't generally make exceptions |
|||
for FAT, NTFS, or other non-POSIX filesystem. |
|||
- Do **not** use `cache.files=off` if you expect applications (such as |
|||
rtorrent) to use [mmap](http://linux.die.net/man/2/mmap) |
|||
files. Shared mmap is not currently supported in FUSE w/ page |
|||
caching disabled. Enabling `dropcacheonclose` is recommended when |
|||
`cache.files=partial|full|auto-full`. |
|||
- [Kodi](http://kodi.tv), [Plex](http://plex.tv), |
|||
[Subsonic](http://subsonic.org), etc. can use directory |
|||
[mtime](http://linux.die.net/man/2/stat) to more efficiently |
|||
determine whether to scan for new content rather than simply |
|||
performing a full scan. If using the default **getattr** policy of |
|||
**ff** it's possible those programs will miss an update on account |
|||
of it returning the first directory found's **stat** info and it's a |
|||
later directory on another mount which had the **mtime** recently |
|||
updated. To fix this you will want to set |
|||
**func.getattr=newest**. Remember though that this is just |
|||
**stat**. If the file is later **open**'ed or **unlink**'ed and the |
|||
policy is different for those then a completely different file or |
|||
directory could be acted on. |
|||
- Some policies mixed with some functions may result in strange |
|||
behaviors. Not that some of these behaviors and race conditions |
|||
couldn't happen outside **mergerfs** but that they are far more |
|||
likely to occur on account of the attempt to merge multiple sources |
|||
of data which could be out of sync due to the different policies. |
|||
- For consistency it's generally best to set **category** wide policies |
|||
rather than individual **func**'s. This will help limit the |
|||
confusion of tools such as |
|||
[rsync](http://linux.die.net/man/1/rsync). However, the flexibility |
|||
is there if needed. |
@ -1,64 +0,0 @@ |
|||
# General Information and Overview |
|||
|
|||
## How well does mergerfs scale? Is it "production ready?" |
|||
|
|||
Users have reported running mergerfs on everything from a Raspberry Pi |
|||
to dual socket Xeon systems with >20 cores. I'm aware of at least a |
|||
few companies which use mergerfs in production. [Open Media |
|||
Vault](https://www.openmediavault.org) includes mergerfs as its sole |
|||
solution for pooling filesystems. The author of mergerfs had it |
|||
running for over 300 days managing 16+ devices with reasonably heavy |
|||
24/7 read and write usage. Stopping only after the machine's power |
|||
supply died. |
|||
|
|||
Most serious issues (crashes or data corruption) have been due to |
|||
[kernel |
|||
bugs](https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs). All |
|||
of which are fixed in stable releases. |
|||
|
|||
## Why use FUSE? Why not a kernel based solution? |
|||
|
|||
As with any solution to a problem, there are advantages and |
|||
disadvantages to each one. |
|||
|
|||
A FUSE based solution has all the downsides of FUSE: |
|||
|
|||
- Higher IO latency due to the trips in and out of kernel space |
|||
- Higher general overhead due to trips in and out of kernel space |
|||
- Double caching when using page caching |
|||
- Misc limitations due to FUSE's design |
|||
|
|||
But FUSE also has a lot of upsides: |
|||
|
|||
- Easier to offer a cross platform solution |
|||
- Easier forward and backward compatibility |
|||
- Easier updates for users |
|||
- Easier and faster release cadence |
|||
- Allows more flexibility in design and features |
|||
- Overall easier to write, secure, and maintain |
|||
- Much lower barrier to entry (getting code into the kernel takes a |
|||
lot of time and effort initially) |
|||
|
|||
FUSE was chosen because of all the advantages listed above. The |
|||
negatives of FUSE do not outweigh the positives. |
|||
|
|||
## Is my OS's libfuse needed for mergerfs to work? |
|||
|
|||
No. Normally `mount.fuse` is needed to get mergerfs (or any FUSE |
|||
filesystem to mount using the `mount` command but in vendoring the |
|||
libfuse library the `mount.fuse` app has been renamed to |
|||
`mount.mergerfs` meaning the filesystem type in `fstab` can simply be |
|||
`mergerfs`. That said there should be no harm in having it installed |
|||
and continuing to using `fuse.mergerfs` as the type in `/etc/fstab`. |
|||
|
|||
If `mergerfs` doesn't work as a type it could be due to how the |
|||
`mount.mergerfs` tool was installed. Must be in `/sbin/` with proper |
|||
permissions. |
|||
|
|||
## Why was splice support removed? |
|||
|
|||
After a lot of testing over the years, splicing always appeared to |
|||
at best, provide equivalent performance, and in some cases, worse |
|||
performance. Splice is not supported on other platforms forcing a |
|||
traditional read/write fallback to be provided. The splice code was |
|||
removed to simplify the codebase. |
@ -1,148 +0,0 @@ |
|||
Originally from [Reddit](https://www.reddit.com/r/synology/comments/etz32q/instructions_on_how_to_install_mergerfs_on_a/). Copied and edited with permission. |
|||
|
|||
A different version to overcome some problems with the method below, can be [found here](https://web.archive.org/web/20221205205446/https://daniellemarco.nl/wp/2022/01/01/adding-mergerfs-to-your-synology/) |
|||
|
|||
Install Entware |
|||
|
|||
1. SSH into your NAS and switch to the root user: |
|||
|
|||
``` |
|||
sudo su |
|||
``` |
|||
|
|||
2. Create a folder on your hdd (outside rootfs): |
|||
|
|||
``` |
|||
mkdir -p /volume1/@Entware/opt |
|||
``` |
|||
|
|||
2. Remove `/opt` and mount optware folder. |
|||
|
|||
Make sure that `/opt` folder is empty (Optware is not installed), we will remove the `/opt` folder with its contents at this step. |
|||
|
|||
``` |
|||
rm -rf /opt |
|||
mkdir /opt |
|||
mount -o bind "/volume1/@Entware/opt" /opt |
|||
``` |
|||
|
|||
3. Run install script depending on the processor. Use command `uname -m` to find out. Then run the corresponding command. |
|||
|
|||
#### armv8 (aarch64) - Realtek RTD129x |
|||
|
|||
``` |
|||
wget -O - http://bin.entware.net/aarch64-k3.10/installer/generic.sh | /bin/sh |
|||
``` |
|||
|
|||
#### armv5 |
|||
|
|||
``` |
|||
wget -O - http://bin.entware.net/armv5sf-k3.2/installer/generic.sh | /bin/sh |
|||
``` |
|||
|
|||
#### armv7 |
|||
|
|||
``` |
|||
wget -O - http://bin.entware.net/armv7sf-k3.2/installer/generic.sh | /bin/sh |
|||
``` |
|||
|
|||
#### x64 |
|||
|
|||
``` |
|||
wget -O - http://bin.entware.net/x64-k3.2/installer/generic.sh | /bin/sh |
|||
``` |
|||
|
|||
4. Create an Autostart Task On Synology |
|||
|
|||
Create a triggered user-defined task in Task Scheduler. |
|||
|
|||
- Go to: DSM > Control Panel > Task Scheduler |
|||
- Create > Triggered Task > User Defined Script |
|||
- General |
|||
- Task: Entware |
|||
- User: root |
|||
- Event: Boot-up |
|||
- Pretask: none |
|||
- Task Settings |
|||
- Run Command: Paste the below script in. |
|||
|
|||
``` |
|||
#!/bin/sh |
|||
|
|||
# Mount/Start Entware |
|||
mkdir -p /opt |
|||
mount -o bind "/volume1/@Entware/opt" /opt |
|||
/opt/etc/init.d/rc.unslung start |
|||
|
|||
# Add Entware Profile in Global Profile |
|||
if grep -qF '/opt/etc/profile' /etc/profile; then |
|||
echo "Confirmed: Entware Profile in Global Profile" |
|||
else |
|||
echo "Adding: Entware Profile in Global Profile" |
|||
cat >> /etc/profile <<"EOF" |
|||
|
|||
# Load Entware Profile |
|||
[ -r "/opt/etc/profile" ] && . /opt/etc/profile |
|||
EOF |
|||
fi |
|||
|
|||
# Update Entware List |
|||
/opt/bin/opkg update |
|||
``` |
|||
|
|||
5. Reboot your NAS. |
|||
|
|||
6. SSH back into your NAS |
|||
|
|||
7. Install mergerfs by the following command. |
|||
|
|||
``` |
|||
sudo opkg install mergerfs |
|||
``` |
|||
|
|||
9. Make sure it's installed by running the following command. Mergerfs binary is expected to be listed there. |
|||
|
|||
``` |
|||
sudo ls /volume1/@Entware/opt/bin |
|||
``` |
|||
|
|||
This should print the usage helper of mergerfs. |
|||
|
|||
``` |
|||
mergerfs --help |
|||
``` |
|||
|
|||
10. If you want the latest build of mergerfs, you can download the `mergerfs-static-linux_$ARCH.tar.gz` from [Github releases page](https://github.com/trapexit/mergerfs/releases/latest), remember to replace `$ARCH` with your architecture, e.g. what `uname -m` tells you. |
|||
|
|||
Extract the `.tar.gz` archive and use its content to update the `mergerfs` and `mergerfs-fusermount` binaries in `/opt/bin/` |
|||
|
|||
11. Configure mergerfs. Note: Change the file paths to your setup. |
|||
|
|||
_MY CONFIG IS (Don't know if it is the perfect setting, but works in my testing) _ |
|||
|
|||
``` |
|||
mergerfs -o rw,use_ino,allow_other,func.getattr=newest,category.action=all,category.create=ff,dropcacheonclose=true /volume1/Media/TempMedia:/volume1/Media/GMedia /volume1/Media/FinalMedia |
|||
``` |
|||
|
|||
If mergerfs complains about existing files because the destination already has the Synology `@eaDir` directory, you can use the option `nonempty`. |
|||
|
|||
12. Create an Autostart Task On Synology for Mergerfs |
|||
|
|||
- Go to: DSM > Control Panel > Task Scheduler |
|||
- Create > Triggered Task > User Defined Script |
|||
- General |
|||
- Task: Mergerfs |
|||
- User: root |
|||
- Event: Boot-up |
|||
- Pretask: Entware |
|||
- Task Settings |
|||
- Run Command: Paste the below script in. |
|||
|
|||
``` |
|||
#!/bin/sh |
|||
|
|||
/opt/bin/mergerfs -o rw,use_ino,allow_other,func.getattr=newest,category.action=all,category.create=ff,dropcacheonclose=true /volume1/Media/TempMedia:/volume1/Media/GMedia /volume1/Media/FinalMedia |
|||
|
|||
``` |
|||
|
|||
13. Profit |
@ -1,45 +0,0 @@ |
|||
There have been a number of kernel issues / bugs over the years which mergerfs has run into. Here is a list of them for reference and posterity. |
|||
|
|||
## NFS and EIO errors |
|||
|
|||
https://lore.kernel.org/linux-fsdevel/20240228160213.1988854-1-mszeredi@redhat.com/T/ |
|||
|
|||
Over the years some users have reported that while exporting mergerfs via NFS, after significant filesystem activity, not only will the NFS client start returning ESTALE and EIO errors but mergerfs itself would start returning EIO errors. The problem was that no one could reliability reproduce the issue. After a string of reports in late 2023 and early 2024 more investigation was done. |
|||
|
|||
In Linux 5.14 new validation was put into FUSE which caught a few invalid situations and would tag a FUSE node as invalid if a check failed. Such checks include invalid file type, changing of type from one request to another, a size greater than 63bit, and the generation of a inode changing while in use. |
|||
|
|||
What happened was that mergerfs was using a different fixed, non-zero value for the generation of all nodes as it was suggested that unique inode + generation pairs are needed for proper integration with NFS. That non-zero value was being sent back to the kernel when a lookup request was made for root. The reason this was hard to track down was because NFS almost uniquely uses an API which can lead to a lookup of the root node that simply won't happen under normal workloads and usage. And that lookup will only happen if child nodes of the root were forgotten but NFS still had a handle to that node and later asked for details about it. It would trigger a set of requests to lookup info on those nodes. |
|||
|
|||
This wasn't a bug in FUSE but mergerfs. However, the incorrect behavior of mergerfs lead to FUSE behave in an unexpected and incorrect manner. It would issue a lookup of the "parent of a child of the root" and mergerfs would send the invalid generation value. As a result the kernel would mark the root node as "bad" which would then trigger the kernel to issue a "forget root" message. In between those it would issue a request for the parent of the root... which doesn't exist. |
|||
|
|||
So the kernel was doing two invalid things. Requesting the parent of the root and then when that failed issuing a forget for the root. These led to chasing after the wrong possible causes. |
|||
|
|||
The proposed change is for FUSE to revert the marking of root node bad if the generation is non-zero and warn about it. It will mark the node bad but not unhash/forget/remove it. |
|||
|
|||
mergerfs in v2.40.1 ensures that generation for root is always 0 on lookup which should work across any kernel version. |
|||
|
|||
## Truncated files |
|||
|
|||
This was a bug with mmap and FUSE on 32bit platforms. Should be fixed in all LTS releases. |
|||
|
|||
- https://marc.info/?l=linux-fsdevel&m=155550785230874&w=2 |
|||
|
|||
## Crashing on OpenVZ |
|||
|
|||
There is/was a bug in the OpenVZ kernel with regard to how it handles ioctl calls. It was making invalid requests which would lead to crashes due to mergerfs not expecting them. |
|||
|
|||
- https://bugs.openvz.org/browse/OVZ-7145 |
|||
- https://www.mail-archive.com/devel@openvz.org/msg37096.html |
|||
|
|||
## Really bad mmap performance |
|||
|
|||
There is/was a bug in caching which affects overall performance of mmap through FUSE in Linux 4.x kernels. It is fixed in 4.4.10 and 4.5.4. |
|||
|
|||
- https://lkml.org/lkml/2016/3/16/260 |
|||
- https://lkml.org/lkml/2016/5/11/59 |
|||
|
|||
## Heavy load and memory pressure leads to kernel panic |
|||
|
|||
- https://lkml.org/lkml/2016/9/14/527 |
|||
- https://lkml.org/lkml/2016/10/4/1 |
|||
- https://www.theregister.com/2016/10/05/linus_torvalds_admits_buggy_crap_made_it_into_linux_48/ |
@ -1,4 +0,0 @@ |
|||
# Links |
|||
|
|||
- [Another way installing MergerFS on Synology and overcoming problems](https://mjanssen.nl/2022/01/01/adding-mergerfs-to-your-synology/) |
|||
- [fstab](<https://github.com/trapexit/backup-and-recovery-howtos/blob/master/docs/setup_(fstab).md>) |
@ -1,34 +0,0 @@ |
|||
# Projects incorporating mergerfs directly in some way |
|||
|
|||
- [Lakka.tv](https://lakka.tv/): A turnkey software emulation Linux distribution. Used to pool user and local storage. Also includes my other project [Opera](https://retroarch.com/). A 3DO emulator. |
|||
- [OpenMediaVault](https://www.openmediavault.org): A network attached storage (NAS) solution based on Debian Linux. They provide plugins to manage mergerfs. |
|||
- [CasaOS](https://casaos.io): "A simple, easy to use, elegant open source home cloud system." Has added initial integration with mergerfs to create pools from existing filesystems. |
|||
- [ZimaOS](https://github.com/IceWhaleTech/zimaos-rauc): A more commercially focused NAS OS by the authors of CasaOS at [Ice Whale](https://www.zimaboard.com/). |
|||
|
|||
# Software and services commonly used with mergerfs |
|||
|
|||
- [snapraid](https://www.snapraid.it/) |
|||
- [rclone](https://rclone.org/) |
|||
- rclone's [union](https://rclone.org/union/) feature is based on mergerfs policies |
|||
- [ZFS](https://openzfs.org/): Common to use ZFS w/ mergerfs |
|||
- [UnRAID](https://unraid.net): While UnRAID has its own union filesystem it isn't uncommon to see UnRAID users leverage mergerfs given the differences in the technologies. |
|||
- For a time there were a number of Chia miners recommending mergerfs |
|||
- [cloudboxes.io](https://cloudboxes.io/wiki/how-to/apps/set-up-mergerfs-using-ssh) |
|||
|
|||
# Distributions including mergerfs |
|||
|
|||
mergerfs can be found in the [repositories](https://pkgs.org/download/mergerfs) of [many Linux](https://repology.org/project/mergerfs/versions) (and maybe FreeBSD) distributions. |
|||
|
|||
Note: Any non-rolling release based distro is likely to have out-of-date versions. |
|||
|
|||
- [Debian](https://packages.debian.org/bullseye/mergerfs) |
|||
- [Ubuntu](https://launchpad.net/ubuntu/+source/mergerfs) |
|||
- [Fedora](https://rpmsphere.github.io/) |
|||
- [T2](https://t2sde.org/packages/mergerfs) |
|||
- [Alpine](https://pkgs.alpinelinux.org/packages?name=mergerfs&branch=edge&repo=&arch=&maintainer=) |
|||
- [Gentoo](https://packages.gentoo.org/packages/sys-fs/mergerfs) |
|||
- [Arch (AUR)](https://aur.archlinux.org/packages/mergerfs) |
|||
- [Void](https://voidlinux.org/packages/?arch=x86_64&q=mergerfs) |
|||
- [NixOS](https://search.nixos.org/packages?channel=22.11&show=mergerfs&from=0&size=50&sort=relevance&type=packages&query=mergerfs) |
|||
- [Guix]() |
|||
- [Slackware](https://slackbuilds.org/repository/15.0/system/mergerfs/?search=mergerfs) |
@ -1,96 +0,0 @@ |
|||
# trapexit's (mergerfs' author) |
|||
|
|||
## Current setup |
|||
|
|||
- SilverStone Technology CS380B-X V2.0 case |
|||
- Intel Core i7-4790S |
|||
- 32GB DDR3 RAM |
|||
- LSI SAS 9201-16e |
|||
- 8 SATA connections to the CS380B backplane |
|||
- 8 SATA connections to a generic 8-bay enclosure (similar to a Sans Digital 8-bay enclosure) |
|||
- Connections via SAS to SATA breakout cables fished through the back. Not elegant but cost effective. SAS SCSI cutout boards are difficult to find and would add $50 to $100 to the cost. |
|||
- Marvell 88SE9230 PCIe SATA 6Gb/s Controller on motherboard |
|||
- 4 SATA connections to a [StarTech SATSASBP425](https://www.amazon.com/StarTech-com-4-Bay-Mobile-Backplane-Drives/dp/B00X7B3CUE) |
|||
- ASMedia ASM1062 SATA Controller on motherboard |
|||
- 4 SATA connections to a second [StarTech SATSASBP425](https://www.amazon.com/StarTech-com-4-Bay-Mobile-Backplane-Drives/dp/B00X7B3CUE) |
|||
- 1 MSATA connection on the motherboard |
|||
- NVidia Quadro P2000 (for hardware transcoding in Plex, Jellyfin, etc.) |
|||
- Mix of 3.5" SATA HDD: 8TB - 14TB |
|||
- Mix of 2.5" SATA HDD: 2TB - 5TB |
|||
- Mix of 2.5" SATA SSD: |
|||
- primary boot drive, backup boot drive, application specific caches |
|||
- Some of the SSDs are used enterprise drives which can often be found for a reasonable price on eBay |
|||
- Mix of 2.5" U.2 NVME: 3x 2TB Intel P4510, 1x 3.84TB Dell P5500 |
|||
- Connected via a [Ceacent ANU28PE16 NVMe SSD Riser SFF8643 to SFF8639](https://www.aliexpress.us/item/2255800570129198.html) |
|||
- Have a [IcyDock MB931U-1VB](https://www.icydock.com/goods.php?id=363) for using U.2 NVME drives externally |
|||
- All drives formatted with EXT4 to make recovery easier in case of failure |
|||
- `mkfs.ext4 -L DRIVE_SERIAL_NUMBER -m 0 /dev/DEV` |
|||
- HDDs, some SSDs, some NVMEs merged together in a single mergerfs mount |
|||
- branches-mount-timeout=300 |
|||
- cache.attr=120 |
|||
- cache.entry=120 |
|||
- cache.files=per-process |
|||
- cache.readdir=true |
|||
- cache.statfs=10 |
|||
- category.create=pfrd |
|||
- dropcacheonclose=true |
|||
- fsname=media |
|||
- lazy-umount-mountpoint=true |
|||
- link_cow=true |
|||
- readahead=2048 |
|||
- some SSDs/NVMes used for bespoke purposes such as main storage for Docker/container config storage and caching (Plex transcoding, etc.) |
|||
- Filesystem labels are set to the serial number of the drive for easy identification |
|||
- Drives mounted to: |
|||
- /mnt/hdd/SIZE-LABEL |
|||
- /mnt/sdd/SIZE-LABEL |
|||
- /mnt/nvme/SIZE-LABEL |
|||
- ex: /mnt/hdd/8TB-ABCDEF |
|||
- Total drives in main mergerfs pool: 24 |
|||
- Total storage combined in main mergerfs pool: 155TB |
|||
- RAM usage by mergerfs under load: 512MB - 1GB of resident memory |
|||
|
|||
## Old setup |
|||
|
|||
- Core i7 3770s |
|||
- 16GB RAM |
|||
- 4 Port ASMedia Technology 106x eSATA PCIE 4x card |
|||
- 4x [ICYCube MB561U3S-4SB R1 Quad Bay enclosure](https://www.icydock.com/goods.php?id=219) |
|||
|
|||
NOTES: The eSATA enclosure setup was easier to manage physically as the enclosures are smaller but the LSI SAS HBA & generic enclosure setup is more reliable/stable, more performant, and actually cost less. Port multipliers tend to behave poorly with different brand controllers (if they work at all). They can perform poorly if a drive is bad leading to the other drives acting as if they have issues leading to a full hard reset of the computer and enclosure to 'fix'. Port multiplier enclosures, over USB, tend not to support hot swapping and the drives will all be reset if a drive is swapped. |
|||
|
|||
--- |
|||
|
|||
# (´・ω・`) |
|||
|
|||
- 2x Intel(R) Xeon(R) CPU X5690 @ 3.47GHz |
|||
- 64G RAM |
|||
- Chassis: 847E16-R1K28LPB |
|||
- 36 bays + 2 sytem bays |
|||
- SAS2008 |
|||
- X8DTH |
|||
- Drives |
|||
- 26x 8TB Data |
|||
- luks |
|||
- btrfs: `mount -ospace_cache=v2,noatime,rw` |
|||
- 6x 8TB Parity |
|||
- luks |
|||
- ext4: `mkfs.ext4 -J size=4 -m 0 -i 67108864 -L <LABEL> <DEVICE>` |
|||
- Software |
|||
- `mergerfs` all data disks to a single root: `-o defaults,allow_other,category.create=msplfs,minfreespace=100G,use_ino,dropcacheonclose=true,ignorepponrename=true,moveonenospc=mspmfs` |
|||
- `snapraid` all drives and 6 parity |
|||
- `snapraid-btrfs` btrfs snapshots+snapraid |
|||
- Misc |
|||
- 1.2GB/s max with 2x SAS2 connections |
|||
- ~56-65 hours for full sync |
|||
- 1-4 hours on "small" changes |
|||
- a fuckton of reads against the hdds if you change too much |
|||
|
|||
Note: Buy good chassis with even better backplanes. The backplane 847E16-R1K28LPB uses, can cascade 24 drives and allow access over a single SAS2 connection. |
|||
You can interconnect the front- and backplane and it will cascade 36 drives over a single SAS2 connection. But most HBAs have 2 connections, so you can do 1.2GB/s. |
|||
The backplanes actually have SAS3, but the cards are.... well... expensive. But if you got one, ayyy 2x 12Gbit connection to the backplane. Or maybe 4x 12Gbit if you are up to it. |
|||
|
|||
Tweak your snapraid autosave to ~4-6TB, otherwise it will take a long ass time. |
|||
|
|||
Oh, yeah. If you got all the drives and the right connection to your backpanel get ready for cpu carnage. |
|||
|
|||
![rape](https://i.imgur.com/ClJAbmF.png "the rape") |
@ -1,60 +0,0 @@ |
|||
# systemd |
|||
|
|||
## Start mergerfs after some arbitrary script |
|||
|
|||
## prep script |
|||
|
|||
`/usr/local/bin/prepare-for-mergerfs` |
|||
|
|||
```shell |
|||
#!/usr/bin/env sh |
|||
|
|||
# Setup things |
|||
# Wait for things |
|||
/bin/sleep 10 |
|||
|
|||
# Report back to systemd that things are ready |
|||
/bin/systemd-notify --ready |
|||
``` |
|||
|
|||
## prep script system service |
|||
|
|||
`/etc/systemd/system/prepare-for-mergerfs.service` |
|||
|
|||
``` |
|||
[Unit] |
|||
Description=Dummy mount service |
|||
|
|||
[Service] |
|||
Type=notify |
|||
RemainAfterExit=yes |
|||
ExecStart=/usr/local/bin/prepare-for-mergerfs |
|||
|
|||
[Install] |
|||
WantedBy=default.target |
|||
``` |
|||
|
|||
## mergerfs systemd service |
|||
|
|||
`/etc/systemd/system/mergerfs.service` |
|||
|
|||
``` |
|||
[Unit] |
|||
Description=Dummy mergerfs service |
|||
Requires=prepare-for-mergerfs.service |
|||
After=prepare-for-mergerfs.service |
|||
|
|||
[Service] |
|||
Type=simple |
|||
KillMode=none |
|||
ExecStart=/usr/bin/mergerfs \ |
|||
-f \ |
|||
-o OPTIONS \ |
|||
/mnt/filesystem0:/mnt/filesystem1 \ |
|||
/mnt/mergerfs |
|||
ExecStop=/bin/fusermount -uz /mnt/mergerfs |
|||
Restart=on-failure |
|||
|
|||
[Install] |
|||
WantedBy=default.target |
|||
``` |
@ -1,4 +0,0 @@ |
|||
- mergerfs rocks! And you rock too! Keep going! Plus, I just found your posting about using mergerfs on Synology and that made me love it even more! Thank you! - Vladimir |
|||
- mergerfs is pretty awesome - [RUakij](https://www.reddit.com/r/homelab/comments/109rka2/comment/j401lyc/?utm_source=reddit&utm_medium=web2x&context=3) |
|||
- mergerfs is surprisingly pleasant - [@blankxk](https://twitter.com/blankxk/status/1619385944578347008) |
|||
- mergerfs good - SE |
@ -0,0 +1,43 @@ |
|||
# Tweaking Performance |
|||
|
|||
mergerfs is at its is a proxy and therefore its theoretical max |
|||
performance is that of the underlying devices. However, given it is a |
|||
FUSE based filesystem working from userspace there is an increase in |
|||
overhead relative to kernel based solutions. That said the performance |
|||
can match the theoretical max but it depends greatly on the system's |
|||
configuration. Especially when adding network filesystems into the mix |
|||
there are many variables which can impact performance. Device speeds |
|||
and latency, network speeds and latency, concurrency and parallel |
|||
limits of the hardware, read/write sizes, etc. |
|||
|
|||
While some settings can impact performance they are all **functional** |
|||
in nature. Meaning they change mergerfs' behavior in some way. As a |
|||
result there is no such thing as a "performance mode". |
|||
|
|||
If you're having performance issues please look over the suggestions |
|||
below and the [benchmarking section.](benchmarking.md) |
|||
|
|||
NOTE: Be sure to [read about these features](config/options.md) before |
|||
changing them to understand how functionality will change. |
|||
|
|||
* test theoretical performance using `nullrw` or mounting a ram disk |
|||
* increase readahead: `readahead=1024` |
|||
* disable `security_capability` and/or `xattr` |
|||
* increase cache timeouts `cache.attr`, `cache.entry`, `cache.negative_entry` |
|||
* enable (or disable) page caching (`cache.files`) |
|||
* enable `parallel-direct-writes` |
|||
* enable `cache.writeback` |
|||
* enable `cache.statfs` |
|||
* enable `cache.symlinks` |
|||
* enable `cache.readdir` |
|||
* change the number of threads available |
|||
* disable `posix_acl` |
|||
* disable `async_read` |
|||
* use `symlinkify` if your data is largely static and read-only |
|||
* use tiered cache devices |
|||
* use LVM and LVM cache to place a SSD in front of your HDDs |
|||
|
|||
If you come across a setting that significantly impacts performance |
|||
please [contact trapexit](support.md) so he may investigate further. Please test |
|||
both against your normal setup, a singular branch, and with |
|||
`nullrw=true` |
@ -0,0 +1,189 @@ |
|||
# QuickStart |
|||
|
|||
## Install |
|||
|
|||
First ensure you have the [latest version installed](setup/installation.md). |
|||
|
|||
|
|||
## Configuration |
|||
|
|||
mergerfs has many options and effectively all of them are functional |
|||
in nature. What that means is that there is no "best" or "fastest" |
|||
configuration. No "make faster" options. Everything changes |
|||
behavior. Sometimes those changes in behavior affect performance. |
|||
|
|||
That said: If you don't already know that you have a special use case |
|||
then use one of the following option sets as it will cover most casual |
|||
usecases. |
|||
|
|||
### You use Linux v6.6 or above |
|||
|
|||
* cache.files=off |
|||
* category.create=mfs |
|||
* dropecacheonclose=false |
|||
|
|||
In previous versions of Linux it was unable to support `mmap` if page |
|||
caching was disabled (ie: `cache.files=off`). However, it now will |
|||
enable page caching if needed for a particular file if mmap is |
|||
requested. |
|||
|
|||
`mmap` is needed by certain software to read and write to a |
|||
file. However, many software could work without it and fail to have |
|||
proper error handling. Many programs that use sqlite3 will require |
|||
`mmap` despite sqlite3 working perfectly fine without it (and in some |
|||
cases can be more performant with regular file IO.) |
|||
|
|||
|
|||
### You use Linux v6.5 or below |
|||
|
|||
#### You need `mmap` (used by rtorrent and many sqlite3 base software) |
|||
|
|||
* cache.files=auto-full |
|||
* category.create=mfs |
|||
* dropcacheonclose=true |
|||
|
|||
|
|||
#### You don't need `mmap` |
|||
|
|||
* cache.files=off |
|||
* category.create=mfs |
|||
* dropcacheonclose=false |
|||
|
|||
|
|||
## Usage |
|||
|
|||
### Command Line |
|||
|
|||
``` |
|||
mergerfs -o cache.files=off,dropcacheonclose=false,category.create=mfs /mnt/hdd0:/mnt/hdd1 /media |
|||
``` |
|||
|
|||
|
|||
### /etc/fstab |
|||
|
|||
``` |
|||
/mnt/hdd0:/mnt/hdd1 /media mergerfs cache.files=off,dropcacheonclose=false,category.create=mfs 0 0 |
|||
``` |
|||
|
|||
### /etc/fstab w/ config file |
|||
|
|||
For more complex setups it can be useful to separate out the config. |
|||
|
|||
|
|||
#### /etc/fstab |
|||
|
|||
``` |
|||
/etc/mergerfs/branches/media/* /media mergerfs config=/etc/mergerfs/config/media.ini |
|||
``` |
|||
|
|||
|
|||
#### /etc/mergerfs/config/media.ini |
|||
|
|||
```ini title="media.ini" linenums="1" |
|||
cache.files=off |
|||
category.create=mfs |
|||
dropcacheonclose=false |
|||
``` |
|||
|
|||
#### /etc/mergerfs/branches/media/ |
|||
|
|||
Create a bunch of symlinks to point to the branch. mergerfs will |
|||
resolve the symlinks and use the real path. |
|||
|
|||
`ls -lh /etc/mergerfs/branches/media/*` |
|||
|
|||
```text |
|||
lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd00 -> /mnt/hdd/hdd00 |
|||
lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd01 -> /mnt/hdd/hdd01 |
|||
lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd02 -> /mnt/hdd/hdd02 |
|||
lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd03 -> /mnt/hdd/hdd03 |
|||
``` |
|||
|
|||
### systemd (simple) |
|||
|
|||
`/etc/systemd/system/mergerfs-media.service` |
|||
|
|||
```systemd title="mergerfs-media.service" linenums="1" |
|||
[Unit] |
|||
Description=mergerfs /media service |
|||
After=local-fs.target network.target |
|||
|
|||
[Service] |
|||
Type=simple |
|||
KillMode=none |
|||
ExecStart=/usr/bin/mergerfs \ |
|||
-f \ |
|||
-o cache.files=off \ |
|||
-o category.create=mfs \ |
|||
-o dropcacheonclose=false \ |
|||
/mnt/hdd0:/mnt/hdd1 \ |
|||
/media |
|||
ExecStop=/bin/fusermount -uz /media |
|||
Restart=on-failure |
|||
|
|||
[Install] |
|||
WantedBy=default.target |
|||
``` |
|||
|
|||
### systemd (w/ setup script) |
|||
|
|||
Since it isn't well documented otherwise: if you wish to do some setup before |
|||
you mount mergerfs follow this example. |
|||
|
|||
#### setup-for-mergerfs |
|||
|
|||
`/usr/local/bin/setup-for-mergerfs` |
|||
|
|||
```shell title="setup-for-mergerfs" linenums="1" |
|||
#!/usr/bin/env sh |
|||
|
|||
# Perform setup |
|||
/bin/sleep 10 |
|||
|
|||
# Report back to systemd that things are ready |
|||
/bin/systemd-notify --ready |
|||
``` |
|||
|
|||
#### setup-for-mergerfs.service |
|||
|
|||
`/etc/systemd/system/setup-for-mergerfs.service` |
|||
|
|||
```systemd title="setup-for-mergerfs.service" linenums="1" |
|||
[Unit] |
|||
Description=mergerfs setup service |
|||
|
|||
[Service] |
|||
Type=notify |
|||
RemainAfterExit=yes |
|||
ExecStart=/usr/local/bin/setup-for-mergerfs |
|||
|
|||
[Install] |
|||
WantedBy=default.target |
|||
``` |
|||
|
|||
#### mergerfs-media.service |
|||
|
|||
`/etc/systemd/system/mergerfs-media.service` |
|||
|
|||
```systemd title="mergerfs-media.service" linenums="1" |
|||
[Unit] |
|||
Description=mergerfs /media service |
|||
Requires=setup-for-mergerfs.service |
|||
After=local-fs.target network.target prepare-for-mergerfs.service |
|||
|
|||
[Service] |
|||
Type=simple |
|||
KillMode=none |
|||
ExecStart=/usr/bin/mergerfs \ |
|||
-f \ |
|||
-o cache.files=off \ |
|||
-o category.create=mfs \ |
|||
-o dropcacheonclose=false \ |
|||
/mnt/hdd0:/mnt/hdd1 \ |
|||
/media |
|||
ExecStop=/bin/fusermount -uz /media |
|||
Restart=on-failure |
|||
|
|||
[Install] |
|||
WantedBy=default.target |
|||
``` |
@ -0,0 +1,56 @@ |
|||
# Related Projects |
|||
|
|||
## Projects using mergerfs |
|||
|
|||
* [Lakka.tv](https://lakka.tv/): A turnkey software emulation Linux |
|||
distribution. Used to pool user and local storage. Also includes my |
|||
other project [Opera](https://retroarch.com/). A 3DO emulator. |
|||
* [OpenMediaVault](https://www.openmediavault.org): A network attached |
|||
storage (NAS) solution based on Debian Linux. They provide plugins |
|||
to manage mergerfs. |
|||
* [CasaOS](https://casaos.io): "A simple, easy to use, elegant open |
|||
source home cloud system." Has added initial integration with |
|||
mergerfs to create pools from existing filesystems. |
|||
* [ZimaOS](https://github.com/IceWhaleTech/zimaos-rauc): A more |
|||
commercially focused NAS OS by the authors of CasaOS at [Ice |
|||
Whale](https://www.zimaboard.com/). |
|||
* [Cosmos Cloud](https://cosmos-cloud.io/): Cosmos "take the chore out |
|||
of selfhosting, with automated maintenance and fully secured setup |
|||
out of the box. It even integrates to your existing setup." |
|||
|
|||
|
|||
## Software and services commonly used with mergerfs |
|||
|
|||
* [snapraid](https://www.snapraid.it/) |
|||
* [rclone](https://rclone.org/) |
|||
* rclone's [union](https://rclone.org/union/) feature is based on |
|||
mergerfs policies |
|||
* [ZFS](https://openzfs.org/): Common to use ZFS w/ mergerfs |
|||
* [UnRAID](https://unraid.net): While UnRAID has its own union |
|||
filesystem it isn't uncommon to see UnRAID users leverage mergerfs |
|||
given the differences in the technologies. |
|||
* For a time there were a number of Chia miners recommending mergerfs |
|||
* [cloudboxes.io](https://cloudboxes.io/wiki/how-to/apps/set-up-mergerfs-using-ssh) |
|||
|
|||
|
|||
## Distributions including mergerfs |
|||
|
|||
mergerfs can be found in the |
|||
[repositories](https://pkgs.org/download/mergerfs) of [many |
|||
Linux](https://repology.org/project/mergerfs/versions) (and maybe |
|||
FreeBSD) distributions. |
|||
|
|||
Note: Any non-rolling release based distro is likely to have |
|||
out-of-date versions. |
|||
|
|||
* [Debian](https://packages.debian.org/bullseye/mergerfs) |
|||
* [Ubuntu](https://launchpad.net/ubuntu/+source/mergerfs) |
|||
* [Fedora](https://rpmsphere.github.io/) |
|||
* [T2](https://t2sde.org/packages/mergerfs) |
|||
* [Alpine](https://pkgs.alpinelinux.org/packages?name=mergerfs&branch=edge&repo=&arch=&maintainer=) |
|||
* [Gentoo](https://packages.gentoo.org/packages/sys-fs/mergerfs) |
|||
* [Arch (AUR)](https://aur.archlinux.org/packages/mergerfs) |
|||
* [Void](https://voidlinux.org/packages/?arch=x86_64&q=mergerfs) |
|||
* [NixOS](https://search.nixos.org/packages?channel=22.11&show=mergerfs&from=0&size=50&sort=relevance&type=packages&query=mergerfs) |
|||
* [Guix]() |
|||
* [Slackware](https://slackbuilds.org/repository/15.0/system/mergerfs/?search=mergerfs) |
@ -1,80 +1,100 @@ |
|||
# INSTALL |
|||
# Installation |
|||
|
|||
https://github.com/trapexit/mergerfs/releases |
|||
If you are using a non-rolling release Linux distro such as Debian or |
|||
Ubuntu then you are almost certainly going to have an old version of |
|||
mergerfs installed if you use the "official" package. For that reason |
|||
we provide packages for major stable released distros. |
|||
|
|||
If your distribution's package manager includes mergerfs check if the |
|||
version is up to date. If out of date it is recommended to use |
|||
the latest release found on the release page. Details for common |
|||
distros are below. |
|||
Before reporting issues or bugs please be sure to upgrade to the |
|||
latest release to confirm they still exist. |
|||
|
|||
#### Debian |
|||
All provided packages can be found at [https://github.com/trapexit/mergerfs/releases](https://github.com/trapexit/mergerfs/releases) |
|||
|
|||
|
|||
## Debian |
|||
|
|||
Most Debian installs are of a stable branch and therefore do not have |
|||
the most up to date software. While mergerfs is available via `apt` it |
|||
is suggested that users install the most recent version available from |
|||
the [releases page](https://github.com/trapexit/mergerfs/releases). |
|||
|
|||
#### prebuilt deb |
|||
|
|||
### prebuilt deb |
|||
|
|||
``` |
|||
wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs_<ver>.debian-<rel>_<arch>.deb |
|||
dpkg -i mergerfs_<ver>.debian-<rel>_<arch>.deb |
|||
sudo dpkg -i mergerfs_<ver>.debian-<rel>_<arch>.deb |
|||
``` |
|||
|
|||
#### apt |
|||
|
|||
### apt |
|||
|
|||
``` |
|||
sudo apt install -y mergerfs |
|||
``` |
|||
|
|||
#### Ubuntu |
|||
|
|||
## Ubuntu |
|||
|
|||
Most Ubuntu installs are of a stable branch and therefore do not have |
|||
the most up to date software. While mergerfs is available via `apt` it |
|||
is suggested that users install the most recent version available from |
|||
the [releases page](https://github.com/trapexit/mergerfs/releases). |
|||
|
|||
#### prebuilt deb |
|||
|
|||
### prebuilt deb |
|||
|
|||
``` |
|||
wget https://github.com/trapexit/mergerfs/releases/download/<version>/mergerfs_<ver>.ubuntu-<rel>_<arch>.deb |
|||
dpkg -i mergerfs_<ver>.ubuntu-<rel>_<arch>.deb |
|||
sudo dpkg -i mergerfs_<ver>.ubuntu-<rel>_<arch>.deb |
|||
``` |
|||
|
|||
#### apt |
|||
|
|||
### apt |
|||
|
|||
``` |
|||
sudo apt install -y mergerfs |
|||
``` |
|||
|
|||
#### Raspberry Pi OS |
|||
|
|||
Effectively the same as Debian or Ubuntu. |
|||
## Raspberry Pi OS |
|||
|
|||
The same as Debian or Ubuntu. |
|||
|
|||
#### Fedora |
|||
|
|||
## Fedora |
|||
|
|||
Get the RPM from the [releases page](https://github.com/trapexit/mergerfs/releases). |
|||
|
|||
``` |
|||
wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.fc<rel>.<arch>.rpm |
|||
sudo rpm -i mergerfs-<ver>.fc<rel>.<arch>.rpm |
|||
``` |
|||
|
|||
#### CentOS / Rocky |
|||
|
|||
## CentOS / Rocky |
|||
|
|||
Get the RPM from the [releases page](https://github.com/trapexit/mergerfs/releases). |
|||
|
|||
``` |
|||
wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.el<rel>.<arch>.rpm |
|||
sudo rpm -i mergerfs-<ver>.el<rel>.<arch>.rpm |
|||
``` |
|||
|
|||
#### ArchLinux |
|||
|
|||
## ArchLinux |
|||
|
|||
1. Setup AUR |
|||
2. Install `mergerfs` |
|||
2. `pacman -S mergerfs` |
|||
|
|||
|
|||
#### Other |
|||
## Other |
|||
|
|||
Static binaries are provided for situations where native packages are |
|||
unavailable. |
|||
|
|||
Get the tarball from the [releases page](https://github.com/trapexit/mergerfs/releases). |
|||
|
|||
``` |
|||
wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-static-linux_<arch>.tar.gz |
|||
sudo tar xvf mergerfs-static-linux_<arch>.tar.gz -C / |
@ -1,4 +1,4 @@ |
|||
# UPGRADE |
|||
# Upgrade |
|||
|
|||
mergerfs can be upgraded live by mounting on top of the previous |
|||
instance. Simply install the new version of mergerfs and follow the |
@ -0,0 +1,17 @@ |
|||
# Sponsorship and Donations |
|||
|
|||
[https://github.com/trapexit/support](https://github.com/trapexit/support) |
|||
|
|||
Development and support of a project like mergerfs requires a |
|||
significant amount of time and effort. The software is released under |
|||
the very liberal [ISC](https://opensource.org/license/isc-license-txt) |
|||
license and is therefore free to use for personal or commercial uses. |
|||
|
|||
If you are a non-commercial user and find mergerfs and its support valuable |
|||
and would like to support the project financially it would be very |
|||
much appreciated. |
|||
|
|||
If you are using mergerfs commercially please consider sponsoring the |
|||
project to ensure it continues to be maintained and receive |
|||
updates. If custom features are needed feel free to [contact me |
|||
directly](mailto:support@spawn.link). |
@ -0,0 +1,45 @@ |
|||
# Support |
|||
|
|||
Filesystems are complex, as are the interactions software have with |
|||
them, and therefore difficult to debug. When reporting on a suspected |
|||
issue **please** include as much of the below information as possible |
|||
otherwise it will be difficult or impossible to diagnose. Also please |
|||
read the documentation as it provides details on many previously |
|||
encountered questions/issues. |
|||
|
|||
**Please make sure you are using the [latest |
|||
release](https://github.com/trapexit/mergerfs/releases) or have tried |
|||
it in comparison. Old versions, which are often included in distros |
|||
like Debian and Ubuntu, are not ever going to be updated and the issue |
|||
you are encountering may have been addressed already.** |
|||
|
|||
**For commercial support or feature requests please [contact me |
|||
directly.](mailto:support@spawn.link)** |
|||
|
|||
### Information to include in bug reports |
|||
|
|||
* [Information about the broader problem along with any attempted |
|||
solutions.](https://xyproblem.info) |
|||
* Solution already ruled out and why. |
|||
* Version of mergerfs: `mergerfs --version` |
|||
* mergerfs settings / arguments: from fstab, systemd unit, command |
|||
line, OMV plugin, etc. |
|||
* Version of the OS: `uname -a` and `lsb_release -a` |
|||
* List of branches, their filesystem types, sizes (before and after issue): `df -h` |
|||
* **All** information about the relevant paths and files: permissions, ownership, etc. |
|||
* **All** information about the client app making the requests: version, uid/gid |
|||
* Runtime environment: |
|||
* Is mergerfs running within a container? |
|||
* Are the client apps using mergerfs running in a container? |
|||
* A `strace` of the app having problems: |
|||
* `strace -fvTtt -s 256 -o /tmp/app.strace.txt <cmd>` |
|||
* A `strace` of mergerfs while the program is trying to do whatever it is failing to do: |
|||
* `strace -fvTtt -s 256 -p <mergerfsPID> -o /tmp/mergerfs.strace.txt` |
|||
* **Precise** directions on replicating the issue. Do not leave **anything** out. |
|||
* Try to recreate the problem in the simplest way using standard programs: `ln`, `mv`, `cp`, `ls`, `dd`, etc. |
|||
|
|||
### Contact / Issue submission |
|||
|
|||
* github.com: [https://github.com/trapexit/mergerfs/issues](https://github.com/trapexit/mergerfs/issues) |
|||
* discord: [https://discord.gg/MpAr69V](https://discord.gg/MpAr69V) |
|||
* reddit: [https://www.reddit.com/r/mergerfs](https://www.reddit.com/r/mergerfs) |
@ -0,0 +1,43 @@ |
|||
# Tips and Notes |
|||
|
|||
* This document is literal and reasonably thorough. If a suspected |
|||
feature isn't mentioned it doesn't exist. If certain `libfuse` |
|||
arguments aren't listed they probably shouldn't be used. |
|||
* Ensure you're using the latest version. Especially before submitting |
|||
bug reports. |
|||
* Run mergerfs as `root`. mergerfs is designed and intended to be run |
|||
as `root` and may exhibit incorrect behavior if run otherwise. |
|||
* If you do not see some directories and files you expect, policies |
|||
seem to skip branches, you get strange permission errors, etc. be |
|||
sure the underlying filesystems' permissions are all the same. Use |
|||
`mergerfs.fsck` to audit the filesystem for out of sync permissions. |
|||
* If you still have permission issues be sure you are using POSIX ACL |
|||
compliant filesystems. mergerfs doesn't generally make exceptions |
|||
for FAT, NTFS, or other non-POSIX filesystem. |
|||
* Unless using Linux v6.6 or above do **not** use `cache.files=off` if |
|||
you expect applications (such as rtorrent) to use |
|||
[mmap](http://linux.die.net/man/2/mmap). Enabling `dropcacheonclose` |
|||
is recommended when `cache.files=auto-full`. |
|||
* [Kodi](http://kodi.tv), [Plex](http://plex.tv), |
|||
[Subsonic](http://subsonic.org), etc. can use directory |
|||
[mtime](http://linux.die.net/man/2/stat) to more efficiently |
|||
determine whether to scan for new content rather than simply |
|||
performing a full scan. If using the default `getattr` policy of |
|||
`ff` it's possible those programs will miss an update on account of |
|||
it returning the first directory found's `stat` info and it is a |
|||
later directory on another mount which had the `mtime` recently |
|||
updated. To fix this you will want to set |
|||
`func.getattr=newest`. Remember though that this is just `stat`. If |
|||
the file is later `open`'ed or `unlink`'ed and the policy is |
|||
different for those then a completely different file or directory |
|||
could be acted on. |
|||
* Some policies mixed with some functions may result in strange |
|||
behaviors. Not that some of these behaviors and race conditions |
|||
couldn't happen outside mergerfs but that they are far more |
|||
likely to occur on account of the attempt to merge multiple sources |
|||
of data which could be out of sync due to the different policies. |
|||
* For consistency it's generally best to set `category` wide policies |
|||
rather than individual `func`'s. This will help limit the |
|||
confusion of tools such as |
|||
[rsync](http://linux.die.net/man/1/rsync). However, the flexibility |
|||
is there if needed. |
@ -1,2 +0,0 @@ |
|||
mkdocs==1.6.1 |
|||
mkdocs-material==9.5.49 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue