Setting up SnapRAID on Ubuntu to Create a Flexible Home Media Fileserver

Home Media Fileserver

Home Media Fileserver in Norco 4224 Case

I have SnapRAID setup to create a super flexible, reliable bulk media server. I have used SnapRAID for years across numerous versions of Ubuntu and a plethora of hardware. SnapRAID has been so reliable that I have updated hardware four times since I originally set it up, migrated through many versions of SnapRAID, added many data disks, added parity levels, and replaced disks all without issue.  All the while, it’s been super flexible and an awesome way to manage my bulk media.  I currently have a ridiculously over the top server than you can read more about here.  On it I use three parity disks and 21 data disks.

The first thing I do after any new install is update the system, and install my base packages.

After the reboot, let’s keep installing the packages we will need to build SnapRAID.

Finally, let’s install it.

Next, let’s cleanup.

Next, I’m going to partition the disks, so I need to grab a couple packages.

Let’s partition one, and copy the structure to the other disks.

Now, we will make a place to mount the disks. I mount them via /etc/fstab labeled by their device type and serial number as seen beloew. This makes the disk easier to identify in the event of a disk failure.

Setup a filesystem on each data disk (Note, I’m reserving 2% of the disks space so that the parity overhead can fit on the parity disk). You can set the reserved space to 0% if your parity disk(s) are all larger than your data disks (i.e. you have 6TB parity disks and 5TB data disks).

Put a filesystem on the parity disk (here I’m reserving 0%, or letting it use the whole disk for parity).

Get the device type and serial numbers like this, then add them to your /etc/fstab.

It should give you output like this.

You use the above to add them to /etc/fstab

It should look something like this.

As you may be able to see, the above shows the type of connection, in this case SATA, the Manufacturer of the disk, the part number of the disk, the serial number of the disk, and the partition we are using from the disk.  This makes indentying disks in the event of a failure super easy.

Mount the disks after you add them to /etc/fstab

Next, you’ll want to configure SnapRAID.

This is how I configured mine

Next, we need to create the path that we mentioned above for our local content file.

Once that’s complete, you should sync your array.

Since moving to SnapRAID 7.x, the above mentioned script no longer works. I have revised the script to accommodate dual parity, and to integrate the changes in the counters.

Finally, I wanted something to pool these disks together. There are four options here (choose your own adventure). The nice part about any of these is that it’s very easy to change later if you run into something you don’t like.

1. The first option is mhddfs. It is super easy to setup and “just works”, but many people have run into random disconnects while writing to the pool (large rsync jobs where causing this for me). I have since updated my mhddfs tutorial with some new FUSE options that seems to remedy the disconnect issue. mhddfs runs via FUSE vs. a kernel driver for AUFS, so it’s not as fast as AUFS and it does have more system overhead.

2. The second option is to use AUFS instead. The version bundled with Ubuntu has some weirdness with deletion and file moves with both it’s opaque and whiteout files. It also does not support exporting via NFS.

3. The third option is to use AUFS, but to compile your own versions to support the hnotify option and allow for export via NFS. This is where I landed for a few years after trying both of the above for many months/years.

4. This is what I use Finally, a solution that performs well and is easy to use. MergerFS (the solution I’m currently using). This is a FUSE based solution, but it’s fast and has create modes like AUFS. It’s also easy to install and requires no compiling unlike AUFS to get it working. This is what I use now, and it’s great and actively developed.

After choosing one of the options above, you should now have a mount point at /storage that is pooling all of your disks into one large volume. You’ll still want to setup a UPS and SMART monitoring for your disks. Another thing I did was write up a simple BASH script to watch my disk usage, and email me if a disk gets over 90% used, so I can add another disk to the array.

Next, I would strongly suggest you read my other articles to setup email for monitoring, SMART information monitoring , spinning down disks, setting up a UPS battery backup, and other raid array actions. Being able to cope with drives failing useful, but it’s nice to know that one has failed and be able to replace it too.

Updating in the future
You may wonder…”Hmm, I installed this fancy SnapRAID a while back, but the shiny new version of SnapRAID just came out, so how do I update?” The nice thing about SnapRAID is that it’s a standalone binary with no dependencies, so you can upgrade it in place. Just grab the latest version, untar, and install.

You can check your version like this.

Other Items:
If you would like to have encrypted SnapRAID disks, the following will go through that.



I love learning new things and trying out the latest technology.

You may also like...

21 Responses

  1. Dave Dave says:

    Awesome been looking for someone todo a more current SNAPRAID follow up. Thanks!!!

    • Zack Zack says:

      I’m glad you found this helpful Dave. I just migrated this content from my old site, though, so this has been an article I have updated for a couple of years now. Please let me know if you have any questions.

  2. Joe says:

    your first set of commands didn’t migrate over well;

    apt-get update && apt-get dist-upgrade -y && reboot

    should be
    apt-get update && apt-get dist-upgrade -y && reboot

  3. Joe says:

    ack it looks like my amp; amp; didn’t get written correctly in my post.

  4. oxzhor says:

    Hi Zack,

    Great post! normally i work with CentOS but you done nice work on Ubuntu 16.x.
    I buy a old Dell R510 and put a perc H310 into it and will follow your post to setup a backupserver.
    I keep you updated over how the project will go :).

    Keep the good work up!

  5. Savage702 says:

    Ok, got my first failing drive, next steps?

    The following warning/error was logged by the smartd daemon:

    Device: /dev/sdf [SAT], 2 Offline uncorrectable sectors

    Device info:
    WDC WD30EFRX-68EUZN0, S/N:WD-WMC4N0455643, WWN:5-0014ee-0ae519cc4, FW:80.00A80, 3.00 TB

    For details see host’s SYSLOG.

    I guess turning off Plex sync/updating and stopping new downloads, etc. Then just as simple as replacing drive, setting new drive up, updating config and running a sync?

    • Zack Zack says:

      Hello. Sorry to hear you have lost a disk. Your first steps are correct, I’d stop plex from updating and stop downloading. I would format the new disk and temporarily mount it somewhere for the time being.

      Since the old disk is still available, I would use rsync in a tmux session to transfer the data to the new disk from the old disk. Here is an example. Note the trailing slash. This copies the whole disk to the other one.

      Once this is finished, I would mount the old disk and mount your new disk in its same location. Next, you will want to get the replacement disk setup /etc/fstab so it mounts after a reboot. So, change the device name to match the new name.

      Finally, run a snapraid diff. At this point is should mention that theven UUID for the real ed disk has changed and moves won’t be optimal. As long as the number of deleted and updated files looks good, run a sync.

      Once that’s done, you can remove the failed disk and startup your shutdown services.

      For bonus points, check and see if your failed disk is under warranty. If, so submit and RMA and save the new disk that they send you as a backup disk.

      Let me know if this makes sense.

      • Savage702 says:

        Ok, makes sense, and thanks for that. I’m sure doing the rsync is better/easier/faster than letting it recover from parity. I ran a few status checks and tried a fix, 2 blocks with IO errors. I like these steps though, all the media will remain available for the kids today while this is doing it’s thing.

        I’m going through my stack of drives and making an inventory of which one is where in the stack, something I should have labeled 3 years ago when setting up. Better late than never. In doing this, I saw that I’m about 3 months out of warranty on my 3TB Red Drives… a little longer for 3 of them that I originally started with! (BOOO!!!)

        For 3 years, I’ve had a 3TB Red on standby, so broke that out of the static bag to realize it’s a re certified drive. 😐 Not thrilled about that, but will have a spare on hand by next week. I’ll make sure this time to get the drive all formatted and ready so it will be a much more plug and play scenario.

        • Zack Zack says:

          Sounds like a good idea. One other thing I always like to do with new drives (especially re-certified) before putting them into service is stress test them. I use something like this (this will destroy all data on the disk, so make sure it’s the right one).

          In your case where you have a missing disk, I’d just throw in the re-certified disk and get everything working. I’d stress test and format your new replacement disk when you get it prior to putting it into service.

      • Savage702 says:

        This can be safely ignored and just move along, correct?

      • Savage702 says:

        Thank you! I think I’m there, although it took all day to rsync the drive.

        WARNING! UUID is changed for disks: 'd4'. Move operations won't be optimal.

        134391 equal
        2 added
        0 removed
        187 updated
        0 moved
        0 copied
        0 restored
        There are differences!

  6. phuriousgeorge says:

    Found a little boo-boo in the instructions that made me have to double-back a little:

    cp ~/snapraid-10.0/snapraid.conf.example /etc/snapraid.conf

    Thanks for all your useful information you blog about, it’s really easy to follow and has done wonders to help me!

  7. oxzhor says:

    If you want to use two parity disk you can add it like:

    # Parity Disks
    /dev/disk/by-id/ata-hdd1-name-part1 /mnt/parity/1-parity xfs defaults 0 2
    /dev/disk/by-id/ata-hdd2-name-part1 /mnt/parity/2-parity xfs defaults 0 2

    thx for your feedback.

Leave a Reply