Setting up an UPS for Synology NAS, Odroid and Arch Linux

To protect data residing on my Synology NAS I’ve bought and installed an UPS, an APC 700U to be exact. The trigger for buying and installing one was the loss of (some) disk data event that happened to family member external hard disk due to power loss. The data recovery cost was higher than buying an UPS and of course the lack of backups added to outcome of that event.

While no Synology NAS was involved on the above data loss, I know first hand that backups by themselves only add one layer of protection to possible data loss, and since from time to time I also have some power loss events, it was just a matter of time that my NAS might be hit by an unrecoverable power event, and, who knows, data loss.

So buying an UPS just might be a good idea…

Anyway the UPS from APC that I bought has an USB port allowing it to be connected to the Synology, which allows the UPS to be monitored and also allows the NAS to gracefully shutdown before UPS battery exhaustion. As a bonus it also allows to run an UPS monitoring server where other devices that share the same UPS power source can be notified of a power event through the network. Just keep in mind that the network switch or router must also be power protected…

Installing the UPS:
Installing the UPS is as simple as power down all devices that will connect to the UPS: Synology NAS, Odroid, external hard disks, PC base unit and network switch, and connecting an USB cable from the UPS to the back Diskstation USB ports.

After starting up, just go to DSM Control Panel and select Hardware & Power and then the UPS tab. Enable the UPS by ticking the Enable UPS support and also enable the UPS server to allow remote clients by ticking Enable UPS Network Server:

UPS Configuration

We can see by pressing the Device Information button that the UPS was correctly detected:

UPS Device Information

To end the configuration we need to press the Permitted DiskStation Devices and add the IP’s address of the devices that also have their power sources connected to the UPS and will also monitor the power status, in my case the IP of Odroid and my home PC.

And that’s it.

Setting up Arch Linux
Interestingly I dind’t found the NUT tools (Network UPS tools) on the core Arch repositories, but they are available at the AUR repository:

 yaourt -S network-ups-tools nut-monitor

The above packages will install the core NUT tools and a graphical monitor.

We can now scan our network for the ups:

nut-scanner -s 192.168.1.16
Scanning USB bus.
Scanning SNMP bus.
Scanning XML/HTTP bus.
Scanning NUT bus (old connect method).
[nutdev1]
        driver = "nutclient"
        port = "ups@192.168.1.16"

With the UPS reference found, we can now query it:

 upsc ups@192.168.1.16
 
Init SSL without certificate database
battery.charge: 100
....
....
battery.voltage: 13.9
battery.voltage.nominal: 12.0
device.mfr: American Power Conversion
device.model: Back-UPS XS 700U  
....

We can check the load, for example, with:

upsc  ups@192.168.1.16 | grep load
Init SSL without certificate database
ups.load: 37

We need now to modify the following files on /etc/ups:

  1. nut.conf
  2. upsmon.conf

First, as root, we copy a file from upsmon.conf.sample to upsmon.conf and add the following line:

MONITOR ups@192.168.1.16 1 * * slave

after the other commented out MONITOR lines. Since I’m only monitory, I’ve just put * at the username and password for authentication.

On nut.conf, we change the line MODE to MODE=netclient

After changing the files, we enable and start the UPS monitoring service:

sudo systemctl enable nut-monitor
sudo systemctl start nut-monitor

We are now monitoring the UPS status through the network. Keep in mind that the hub/switch power should also be connected to the UPS.

For monitoring we can use the nut-monitor application to see the UPS status in a nicer way:

NUT Monitor

To make the application easier to use, we can create a profile and save it, and when calling the application nut-monitor, we pass the profile name with the -F switch.

Setting up Odroid
To allow Odroid to monitor the UPS status through the Synology UPS server we need to also install the nut UPS tools (the same used by Arch Linux and DSM):

 apt-get install nut

The configuration steps for Odroid are the same as the Arch Linux steps, but since Odroid is running an Ubuntu variant, the files are located on a different path: /etc/nut.

To start the monitoring with the new configuration we just do /etc/init.d/ups-monitor restart.

Authentication
If authentication is needed, on the Synology disk, check the NUT configuration files located at /usr/syno/etc/ups/.

The upsd.users file has the user and password defined by default by the NUT tools on DSM.

Advertisements

Synology Mail Station with POP3 retrieval – Hibernation issues

After installing and enabling Synology Mail Station (RoundCube), I added a POP3 external account, so that account’s mail also was available at RoundCube’s interface on my Synology.

The issue is that after that change/configuration the NAS didn’t hibernate any more.

I thought that the issue was related to the pooling interval to the POP3 account, and I was right, it was set to 5 minutes by default. I’ve changed to 4 hour’s (240 minutes), but checking the logs I could see that the pooling was still at 5 minutes… and still the NAS wouldn’t hibernate.

So a quick check I’ve found out that the fetchmail process that fetchs the mail from the external POP3 accounts reads it’s configuration files from /var/packages/MailStation/target/roundcubemail/ext

In my case the POP3 account was defined on the admin accounts, and so there is an admin_fetch file, which might be different if other users are using the POP3 external accounts feature.

Editing this file there is a line

#### .fetchmailrc
set daemon 300

Which means pooling every 5 minutes (300 seconds)

I’ve changed the value to 21600 (6 hours), and waited for the next NAS restart.

After that pooling was set to every 6 hours and the NAS does hibernate now.

Didn’t bother to much to see how to restart the fetchmail process without rebooting the NAS, but probably restarting the Mail Station packages will suffice.

Synology, MySQL and PHPMyAdmin

One of the packages available for installation on the Synology NAS is the PHPMyAdmin application that allows to use the web to administer the embed MySQL.
The problem with this is that the PHPMyAdmin will also available on the root web server of the Web Station package, and if this package is exposed to the internet, then PHPMyAdmin application will also be exposed… a big no-no security wise…

My quick solution is not to install this PHPMyAdmin package, and since I seldom access the MySql package, a better alternative, yet not “light” is to use the Desktop Application MySQLWorkbench: http://www.mysql.com/products/workbench/ to access and administer your databases.