You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
5.2 KiB

11 years ago
  1. mergerfs
  2. ========
  3. another FUSE union filesystem
  4. mergerfs is similar to mhddfs, unionfs, and aufs. Like mhddfs in that it too uses FUSE. Like aufs in that it provides multiple policies for how to handle behavior.
  5. Why create mergerfs when those exist? mhddfs isn't really maintained or flexible. There are also issues with running as root. aufs is more flexible but contains some hard to debug inconsistencies in behavior. Neither support file attributes ([chattr](http://linux.die.net/man/1/chattr)).
  6. Policies
  7. ========
  8. Filesystem calls are broken up into 4 categories of policies: search, action, create, and none.
  9. Below shows each policy class, the FUSE calls they impact, and the policy names.
  10. #### Policy classifications ####
  11. | Class | FUSE calls | Policies |
  12. |-------|------------|----------|
  13. | search | access, getattr, getxattr, listxattr, open, readlink | First Found (ff), First Found w/ Permission (ffwp), Newest (newest) |
  14. | action | chmod, link, removexattr, rmdir, setxattr, truncate, unlink, utimens | First Found (ff), First Found w/ Permission (ffwp), Newest (newest), All Found (all) |
  15. | create | create, mkdir, mknod | Existing Path (ep), Most Free Space (mfs), Existing Path Most Free Space (epmfs), Random (rand) |
  16. | none | fallocate, fsync, ftruncate, ioctl, read, readdir, rename, statfs, symlink, write, release | |
  17. #### Descriptions ####
  18. | Class/Policy | Description |
  19. |--------------|-------------|
  20. | search/ff | Given the order the paths were provided at mount time act on the first one found (regardless if stat would return EACCES). |
  21. | search/ffwp | Given the order the paths were provided at mount time act on the first one found which you have access (stat does not error with EACCES). |
  22. | search/newest | If multiple files exist return the one with the most recent mtime. |
  23. | action/ff | (same as search/ff) |
  24. | action/ffwp | (same as search/ffwp) |
  25. | action/newest | (same as search/newest) |
  26. | action/all | Attempt to apply the call to each file found. If any sub call succeeds the entire operation succeeds and other errors ignored. If all fail then the last error is reported. |
  27. | create/ep | Choose the first path which is found. |
  28. | create/mfs | Assuming the path is found to exist (ENOENT would not be returned) use the drive with the most free space available. |
  29. | create/epmfs | If the path exists in multiple locations use the one with the most free space. Otherwise fall back to mfs. |
  30. | create/rand | Pick a destination at random. Again the dirname of the full path must exist somewhere. |
  31. #### statvfs ####
  32. Since we aren't trying to stripe data across drives the free space of the mountpoint is just that of the source mount with the most free space at the moment.
  33. **NOTE:** create is really a search for existence and then create. The 'search' policy applies to the first part. If the [dirname](http://linux.die.net/man/3/dirname) of the full path is not found to exist [ENOENT](http://linux.die.net/man/3/errno) is returned.
  34. Usage
  35. =====
  36. ```
  37. $ mergerfs -o create=epmfs,search=ff,action=ff <mountpoint> <dir0>:<dir1>:<dir2>
  38. ```
  39. | Option | Values | Default |
  40. |--------|--------|---------|
  41. | search | ff, ffwp, newest | ff |
  42. | action | ff, ffwp, newest, all | ff |
  43. | create | ep, mfs, epmfs, rand | epmfs |
  44. Building
  45. ========
  46. Need to install FUSE development libraries (libfuse-dev).
  47. Optionally need libattr1 (libattr1-dev).
  48. ```
  49. [trapexit:~/dev/mergerfs] $ make help
  50. usage: make
  51. make WITHOUT_XATTR=1 - to build program without xattrs functionality
  52. ```
  53. Runtime Settings
  54. ================
  55. #### /.mergerfs pseudo file ####
  56. ```
  57. <mountpoint>/.mergerfs
  58. ```
  59. There is a pseudo file available at the mountpoint which currently allows for the runtime modification of policies. The file will not show up in readdirs but can be stat'ed, read, and writen. Most other calls will fail with EPERM, EINVAL, or whatever may be appropriate for that call. Anything not understood while writing will result in EINVAL otherwise the number of bytes written will be returned.
  60. Reading the file will result in a newline delimited list of current settings as followed:
  61. ```
  62. [trapexit:/tmp/mount] $ cat .mergerfs
  63. action=ff
  64. create=epmfs
  65. search=ff
  66. ```
  67. Writing to the file is buffered and waits till a newline to process. Meaning echo works well.
  68. ```
  69. [trapexit:/tmp/mount] $ echo "search=newest" >> .mergerfs
  70. [trapexit:/tmp/mount] $ cat .mergerfs
  71. action=ff
  72. create=epmfs
  73. search=newest
  74. ```
  75. *NOTE:* offset is not supported and ignored in both read and write. There is also a safety check which limits buffered + incoming length to a max of 1024 bytes.
  76. #### xattrs ####
  77. If xattrs has been enabled you can also use [{list,get,set}xattrs](http://linux.die.net/man/2/listxattr) on the pseudo file **.mergerfs** to modify the policies. The keys are **mergerfs.action**, **mergerfs.create**, and **mergerfs.search**.
  78. ```
  79. [trapexit:/tmp/mount] $ attr -l .mergerfs
  80. Attribute "mergerfs.action" has a 3 byte value for .mergerfs
  81. Attribute "mergerfs.create" has a 6 byte value for .mergerfs
  82. Attribute "mergerfs.search" has a 3 byte value for .mergerfs
  83. [trapexit:/tmp/mount] $ attr -g mergerfs.action .mergerfs
  84. Attribute "mergerfs.action" had a 3 byte value for .mergerfs:
  85. ff
  86. [trapexit:/tmp/mount] 1 $ attr -s mergerfs.action -V ffwp .mergerfs
  87. Attribute "mergerfs.action" set to a 3 byte value for .mergerfs:
  88. ffwp
  89. ```