1. Home
  2. Linux

How to set up SnapRAID on Ubuntu server

SnapRAID is an easy, software RAID system for Windows and Linux systems that allows users to set up a drive pool to house data easily. The program is free of charge, is open source, and runs on most Linux operating system with ease. In this tutorial, we’ll be focusing on setting up SnapRAID on Ubuntu server.

Note: though this tutorial focuses on Ubuntu server, it’s possible to follow the instructions and set it up on other Linux operating systems. The instructions are near identical.

Before we begin

For SnapRAID to work correctly, you’ll need to have four hard drives. Ideally, the hard drives should be the same size, and hard drives must be formatted with the same file system (Ext4.) On  Ubuntu Server, the quickest way to accomplish this is to format with Cfdisk. To start the formatting process, go to the Ubuntu server console, or, SSH in remotely and use the command syntax below. Keep in mind that you will need to repeat this process four times so that each hard drive has the same filesystem, etc.

Note: please replace the X with the actual label of the drive you wish to format.

sudo cfdisk /dev/sdX

Once the CFdisk partition editor is open in the console, use it to delete existing filesystems on the hard drive. Then, create a new Ext4 partition that takes up the entire size of the drive. When done editing and formatting, select “Write” to save the changes, and “Quit” to exit.

Install SnapRAID

On Ubuntu, you’ll be able to get the SnapRAID software very quite quickly. The reason for this is that the developer maintains a software PPA which is available for Ubuntu Server, as well as the Ubuntu Desktop distribution. To add the PPA to Ubuntu Server, you must first enable PPA support.

sudo apt install software-properties-common

With the PPA software up and running, it’s time to add the SnapRAID software repository to the system.

sudo add-apt-repository ppa:tikhonov/snapraid

Run the update command to refresh Ubuntu, so that the SnapRAID PPA can be fully integrated into your Ubuntu system.

sudo apt update

Finally, install the SnapRAID software.

sudo apt install snapraid

Create SnapRAID directories

If you want to use the SnapRAID software correctly on Ubuntu, several different folders must be set up. These directories are for the drive mounts, as well as the data pool. The first folder you must create is the one that will go in /var/.

sudo mkdir -p /var/snapraid/

Next, several folders must be created in the /mnt/ directory. Five of them to be exact. To make all of these folders with one easy command, do the following:

sudo mkdir -p /mnt/{disk1,disk2,disk3,disk4,data}

SnapRAID configuration file

Now that the directories are set, it’s time to set up the SnapRAID configuration file. To do this, open up the snapraid.conf file in Nano with the command below.

sudo nano -w /etc/snapraid.conf

First, look through the configuration file and search for the line that says "# Format: "parity FILE_PATH" Under this line, erase the code there and replace it with:

parity /mnt/disk4/snapraid.parity

Next, move down to the line in the configuration file that says "# Format: "content FILE_PATH". Erase the lines directly below it. Replace it with these four lines.

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

Move on down the file past the Content section and locate the line in the configuration file that says "# Format: "disk DISK_NAME DISK_MOUNT_POINT". Once again, remove all of the code directly below it and replace it with the code below.

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

Lastly, move down the configuration file and locate the "#pool /pool" line. Under it, specify the /mnt/data directory.

pool /mnt/data

After specifying the location of the data pool in the configuration file, save the edits by pressing Ctrl + O. Then, close the editor with Ctrl + X.

Configure SnapRAID drive mounts

SnapRAID requires all of the hard drives set up in the /etc/fstab file. To add these drive mounts, go to the terminal and do the following.

Step 1: Run the blkid command on each of your hard drives. This command will tell you the UUID. Be sure to replace X with the drive letter and Y with the partition number (aka /dev/sdb1, etc.)

sudo blkid /dev/sdXY

Step 2: Copy the UUID output from the blkid command for each drive partition, and save it to a text file in your favorite text editor for later.

Step 3: Use the following echo commands to quickly write in your drive mounts in the /etc/fstab file. Be sure to replace “example-uuid” with the UUIDs you saved in the text editor.

sudo -s

echo ' ' >> /etc/fstab
echo '# Drives for SnapRAID configuration' >> /etc/fstab
echo 'UUID=example-uuid /mnt/disk1 ext4 noatime,defaults 0 0' >> /etc/fstab
echo 'UUID=example-uuid /mnt/disk2 ext4 noatime,defaults 0 0 ' >> /etc/fstab
echo 'UUID=example-uuid /mnt/disk3 ext4 noatime,defaults 0 0' >> /etc/fstab
echo 'UUID=example-uuid /mnt/disk4 ext4 noatime,defaults 0 0 ' >> /etc/fstab

Step 4: Use the following echo commands to add the AUFS drive pool into your /etc/fstab folder.

echo ' ' >> /etc/fstab
echo '#SnapRAID AuFS mount' >> /etc/fstab
echo 'none /mnt/data aufs br=/mnt/disk1=rw:/mnt/disk2=rw:/mnt/disk3=rw,create=mfs,auto 0 0' >> /etc/fstab

Step 5: Reboot the Ubuntu server. When it comes back online, all drives will be loaded into the correct folders ready to use with SnapRAID.

Start using SnapRAID

With all the directories mounted and the software installed, SnapRAID is ready to use. Now all that’s left is to place data in the pool directory. To do this, gain a root shell in your Ubuntu server’s command-line shell. Then, follow the command-examples below to place files and folders onto the drive pool.

Put single files on SnapRAID pool

sudo -s

cp /path/to/single/file /mnt/data

Put directories on SnapRAID pool

sudo -s

cp -r /path/to/folder/ /mnt/data

When your data is in the SnapRAID pool, run the snapraid sync command to sync up the data.

snapraid sync

Leave a comment