717 Ohio Ave #161 Wichita Falls, TX 76301

1 -(940)-536-3161

Guide – OrangePi NAS Expansion Board, Headless NAS Setup Part 2

Guide – OrangePi NAS Expansion Board, Headless NAS Setup Part 2

Today we set up a OrangePi Zero with a NAS Expansion board as a headless NAS. This is quite a lengthy tutorial so feel free to refer to the written version for a quicker study.

You can purchase the OrangePi Expansion board here.

OrangePi Zero NAS Setup Part 2

This tutorial is written mainly for Windows users, Mac and Linux users will need to replace tools such as Zip File Extraction programs, Disk Image Utilities, and SSH programs with flavors compatible with their systems, the rest of the content will still be applicable.

If you have not read Part 1 of this guide click here!

Step 5 – Setup SMART Monitoring Tools

Install SMART Monitoring Tools

First step to setting up SMART monitoring tools on our headless NAS is to install the SMART monitoring tools package, we do this with the following command:

sudo apt-get install smartmontools

Check if your disk can be monitored

Almost anything manufactued recently has SMART monitoring built in, but to check if your drive does use:

sudo smartctl -i <disk>

If you get the error “Unknown USB Bridge” then we need to specify the type of interface that the Hard Drive is communicating with by adding a flag to the same command:

sudo smartctl -d sat -i <disk>

Since I needed to specify this interface I am assuming you will need to as well and will be adding it to all of the following commands.

Enable SMART Monitoring

SMART monitoring is typically enabled by default, but this command will verify that everything is on and active:

sudo smartctl -d sat -s on -o on -S on <disk>

Initial health check

Before we self-test you can see if the drive has failed a self-test before with this command:

sudo smartctl -d sat -H <disk>

Complete a short self-test

If you would like to do a long test instead substitute short with long in the following command, just be forewarned that long test can be hours long:

sudo smartctl -d sat -t short <disk>

Check results of self-test

Once the estimated run time of the test has elapsed, you can check it by using:

sudo smartctl -d sat -l selftest <disk>

Step 6 – Setup Automatic Disk Monitoring

Edit smartd configuration file

sudo nano /etc/smartd.conf

Check that each line that begins with “DEVICESCAN” and comment it out by adding a “#” at the beginning of the line.

Then add the following line at the end of the file:

<disk> -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m <email> -M exec /usr/share/smartmontools/smartd-runner -M test

Substitue the email with an email you would like to receive notifications at. Just note the “-M test” in this line sends a test notification. Right now I am adding this line to test email notifications, later we will be removing it.

Set SMART Monitoring to automatically start with server

We do this by editing the smartmontools configuration file with following command:

sudo nano /etc/default/smartmontools

Find the line “start_smartd=yes” and remove the comment “#” from the beginning of it then save.

Restart SMART monitoring tools

sudo /etc/init.d/smartmontools restart

If the service will not restart go back and check the configuration files for errors.

Step 7 – Email Notifications

With the restart you should have been sent a email notification, so go check your email now, but don’t be surprised when you find nothing there.

The reason for this is that there is no email service setup in the linux image we are using for this NAS, so we will have to set this up ourselves as well.

Install Postfix

The easiest was to do this is to install the mail utilities package with the following command:

sudo apt-get install mailutils

During the install you will be asked to configure postfix, for the first option, picking an internet site is fine. For the second part, if you own a domain that would be the preferable choice, if you do not, entering the domain of your email provider is a distant second that will work. So if your email is lazypc@yahoo.com use yahoo.com.

Set Postfix to only send emails from localhost

To help prevent our NAS from becoming a spambot, we will set it to only send emails that originate from the server itself by editing the postfix configuration with the following command:

sudo nano /etc/postfix/main.cf

Look for the line that says “inet_interfaces = all” and change it to “inet_interfaces = localhost”

Restart Postfix

sudo service postfix restart

Test Email

Next we will see if emails are now working properly by sending ourselves an email with the following command:

echo "This is the body of the email" | mail -s "This is the subject line" <email>

Now check your email and if you don’t see a email in your inbox check your spam folder as well. You should have a email, and if it is in your spam folder, whitelist it now to make sure you don’t miss any future notifications.

Test SMART Email

If you have received your test message you know that your email service is working, so now we restart the SMART monitoring service to make sure that it is capable of sending emails as well.

sudo /etc/init.d/smartmontools restart

Remove SMART test flag

Edit the configuration file with the following command and remove the “-M test” from our configuration line:

sudo nano /etc/smartd.conf

Extra – Simple Benchmark

A simple benchmark built into linux you can use is as follows

sudo hdparm -Tt <disk>

With that you should have a self-monitored NAS that will hopefully notify you in case of a drive failure. There are occasions where dives fail without any SMART indication of failing, and most drives that fail only have one SMART flag indicating failure. So if you do get a SMART failure notification, don’t wait. Backup that drive now.

Share this with friends

Leave a Reply