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.

189 lines
4.1 KiB

  1. # QuickStart
  2. ## Install
  3. First ensure you have the [latest version installed](setup/installation.md).
  4. ## Configuration
  5. mergerfs has many options and effectively all of them are functional
  6. in nature. What that means is that there is no "best" or "fastest"
  7. configuration. No "make faster" options. Everything changes
  8. behavior. Sometimes those changes in behavior affect performance.
  9. That said: If you don't already know that you have a special use case
  10. then use one of the following option sets as it will cover most casual
  11. usecases.
  12. ### You use Linux v6.6 or above
  13. * cache.files=off
  14. * category.create=mfs
  15. * dropecacheonclose=false
  16. In previous versions of Linux it was unable to support `mmap` if page
  17. caching was disabled (ie: `cache.files=off`). However, it now will
  18. enable page caching if needed for a particular file if mmap is
  19. requested.
  20. `mmap` is needed by certain software to read and write to a
  21. file. However, many software could work without it and fail to have
  22. proper error handling. Many programs that use sqlite3 will require
  23. `mmap` despite sqlite3 working perfectly fine without it (and in some
  24. cases can be more performant with regular file IO.)
  25. ### You use Linux v6.5 or below
  26. #### You need `mmap` (used by rtorrent and many sqlite3 base software)
  27. * cache.files=auto-full
  28. * category.create=mfs
  29. * dropcacheonclose=true
  30. #### You don't need `mmap`
  31. * cache.files=off
  32. * category.create=mfs
  33. * dropcacheonclose=false
  34. ## Usage
  35. ### Command Line
  36. ```
  37. mergerfs -o cache.files=off,dropcacheonclose=false,category.create=mfs /mnt/hdd0:/mnt/hdd1 /media
  38. ```
  39. ### /etc/fstab
  40. ```
  41. /mnt/hdd0:/mnt/hdd1 /media mergerfs cache.files=off,dropcacheonclose=false,category.create=mfs 0 0
  42. ```
  43. ### /etc/fstab w/ config file
  44. For more complex setups it can be useful to separate out the config.
  45. #### /etc/fstab
  46. ```
  47. /etc/mergerfs/branches/media/* /media mergerfs config=/etc/mergerfs/config/media.ini
  48. ```
  49. #### /etc/mergerfs/config/media.ini
  50. ```ini title="media.ini" linenums="1"
  51. cache.files=off
  52. category.create=mfs
  53. dropcacheonclose=false
  54. ```
  55. #### /etc/mergerfs/branches/media/
  56. Create a bunch of symlinks to point to the branch. mergerfs will
  57. resolve the symlinks and use the real path.
  58. `ls -lh /etc/mergerfs/branches/media/*`
  59. ```text
  60. lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd00 -> /mnt/hdd/hdd00
  61. lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd01 -> /mnt/hdd/hdd01
  62. lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd02 -> /mnt/hdd/hdd02
  63. lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd03 -> /mnt/hdd/hdd03
  64. ```
  65. ### systemd (simple)
  66. `/etc/systemd/system/mergerfs-media.service`
  67. ```systemd title="mergerfs-media.service" linenums="1"
  68. [Unit]
  69. Description=mergerfs /media service
  70. After=local-fs.target network.target
  71. [Service]
  72. Type=simple
  73. KillMode=none
  74. ExecStart=/usr/bin/mergerfs \
  75. -f \
  76. -o cache.files=off \
  77. -o category.create=mfs \
  78. -o dropcacheonclose=false \
  79. /mnt/hdd0:/mnt/hdd1 \
  80. /media
  81. ExecStop=/bin/fusermount -uz /media
  82. Restart=on-failure
  83. [Install]
  84. WantedBy=default.target
  85. ```
  86. ### systemd (w/ setup script)
  87. Since it isn't well documented otherwise: if you wish to do some setup before
  88. you mount mergerfs follow this example.
  89. #### setup-for-mergerfs
  90. `/usr/local/bin/setup-for-mergerfs`
  91. ```shell title="setup-for-mergerfs" linenums="1"
  92. #!/usr/bin/env sh
  93. # Perform setup
  94. /bin/sleep 10
  95. # Report back to systemd that things are ready
  96. /bin/systemd-notify --ready
  97. ```
  98. #### setup-for-mergerfs.service
  99. `/etc/systemd/system/setup-for-mergerfs.service`
  100. ```systemd title="setup-for-mergerfs.service" linenums="1"
  101. [Unit]
  102. Description=mergerfs setup service
  103. [Service]
  104. Type=notify
  105. RemainAfterExit=yes
  106. ExecStart=/usr/local/bin/setup-for-mergerfs
  107. [Install]
  108. WantedBy=default.target
  109. ```
  110. #### mergerfs-media.service
  111. `/etc/systemd/system/mergerfs-media.service`
  112. ```systemd title="mergerfs-media.service" linenums="1"
  113. [Unit]
  114. Description=mergerfs /media service
  115. Requires=setup-for-mergerfs.service
  116. After=local-fs.target network.target prepare-for-mergerfs.service
  117. [Service]
  118. Type=simple
  119. KillMode=none
  120. ExecStart=/usr/bin/mergerfs \
  121. -f \
  122. -o cache.files=off \
  123. -o category.create=mfs \
  124. -o dropcacheonclose=false \
  125. /mnt/hdd0:/mnt/hdd1 \
  126. /media
  127. ExecStop=/bin/fusermount -uz /media
  128. Restart=on-failure
  129. [Install]
  130. WantedBy=default.target
  131. ```