{{tag>snapraid linux}}
======snapraid======
I have been using [[https://www.snapraid.it/|snapraid]] since circa 2015 for my main first past redundancy. I have a second home server used as a backup server that weekly backs up using [[home_server:home_server_setup:other_services:back-up_server#restic]].
The main snapraid commands I use are:
''sudo snapraid sync'' to sync the files that have changes since last sync. I usually do this weekly, manually.
''sudo snapraid scrub'' to check the parity of the array, usually the oldest files first. I usually do this weekly, manually.
''sudo snapraid status'' to check the status of the array. I usually do this weekly, manually.
''sudo snapraid touch'' to add sub-second time granularity to the files that improves snapraid usage. I usually do this weekly, if reported as requried by status, manually.
''sudo snapraid smart'' to check the smart status of the array drives (does not report on nvme drives). I usually do this weekly, manually. Really for information only.
Snapraid allows files and directories that have been deleted since the last sync to be recovered.
*''snapraid diff --test-fmt path''
*''snapraid diff --test-fmt disk'' This will let you know the data disk from snapraids array perspective
Snapraid does not expect you to provide the absolute file system path when fixing files.
*''snapraid fix -m'' This will recreate any deleted file in the entire array
*''snapraid fix -m -d d1'' This will recreate any deleted file on data disk d1
*''snapraid fix -m -f Example/'' This will recreate the contents of any folder named Example anywhere in the array
*''snapraid check -m -f Example/ -v'' If you are unsure what will happen you can replace fix with check above and add -v with this. Snapraid will then tell you that there is a problem with each of the files matching the filter or that they are ok.
The main snapraid configuration file ''/etc/snapraid.conf''
++++Install Snapraid on Linux|
Some good references are [[https://zackreed.me/setting-up-snapraid-on-ubuntu/|Setting up SnapRAID on Ubuntu to Create a Flexible Home Media Fileserver]] and [[https://havetheknowhow.com/configure-the-server/install-snapraid/|How to install and configure SnapRAID on Ubuntu Server]]
apt-get install gcc git make -y
cd
wget https://github.com/amadvance/snapraid/releases/download/v13.0/snapraid-13.0.tar.gz
tar xzvf snapraid-13.0.tar.gz
cd snapraid-13.0/
./configure
make
make check
make install
cd ..
cp ~/snapraid-13.0/snapraid.conf.example /etc/snapraid.conf
cd ..
rm -rf snapraid*
++++
++++My main server configuration files, /etc/snapraid.conf|
I probably should check this configuration file against the latest version example. My current operating version is 12.0 (2021/12) the latest version is 13.0 (2026/03), there looks to be mainly some minor optimisations and bug fixes.
# Example configuration for snapraid
# Defines the file to use as parity storage
# It must NOT be in a data disk
# Format: "parity FILE [,FILE] ..."
parity /media/disk3/snapraid.parity
# Defines the files to use as additional parity storage.
# If specified, they enable the multiple failures protection
# from two to six level of parity.
# To enable, uncomment one parity file for each level of extra
# protection required. Start from 2-parity, and follow in order.
# It must NOT be in a data disk
# Format: "X-parity FILE [,FILE] ..."
#2-parity /mnt/diskq/snapraid.2-parity
#3-parity /mnt/diskr/snapraid.3-parity
#4-parity /mnt/disks/snapraid.4-parity
#5-parity /mnt/diskt/snapraid.5-parity
#6-parity /mnt/disku/snapraid.6-parity
# Defines the files to use as content list
# You can use multiple specification to store more copies
# You must have least one copy for each parity file plus one. Some more don't hurt
# They can be in the disks used for data, parity or boot,
# but each file must be in a different disk
# Format: "content FILE"
content /home/snapraid.content
content /media/disk1/snapraid.content
content /media/disk2/snapraid.content
# Defines the data disks to use
# The name and mount point association is relevant for parity, do not change it
# WARNING: Adding here your /home, /var or /tmp disks is NOT a good idea!
# SnapRAID is better suited for files that rarely changes!
# Format: "data DISK_NAME DISK_MOUNT_POINT"
data d1 /home/shared
data d2 /media/disk1/
data d3 /media/disk2/
# Excludes hidden files and directories (uncomment to enable).
#nohidden
# Defines files and directories to exclude
# Remember that all the paths are relative at the mount points
# Format: "exclude FILE"
# Format: "exclude DIR/"
# Format: "exclude /PATH/FILE"
# Format: "exclude /PATH/DIR/"
exclude *.unrecoverable
exclude /tmp/
exclude /lost+found/
exclude /.Trash-0/
exclude /*.vhdx
exclude .thumbs.db
exclude /VMs/
exclude /home/shared/www/html/logs/
exclude logs/
exclude log/
#exclude .config/
exclude .cache/
exclude /home/baumkp/.vnc/
exclude .log
# Defines the block size in kibi bytes (1024 bytes) (uncomment to enable).
# WARNING: Changing this value is for experts only!
# Default value is 256 -> 256 kibi bytes -> 262144 bytes
# Format: "blocksize SIZE_IN_KiB"
#blocksize 256
# Defines the hash size in bytes (uncomment to enable).
# WARNING: Changing this value is for experts only!
# Default value is 16 -> 128 bits
# Format: "hashsize SIZE_IN_BYTES"
#hashsize 16
# Automatically save the state when syncing after the specified amount
# of GB processed (uncomment to enable).
# This option is useful to avoid to restart from scratch long 'sync'
# commands interrupted by a machine crash.
# It also improves the recovering if a disk break during a 'sync'.
# Default value is 0, meaning disabled.
# Format: "autosave SIZE_IN_GB"
autosave 100
# Defines the pooling directory where the virtual view of the disk
# array is created using the "pool" command (uncomment to enable).
# The files are not really copied here, but just linked using
# symbolic links.
# This directory must be outside the array.
# Format: "pool DIR"
#pool /pool
# Defines a custom smartctl command to obtain the SMART attributes
# for each disk. This may be required for RAID controllers and for
# some USB disk that cannot be autodetected.
# In the specified options, the "%s" string is replaced by the device name.
# Refers at the smartmontools documentation about the possible options:
# RAID -> https://www.smartmontools.org/wiki/Supported_RAID-Controllers
# USB -> https://www.smartmontools.org/wiki/Supported_USB-Devices
#smartctl d1 -d sat %s
#smartctl d2 -d usbjmicron %s
#smartctl parity -d areca,1/1 /dev/sg0
#smartctl 2-parity -d areca,2/1 /dev/sg0
++++
=====Snapraid recover a failed disk=====
The [[https://www.snapraid.it/manual#sec4-4|Snapraid manual recover instruction]] explain the process. A point to remember is to be careful through the entire process to allows reference the correct device, both for the system HDD and Snapraid HDD.
My drives in my backup server were old, small in capacity and starting to report failures in 2025. Some of these drives were 9 years old with 60000+ operating hours. So I purchased 2 new WDC Red Pro 16TB drives to replace the drive in my main server and moved the older drives into the backup server. The backup server runs weekly using Restic to back-up the main server. Once set up the back-up server runs for an hour or so. In early November 2026 I was getting strange messages on one of my main server data drives and it was very slow and locking up the server. Using GSmartControl, a graphical tool to interrogate HDD smart parameters and sure enough the data disk was showing major problems, enough to merit immediate replacement. Back checking my log files showed the backup server script using Restic reported errors on the failed disk on Nov 2, but OK on 26 Oct. When I ran snapraid sync and scrub 31 Oct I did not see any errors. I notice the problems on 2 Nov, about 20 hours after the errors reported on the back-up server. The drive failed badly some time between 31 Oct and 2 Nov. I did not check the smart drive parameters since installing the new drives in Dec 2025, so I do not know if there were earlier warning of failure.
I have purchased a new WDC Red Pro 18TB drive to replace the failed 16TB unit. I purchased the 18TB drive as the 16TB drive cost more and was not readily available, also the prices have almost doubled in the past 10 - 11 months! I have started the RMA process with WDC to warranty claim on the old failed drive. I need to organise to send it back. My first time ever going through this process. I had a failed on arrival 4TB WDC Blue about 6 years ago, I forget whether I returned to WDC or the retail company now, it was a cheap unit for extra desktop gaming capacity on a old computer.
So now I am using Snapraid to rebuild the failed drive, it will be interesting to see how this goes. Fortunately the weather is not too hot so I should not be cooking the drive. That being said the current snapraid is set to stop at 50 ÂșC and allow the HDDs to cool down.
I need to fully check my other drives smart drive parameters to see if there are any concerns.
I not that my main server NVMe drive is showing 49 media and integrity errors with Available spare down to 82% and usage at 17%.
<- home_server:home_server_setup:other_services:index|Prev ^ home_server:home_server_setup:other_services|Start page ^ home_server:home_server_setup:other_services:timedate|Next ->