SnapRAID Config

Why You Need SnapRAID with MergerFS

Picture this: You’ve spent years building the perfect media collection—movies, TV shows, music, and personal backups—all neatly stored across multiple hard drives. Then one day, you hear that dreaded clicking sound from one of your server’s drives. Panic sets in. Did you just lose everything on that drive? Not if you planned ahead.

This is where MergerFS and SnapRAID come to the rescue. MergerFS lets you combine multiple drives into a single, easy-to-manage storage pool, while SnapRAID adds redundancy to protect against drive failures. See my MergerFS Post. Together, they provide a cost-effective way to safeguard your data without the complexity of traditional RAID setups.

SnapRAID is a parity-based backup system that protects against drive failures. Unlike traditional RAID, it doesn’t constantly write to all drives, making it ideal for media servers with mostly static data.

In this post, I’ll walk you through how to install and use SnapRAID with MergerFS to build a robust and flexible home media server.


What is SnapRAID Parity?

SnapRAID parity is the backbone of SnapRAID’s data protection. It works by creating a special file containing mathematical information (parity data) about the files on your data disks. This parity data allows SnapRAID to reconstruct lost files if a drive fails.

Think of parity as an insurance policy for your media collection. If one of your drives crashes, the parity file acts like a backup blueprint, enabling SnapRAID to rebuild the missing data using the remaining disks.

How SnapRAID Parity Works

  1. Parity Calculation:

    • SnapRAID scans all data disks and calculates parity information based on their contents.
    • This parity data is stored on a dedicated parity disk(s), separate from the data drives.
  2. Parity Updates:

    • Unlike traditional RAID, SnapRAID does not automatically update parity when you add, remove, or modify files.
    • You need to run snapraid sync to refresh the parity data. I’ll show you how to automate this with a cron job later.
  3. Drive Recovery:

    • If a data disk fails, SnapRAID uses the remaining data drives + parity disk to reconstruct the lost files.
    • The more parity disks you have, the more failures you can recover from.

Why Is SnapRAID Parity Important?

Protects Against Drive Failures

The main reason to use SnapRAID is data redundancy. Without parity, a drive failure means losing everything on that disk. SnapRAID parity lets you recover the lost files, preventing catastrophic data loss.

Saves Space Compared to Full Backups

Unlike traditional backups, SnapRAID parity only stores difference-based data, taking up much less space than making full copies of your drives. One parity drive can protect multiple data drives, making it a space-efficient solution.

Scales with Your Storage Needs

SnapRAID allows you to mix and match different-sized disks—no need for matching drives like in traditional RAID. You can start with one parity drive and add more as your storage needs grow.

Allows Multiple Parity Drives for Extra Protection

One parity drive protects against one failed disk. For more security, you can add additional parity drives:

  • 1 parity drive → Recovers from 1 failed disk
  • 2 parity drives → Recovers from 2 failed disks
  • 3 parity drives → Recovers from 3 failed disks

SnapRAID’s flexible and scalable parity system makes it a powerful choice for home media servers, keeping your data safe without wasting space.

To add more parity drives, update your /etc/snapraid.conf file like this:

parity /mnt/disk4/snapraid.parity
parity /mnt/disk5/snapraid.parity2

SnapRAID parity is crucial for protecting your home media server from hard drive failures. By setting up at least one parity drive, you ensure that your Movie, TV Shows, and Music collections are safe from unexpected data loss.


What Is SnapRAID Content?

The SnapRAID content file (snapraid.content) is a critical part of the SnapRAID system. It stores metadata about all your files, including checksums, timestamps, and information necessary for data recovery. Unlike the parity file, which is used to reconstruct lost data, the content file tells SnapRAID what your data looked like at the last sync.

Every time you run snapraid sync, the content file is updated with new metadata. This allows SnapRAID to detect changes, check for corruption, and restore lost files when needed.

Why Is It Important to Have snapraid.content on Multiple Drives?

Prevents Complete Data Loss in Case of a Crash

The SnapRAID content file (snapraid.content) is a critical part of the SnapRAID system. It stores metadata about all your files, including checksums, timestamps, and information necessary for data recovery. Unlike the parity file, which is used to rebuild lost files, the content file tells SnapRAID what your data looked like at the last sync.

Ensures SnapRAID Can Rebuild Your Files

If you were to only store snapraid.content on disk1, and disk1 fails. When you try to run SnapRAID recovery, it will fail because it no longer has a record of your data layout. However, if you also had a copy of snapraid.content on disk2, SnapRAID could still function and restore the missing data.

SnapRAID is designed for data resilience, and having multiple copies of the content file aligns with that philosophy. If a drive fails and you only have one copy, you risk losing access to your recovery information. Multiple content files make SnapRAID more fault-tolerant.

How to Store snapraid.content on Multiple Drives

In your /etc/snapraid.conf file, define multiple content locations:

content /mnt/disk1/snapraid.content
content /mnt/disk2/snapraid.content
content /mnt/disk3/snapraid.content

Each entry creates a duplicate of the content file on a different disk. SnapRAID will update all content files during a sync, keeping them identical.

By distributing the content file across two or more drives, you protect your media collection from unexpected failures. This small step ensures that if disaster strikes, you’ll always have a path to recovery.

NOTE: You may use the same drives for content and data.


What Is SnapRAID Data?

In SnapRAID, data refers to the actual files stored on your media server—movies, TV shows, music, backups, and other content. These files are located on data drives, which are physical hard drives or storage locations that SnapRAID protects using parity data.

Unlike traditional RAID, SnapRAID does not mirror or stripe data across disks. Each file exists in only one location, and SnapRAID keeps track of which files are on which drives.

Why Is It Important to Have Data Drives Identified in snapraid.conf?

SnapRAID Needs to Know Where Your Files Are

SnapRAID relies on parity calculations to recover lost files. If you don’t tell SnapRAID which drives contain data, it cannot protect them or restore your missing files.

In /etc/snapraid.conf, you must define each data drive explicitly, like this:

data d1 /mnt/disk1
data d2 /mnt/disk2
data d3 /mnt/disk3

Each data entry tells SnapRAID:

  • Which disks hold your files
  • Which disks need to be included in parity calculations
  • Where to look when checking for data integrity

Allows SnapRAID to Detect Changes and Prevent Corruption

SnapRAID doesn’t automatically track file changes, you need to run snapraid sync to update parity.

By listing your data drives in snapraid.conf, SnapRAID knows:

  • Which files were added, modified, or deleted
  • When to update parity data
  • How to detect bit rot (silent file corruption)

Without these entries, SnapRAID has no way of knowing which files exist and cannot protect them.

Ensures Proper Data Recovery After a Drive Failure

If a drive dies, SnapRAID uses the parity data to reconstruct lost files. However, this only works if:

  • The missing drive was listed in snapraid.conf
  • A valid parity file exists
  • the remaining data disks are intact

If you forget to list a data drive in snapraid.conf, SnapRAID won’t protect it. That means if the drive fails, your files are permanently lost because they were never included in the parity calculations.

Enables Flexible Storage Expansion

One of SnapRAID’s strengths is drive flexibility. You can add new data disks of any size at any time. By mounting the new drive and adding it to snapraid.conf:

data d4 /mnt/disk4

After running snapraid sync, the new disk will be included in parity protection.

Unlike traditional RAID, you do not need to rebuild or reformat your entire array. Just add drives as needed.

Defining data drives in snapraid.conf is critical for SnapRAID to function correctly. Without these entries, SnapRAID will not know what to protect, cannot detect changes, and will not be able to restore lost files.

If you care about keeping your media safe, make sure every data drive is listed in snapraid.conf and remember to run snapraid sync regularly.


Installing SnapRAID

If you’re using Debian/Ubuntu, installing MergerFS is simple. SnapRAID is available in the official package repository:

sudo apt update && sudo apt install snapraid -y

To verify that SnapRAID is installed, run:

snapraid status

This command should return:

Self test...
No configuration file found at '/etc/snapraid.conf'

Configuring SnapRAID

Planning Your SnapRAID Setup

Before configuring SnapRAID, you need to plan:

  • How many data disks? SnapRAID protects your data by storing parity on a separate drive, so you’ll need at least one data disk and one parity disk.

  • How much parity? One parity disk protects against one drive failure, two parity disks protect against two failures, and so on.

  • Which drives hold parity and content? The parity disk should have enough free space for the parity data, while your content should be spread across multiple data drives for better redundancy and organization.

Creating the SnapRAID Configuration File

The main configuration file for SnapRAID is /etc/snapraid.conf. Open it in a text editor:

sudo nano /etc/snapraid.conf

A basic configuration for three data disks and one parity disk looks like this:

# Parity file - stored on the largest disk or a dedicated parity drive
parity /mnt/disk3/snapraid.parity  

# Content files - store metadata; should be on multiple drives for redundancy
content /mnt/disk1/snapraid.content  
content /mnt/disk2/snapraid.content  

# Data drives - these contain actual files
data d1 /mnt/disk1  
data d2 /mnt/disk2  
data d3 /mnt/disk3  

NOTE: You can see that both disk 1 and disk2 are use for content and data.

Key Points to Consider

  • Parity Drive: Should be the largest or have enough space for parity data.

  • Content Files: Should be placed on multiple drives for redundancy.

  • Data Drives: List each drive that stores actual files.

Additional SnapRAID Options

For better protection and logging, add:

# Define the block size used for parity calculations (default is 256K)
block_size 256  

# Auto-save changes to the content file before syncing
autosave 300  

# Enable scrub (data integrity check) with a limit on recovered errors
scrub_percent 10  
scrub_recover 5  

Save and exit the file (CTRL + X, then Y, then Enter).


Running SnapRAID for the First Time

Step 1: Perform an Initial Sync

The first time you run SnapRAID, you need to create the initial parity information. Run:

sudo snapraid sync

This process can take a long time (hours to days), depending on the size of your data. Once completed, SnapRAID will have recorded parity data, allowing you to recover files if a drive fails.

Step 2: Verify Data Integrity

SnapRAID doesn’t automatically detect changes, so you need to check for issues periodically:

sudo snapraid check

This command compares stored parity data with the actual files to detect corruption.

Step 3: Scrubbing for Bit Rot

Over time, files can become corrupted due to bit rot. SnapRAID can scrub files to detect and correct errors. Run:

sudo snapraid scrub -p 10
  • -p 10 limits scrubbing to 10% of files, reducing disk wear.
  • Scrubbing should be run periodically to catch issues before they become serious.

Step 4: Recovering a Lost Drive

If a drive fails, don’t panic! SnapRAID can restore its data. First, replace the failed drive with a new one and mount it in the same location. Then run:

sudo snapraid fix

SnapRAID will reconstruct the missing data using the parity drive.

Automating SnapRAID Maintenance

To keep your system safe, schedule SnapRAID syncs and scrubs automatically. Open the crontab:

crontab -e

Add the following lines:

0 3 * * * /usr/bin/snapraid sync
0 4 * * * /usr/bin/snapraid scrub -p 10
  • Sync runs daily at 3 AM to update parity.
  • Scrub runs at 4 AM to check for silent corruption.

Save and exit (CTRL + X, then Y, then Enter).


Why MergerFS and SnapRAID Make the Perfect Combo

By combining MergerFS and SnapRAID, you get:

  • Simple storage management – All your drives show up as one.
  • Flexible disk usage – Mix and match drives of different sizes without hassle.
  • Data redundancy – SnapRAID safeguards your data against disk failures.
  • Low resource usage – No constant disk mirroring like traditional RAID.

This setup is perfect for media servers, where most of the data is read-only. If a drive fails, you can easily restore it without losing everything.


Final Thoughts

Setting up SnapRAID with MergerFS is a game-changer for media storage. It keeps your files organized, accessible, and protected.

Now that you know how to get it up and running, it’s time to safeguard your media collection!