MergerFS neat tricks
Trapexit’s MergerFS is awesome. He has some great documentation on the README, but I just wanted to share a couple of quick examples I use all the time. Let’s say you have a MergerFS pool mounted at /storage. You can view the current setup by using xattrs to view the pseudo .mergerfs file.
apt-get install python-xattr
cd /storage xattr -l .mergerfs
It will output something like this. Note that there are currently 5 disks shown under the srcmounts value.
user.mergerfs.srcmounts: /mnt/data/disk01:/mnt/data/disk02:/mnt/data/disk03:/mnt/data/disk04:/mnt/data/disk05 user.mergerfs.minfreespace: 21474836480 user.mergerfs.moveonenospc: true user.mergerfs.policies: all,eplfs,eplus,epmfs,erofs,ff,lfs,lus,mfs,newest,rand user.mergerfs.version: 2.13.1 user.mergerfs.pid: 91089 user.mergerfs.category.action: all user.mergerfs.category.create: eplfs user.mergerfs.category.search: ff user.mergerfs.func.access: ff user.mergerfs.func.chmod: all user.mergerfs.func.chown: all user.mergerfs.func.create: eplfs user.mergerfs.func.getattr: ff user.mergerfs.func.getxattr: ff user.mergerfs.func.link: all user.mergerfs.func.listxattr: ff user.mergerfs.func.mkdir: eplfs user.mergerfs.func.mknod: eplfs user.mergerfs.func.open: ff user.mergerfs.func.readlink: ff user.mergerfs.func.removexattr: all user.mergerfs.func.rename: all user.mergerfs.func.rmdir: all user.mergerfs.func.setxattr: all user.mergerfs.func.symlink: eplfs user.mergerfs.func.truncate: all user.mergerfs.func.unlink: all user.mergerfs.func.utimens: all
All of these options above can be set in realtime without unmounting and re-mounting the mergerfs pool via the runtime options.
Removing Disks
The first example could be removing a couple of disks from the pool.
xattr -w user.mergerfs.srcmounts '-/mnt/data/disk04:/mnt/data/disk05' .mergerfs
This modifies the pool in realtime (no need to unmount, or stop services like samba/plex). It just works. Afterwards, we are left with this. Note that disk04 and disk05 have been removed from the pool.
user.mergerfs.srcmounts: /mnt/data/disk01:/mnt/data/disk02:/mnt/data/disk03 user.mergerfs.minfreespace: 21474836480 user.mergerfs.moveonenospc: true user.mergerfs.policies: all,eplfs,eplus,epmfs,erofs,ff,lfs,lus,mfs,newest,rand user.mergerfs.version: 2.13.1 user.mergerfs.pid: 91089 user.mergerfs.category.action: all user.mergerfs.category.create: eplfs user.mergerfs.category.search: ff user.mergerfs.func.access: ff user.mergerfs.func.chmod: all user.mergerfs.func.chown: all user.mergerfs.func.create: eplfs user.mergerfs.func.getattr: ff user.mergerfs.func.getxattr: ff user.mergerfs.func.link: all user.mergerfs.func.listxattr: ff user.mergerfs.func.mkdir: eplfs user.mergerfs.func.mknod: eplfs user.mergerfs.func.open: ff user.mergerfs.func.readlink: ff user.mergerfs.func.removexattr: all user.mergerfs.func.rename: all user.mergerfs.func.rmdir: all user.mergerfs.func.setxattr: all user.mergerfs.func.symlink: eplfs user.mergerfs.func.truncate: all user.mergerfs.func.unlink: all user.mergerfs.func.utimens: all
Adding Disks
Now, let’s show you an example to add a couple disks. Let’s say you got some nice shiny 8TB data disks that you’d like to add to your pool. You can get them all setup and mounted via /etc/fstab (including adding them to the mergerfs line there), but you don’t want to have to offline your pool right now because your kids are watching a movie in Plex. No problem, mergerfs pseudo file to the rescue!
xattr -w user.mergerfs.srcmounts '+>/mnt/data/disk04:/mnt/data/disk05' .mergerfs
The above will append disk04 and disk05 onto the end of the current srcmounts.
user.mergerfs.srcmounts: /mnt/data/disk01:/mnt/data/disk02:/mnt/data/disk03:/mnt/data/disk04:/mnt/data/disk05 user.mergerfs.minfreespace: 21474836480 user.mergerfs.moveonenospc: true user.mergerfs.policies: all,eplfs,eplus,epmfs,erofs,ff,lfs,lus,mfs,newest,rand user.mergerfs.version: 2.13.1 user.mergerfs.pid: 91089 user.mergerfs.category.action: all user.mergerfs.category.create: eplfs user.mergerfs.category.search: ff user.mergerfs.func.access: ff user.mergerfs.func.chmod: all user.mergerfs.func.chown: all user.mergerfs.func.create: eplfs user.mergerfs.func.getattr: ff user.mergerfs.func.getxattr: ff user.mergerfs.func.link: all user.mergerfs.func.listxattr: ff user.mergerfs.func.mkdir: eplfs user.mergerfs.func.mknod: eplfs user.mergerfs.func.open: ff user.mergerfs.func.readlink: ff user.mergerfs.func.removexattr: all user.mergerfs.func.rename: all user.mergerfs.func.rmdir: all user.mergerfs.func.setxattr: all user.mergerfs.func.symlink: eplfs user.mergerfs.func.truncate: all user.mergerfs.func.unlink: all user.mergerfs.func.utimens: all
You can also do all sorts of other things like change the create mode, or the moveonenospc value, or even the minfreespace option all without remounting.
Question – I have three drives (more on the way) and I’m trying out the snapRAID with MergerFS. I have disk1 and disk2 my data drive and disk3 parity. When I see how much space /storage (where it is merging it all) it shows the total some of ALL disks which is 18TB. It should only be 10TB with the parity factored in. Is this expected?
Hello, thanks for the comment. Can you provide a copy of your /erc/fstab? Your parity drive should not be included in the Mergerfs pool and it sounds like it is being included as result of your mount string.
This is my code in /etc/fstab I was curious about the snapRAID tutorial on the parity mounting disk. I can just remount it to /media/parity1 or something since I’ll eventually have two parity drives.
I would suggest you create separate mountpoints for your parity and data disks.
and umount and remount your disks there.
Update your /etc/fstab
Mount everything back.
Remember… If you are using SnapRAID, you will need to update your /etc/snapraid.conf to point to these new locations.
Amazing! Thank you! Works great now!
I’m glad that got it working correctly 🙂
Hi,
How is it possible to setup an ftp account? i try to create an account on /mnt/storage but this not work.
Thanks for your feedback.
I would suggest using SFTP or SSH instead of FTP. Both are FAR more secure than FTP. That being said, I don’t use FTP on my mergerFS pool, but SFTP should work fine (I use SSH all the time without issue).
I totally agree with you that it is less secure but the problem is, i have some devices that not support sftp / ssh.
So that is why i needed some ftp connections.
I created an ftp account with vsftpd and set the path to /mnt/storage but i cannot ftp files or created any folder.
Do you have a copy of the directions you followed? Also, what errors do you see in the logs? This is likely either a permissions issue or a misconfiguration. Have you tried setting up an FTP path not on the mergerFS pool to see if that works?
Had some issues with the mergerfs options as some of them are not listed in the github write-up until I realised some of the options are in fact fuse options. Once I understood that, everything worked perfectly. I was not able to detect any noticeable improvement over mhddfs but there were certainly no drawbacks and being currently maintained is always a big advantage.
Hello, thanks for the comment!
What options did you have issues with? I can’t see any options in my tutorial that are not explained in the Github Readme page.
Other things that are nice over mhddfs: the lack of an readonly volume occasionally (without patched mhddfs. Requiring the pool to be unmounted and re-mounted to remedy), many write policies vs. one with mhddfs, and faster read/write speed on decent hardware.
I know this post is kind of old but I’d really love to get this to work on OpenMediaVault 5. After doing an apt install for python-xattr, I try running the xattr command it says command not found. How do I use it now?
Hello! Are you running xattr as root and in the directory where you mergerfs pool is mounted?