zfs pool status

FreeNAS file server

A constant topic of discussion with the people I know seems to be storage at home so I thought I might as well try to sum it up here;

On my home file server I run freeNAS. There are several reasons for this but the FreeBSD backend, ZFS and being able to run from a usb stick are some that weighs in heavier than other.

Hardware
The hardware is based around a X7SPA-H atom 510 based server board from Supermicro, 4GB of Ram, 4 2TB harddrives (a somewhat unfortunate mix of 3 wd caviar green and a Seagate) and a 64gb OCZ-Agility3 ssd. This is all tucked into a Fractal Design Define R2 chassis.

My current pool looks like this:
zfs pool status
Just a basic 4 drive raid-z with an ssd l2arc cache.

Disks added in the future will be in mirrors and a move away from the current raid-z. The reasons for that is enough for another post, but mainly performance.

Scripts
I have a couple of scripts for things such as alerting me if there is a problem with a disk or the raid-z. (In addition to the nightly emails).

zpool status check and alert:
#!/bin/sh
#
# Simple script to get status of a ZFS tank
# Could use some error handling etc..
# Henrik Anders?n 20110511
# Version 0.0.4 20120830
# This version also takes care of the notification via SMS of any errors.
#

# All the fancy settings:
MAILTO=”zfsmanager@domain.se”
MAILFROM=”void@mydomain.se”
MAILSUBJECT=”zfs pool errors on void.mydomain.se!”
SMSTO=07XXXXXXXX
SMSMSG=”ALERT! problem with zpool ${1} on ${HOST}!”
SMSAUTHHASH=”paste hash here”

# Very advanced script foo follows:
state=`zpool status ${1} | tail -n 1`

if [ “${state#*errors: }” != “No known data errors” ]; then
zpool status | mail -s “$MAILSUBJECT” “$MAILTO”
#send sms
fetch -q -o $$.sms “http://10.10.0.113/sms/API/0.2/send.php?h=${SMSAUTHHASH}&r=${SMSTO}&m=${SMSMSG}”
rm $$.sms
fi

exit 0

In the past I have run in to issues with /var getting filled up by RRD data, so I monitor that too:
#!/bin/sh

# Simple script to monitor usage of the filesystem given as parameter
# 20130108 Henrik Andersen
#
# Version 0.2

SMSTO=07XXXXXXXX
SMSMSG=””
SMSAUTHHASH=”insert-auth-hash-here”

WARN=89
USAGE=`df -h | tail -n 1 | awk ‘{print $5}’ | sed -e ‘s/\%//’`

if [ ${USAGE} -gt ${WARN} ] ; then
SMSMSG=”Warning! Usage of ${1} on ${HOST} is ${USAGE} percent”
#send sms alert.
wget -q -O /dev/null “http://10.10.0.113/sms/API/0.2/send.php?h=${SMSAUTHHASH}&r=${SMSTO}&m=${SMSMSG}”
exit 1
fi

exit 0

Nothing fancy but I do believe that sharing is caring.

I also use another script to notify me of various things such as any reboots or UPS events but that is perhaps another story.

Remember to scrub the pool at least weekly, I do this from cron but freenas has a config option for this now.

Redundancy
In addition to running raid-z which lets the pool survive a failed drive (I would go for mirrors or maybe raid-z2 if setting it up today) I also rely on regular snapshots to save me from accidental deletions and the like.
Having my bases covered with snapshots and the raid is good but only as long as I have a system to run it on. So I run weekly email backups of the configuration database and the occasional simple dd of the USBstick to a backup stick that is disconnected after the backup is done to protect from anything that might fry the server. (occasionally means very rarely (which means at least once))

Script for emailing the config:
#!/bin/sh

#
# Simple script to be run as a cron job to email the system config.
# Henrik Andersén 20120223
#

CONFIG=”/data/freenas-v1.db”
MAILTO=”freenasadm@domain.se”
SUBJECT=”Weekly backup of config from void.mydomain.se”
MAILTEXT=”This is the current version of the config database.”

(echo ${MAILTEXT}; uuencode ${CONFIG} ${CONFIG}) | mail -s “${SUBJECT}” ${MAILTO}

exit 0

dd of system:
[root@void] ~# dd if=/dev/da0 of=/dev/da1 bs=16k

ZFS is a great file system with lots of great features and I hope to do a lot more with it in the future.

Share

4 thoughts on “FreeNAS file server

  1. Frid

    thought about using compression on the zpool? as it is almost zero overhead on ZFS compression

  2. henrik Post author

    @Frid Actually there is some overhead with compression, but depending on how modern CPU and slow disks your have the net result might actually be some performance gain in R/W. I use it on the volume I have my time machine backup on (currently gives me 1.25x) but much of my other big space consumers are already compressed data so it would be a bit of a waste to enable compression on them. I will however experiment more with this..

  3. Pingback: Updates to a couple of my FreeNAS scripts | henrikandersen.se

  4. Pingback: Gregory Smith

Leave a Reply

Your email address will not be published. Required fields are marked *