MergerFS
sudo apt install fuse mergerfsCreate a mountpoint for all the disks.
mkdir /mnt/disk{1,2,3} # this command will create 3 directory
mkdir /mnt/pool /mnt/parity- edit the disks in
/etc/fstab - the disks must have a partition created eg.
/dev/sda1for the mount
Add mergerfs into /etc/fstab
/mnt/disk* /mnt/storage fuse.mergerfs defaults,cache.files=off,allow_other,category.create=mfs,minfreespace=250G,fsname=mergerfs 0 0Relative path: path in mergerfs pool relative to the path of individual drive and pool
Path preservation: policies that only consider branches (path of individual disks) where the relative path being accessed already exists
- eg. with 3 disks,
/mnt/{a,b,c}, if a foldermoviesexists in onlya,bnot notc, a path preservation policy will only considera,bwhen a request to create a file/mnt/pool/movies/file.mkvand the file would not be created inc - eg. for
epmfs, the previous example would choosea,band see which drive has most free space and only put files on these drives, even ifchas more free space; whilemfsignore existing path and would createmovies/file.mkvoncif that has the most free space
MergerFS Options
/mnt/disk*the disks to be added into mergerfs, assuming the disks are disk1,2,3,4,5/mnt/poolwhere the pooled disks arefuse.mergerfsuse mergerfs for this mountdefaultsaction=epallactions such as rename, change metadata (chmod/own) will apply to all foundcreate=epmfsfiles will be created on disks with most free space and preserve pathsearch=ffsearch will act on the first found
category.createthe policycache.file=offdisable page cache in mergerfs, other options includepartial, which could be useful for sqlite apps and rtorrentallow_otheris explicitly needed when some of the drives that needs to be pooled are NTFSfsname=mergerfsshows a friendly name indf -hcommand
SnapRAID
Use Docker to build SnapRAID
https://github.com/ironicbadger/docker-snapraid
- run the
build.shand install the package withsudo dpkg -i *.deb
SnapRAID is configured via /etc/snapraid.conf
parity /mnt/parity/snapraid.parity # location of the parity
content /srv/snapraid/snapraid.content # content file
disk d1 /mnt/data # data disk, d1 is the disk name used in snapraid
contentfile contains details of all the files in the array
Example configuration file with exclusions
https://gist.github.com/IronicBadger/ce960d96015b28a03373
snapraid status will get the status of array, whether there are corruptions
Diff
snapraid diff list all the files that are modified from the last sync, it is recommended to run before syncing to check for deleted files
- if a sync is required, it will require
2as exit code
Sync
snapraid sync will sync the data and create parity (also compute hashes)
- it’s best to use it in a screen/tmux session
- if the SnapRAID sync is abruptly stopped, the next session will start where it’s left off
-Ewill force empty, and sync will proceed even if a data disk is empty
Scrub
snapraid scrub check the data and parity for errors, it is only read intensive
snapraid -p 5 -o 20 scrub-pset the % of array to scrub-p badwill only scrub the bad parts of the array-oolder than, any data older than x days will be scrubbed
Fix
snapraid fix restore or undeleted files from accident or disk failure
snapraid fix -f FILE or DIR/ or -m- for directory add
/to the end -moption will fix every deleted files-dwill act on entire disk (eg. for recovering), the disk name eg.d1is given in the configuration file, it will also fix parity-ewill fix errors in the scrub command
Fixing delete files on Radarr behaving and upgrade
snapraid fix -f /Movies/Name/file.srt- must provide it as absolute path
/Moviesbut without disk numberd1 - the file path and name can be found by
snapraid diff | grep
Check
snapraid check verify all files and parity data
-ais audit only, only the file data is checked and parity data is ignored
Disaster Recovery
Edit the configuration so that is points to the new disks
data d2 /mnt/new_locationsnapraid -d d2 -l fix.log fix- files that cannot be recovered will have
.unrecoverablefile extension
snapraid -d d2 -a check- this will only check the data disk that is specified
Lastly run a snapraid sync.
Automating SnapRAID
https://github.com/Chronial/snapraid-runner
https://github.com/fightforlife/snapraid-runner with apprise support
which snapraidto get the binary file of snapraid, which might be needed for configure the runner- the python script will run SnapRAID diff command, and only run sync if the deleted is below threshold, optionally can be used to periodically scrub the array
By default the cron scripts are located in ~/scripts
cd ~/scripts
git clone https://github.com/fightforlife/snapraid-runner
cd snapraid-runner
mv snapraid-runner.py runner.py
mv snapraid-runner.conf.example snapraid-runner.confConfiguration
+++ executable = /usr/local/bin/snapraid
+++ config = /etc/snapraid.conf
+++ file = sr.log
+++ url = apprise://- use
which snapraidto find executable location, use the default location - it will store as
sr.loginstead
Crontab (every 2 days) - require uv installed and initialized. To install uv
uv init
uv add apprise
uv sync5 2 */2 * * SHELL=/bin/bash cd /home/karis/scripts/snapraid-runner && /home/karis/.local/bin/uv run runner.py