What is Mergerfs and SnapRAID?

MergerFS and SnapRAID are powerful tools used together to create a robust and flexible storage solution, particularly popular in home server setups and small-scale data storage environments. MergerFS is a union filesystem that allows multiple drives to be combined into a single, unified directory structure, making it easier to manage and access files across different physical disks. On the other hand, SnapRAID is a backup program that adds data protection through parity, ensuring that your data can be recovered in the event of a drive failure. While MergerFS offers flexibility in how you organize and store files, SnapRAID provides the redundancy and reliability needed to safeguard your data. Together, they form a highly customizable and efficient storage solution that balances ease of use with strong data protection, making them an ideal choice for those looking to build or manage a home server.

Setting it up

  1. Install Ubuntu Server or Any Linux Distro

  2. Update the System

sudo apt update && sudo apt upgrade -y
  1. Install SnapRAID and MergerFS
sudo apt install snapraid mergerfs
  1. Partition the Drive: Just replace the X with your drive letter.
sudo fdisk /dev/sdX
  1. In fdisk, Follow These Keys: a. g b. n c. Enter key d. Enter key e. Enter key f. w

  2. Repeat This for Each Drive You Have

  3. Format the Drives: This will format the drives in XFS, which MergerFS uses.

sudo mkfs.xfs /dev/sdX
  1. Get the UUID of the Drive: Just the part where it says /dev/sdX1
blkid
  1. Mount the Drives:
susudo mkdir -p /media/{disk1,disk2,parity1}
sudo mount /dev/sdX1 /media/parity1 # Your parity drive
sudo mount /dev/sdX1 /media/disk1 # Your first data drive
sudo mount /dev/sdX1 /media/disk2 # Your second data drive
  1. Add the Drives to Your fstab File:
sudo nano /etc/fstab
  1. Add the Following Lines:
## drive for mergerfs
/dev/disk/by-uuid/89b0dc69-df80-4d3e-8ce8-b6c687debe0c /media/parity1 xfs defaults 0 0
/dev/disk/by-uuid/d072b443-ab59-4c08-910f-21bea2ba3c63 /media/disk1 xfs  defaults 0 0
/dev/disk/by-uuid/c12f8417-f9d4-4982-9e6b-9ae4a3702908 /media/disk2 xfs  defaults 0 0



/media/disk* /media/storage fuse.mergerfs cache.files=partial,dropcacheonclose=true,ignorepponrename=true,allow_other,use_ino,category.create=mfs,minfreespace=10G,fsname=mergerfs,defaults 0 0

Now you are done! You will have a RAID setup, and if one drive fails, you can recover the data. If you want protection against two drive failures, just add two parity drives. Just make sure the parity drives are the same size or larger than your data drives.