UPS … secure my data?

Why should I …

think about to protect my @home NAS with a UPS?

Initially I wasn’t keen on add a UPS to my home network. Clear it cost money and consume energy for what?

So why I go for that and start the next small project:

  • My impression is that the Government decision to move away from conventional energy increase the risk of energy failure
  • I want to be sure that my private data is better protected from energy failure

so let’s start what I’m going to do.

  • add an UPS
  • think about the network (probably VLAN project)
  • add new power plug

… let’s start

Well I think about to let serve two NAS from the UPS. My plan is to autoshutdown the first by the UPS  and second will be shutdown from the first via ssh issued shutdown command.

local server: ssh -t <remote user>@<remote server ip> 'sudo shutdown -h now'

Configure autologin via ssh on local server, where ssh key is already present:

local server: scp ~/.ssh/ <remote user>@<remote server ip>:

Login to remote server

remote server: cat ./ >> ~/.ssh/authorized_keys
remote server: rm ./
remote server: chmod 600 ~/.ssh/authorized_keys
remote server: exit

Now check if ssh login is working. You’ll login without been prompted to enter the password.

local server: ssh <remote user>@<remote server ip>
remote server: _



…select the UPS

To select a UPS isn’t such easy as I thought. First I think about the requirements.

  • shutdown a server
  • colour should be black
  • high max 20 cm
  • capacity not smaller then 500va

As the conclusion I go for Apc bakup ups 700va. Yes oversized, but I don’t know what I’ll add in the future.

Configure the UPS on OMV

  1. Installing the openmediavault-nut plugin.
  2. Configure the UPS plugin by entering the driver setup (no spaces, otherwise the service isn’t running)
  3. Check that the service is running

… shutdown the second NAS

The solution is simple and with a short skript fast to implement.

Setup a small support script to shutdown both NAS

I call the script

local server: cat
logger "UPS Shutdown:Send shutdown to diskstation"
ssh -t root@<other NAS ip> nohup /sbin/poweroff /sbin/shutdown -h +0

Update the upsmon.conf

On the local server I update the upsmon.conf file to call the new script and change the shutdown variable from

local server: cat /etc/nut/ | grep SHUTDOWNCMD 
SHUTDOWNCMD "/sbin/shutdown -h +0"


local server: cat /etc/nut/upsmon.conf | grep SHUTDOWNCMD

Finally reload the UPS config.

Stop spaming your OMC mail with NUT messages

If you OMC mail is spammed by messages from nut that a mail can’t be delivered it might be releated to the fact that the weekly driver update can’t be done. As the issue is not new you can follow the thread discussion the solution or execute the following command to get the issue fixed.

Check as root if your update script is working properly:

local server: update-smart-drivedb
/usr/share/smartmontools/drivedb.h.error: rejected by /usr/sbin/smartctl, probably no longer compatible

Call the sed command to change the source:

local server: sed -i "/^SRCEXPR/{s#=.*#='\$location/smartmontools/drivedb.h?format=raw'#}" $(which update-smart-drivedb)
local server: update-smart-drivedb
/usr/share/smartmontools/drivedb.h updated from branches/RELEASE_5_41_DRIVEDB

Change generic file of postfix

local server: grep nut /etc/postfix/generic
nut@OpenMediaVault.localdomain <your target email>

Create the new generic.db and reload the configuration

local server: postmap /etc/postfix/generic
local server: service postfix reload

That’s it.

… power planning

I need a new power plug, because the UPS might consume a lot during recharging the battery. To be on the save side I put a 3.5kW power plug from Brennstuhl.

… connect the net

Add a 5 port trendnet switch to connect the 2 NAS and link it to the rest of the network.

Gap in the solution

Well the solution of shutdown the second NAS is just working when the NAS connected to the UPS is running. To fix this, I would need

  1. to connect the UPS to both, unfortunatelly not possible
  2. somehow wakeup the connected NAS
  3. let it keep the connected NAS to the UPS longer then the not connected NAS

Option is expensive as requires specific hardware, and option 2 I’ve no clue how to fix. So I choose the option 3. It’s the best solution in terms of cost and complexity.


Project closed at 31.01.2016.


2016-01-31: Finish project

2016-02-04: Fix the mail spam by NUT driver update