We all know what can happen to the data when power goes off, don’t we? We, of course have UPS set and ready, but it’s only sufficient for some amount of time depending on the UPS battery capacity. Finally, the UPS will get depleted and, bang, no power – data loss etc.
If we can’t afford for a backup generator, larger or few more batteries we have to simply switch off as much as we can before draining battery to 0%.
Almost all modern UPS have COM, USB or RJ45 connectors to connect to the PC/Server to monitor the condition of UPS and or battery. Most of them can shut down the computer (assuming your computer shut down is not taking 30minutes:)) but what if you have few computers and other data-sensitive equipment such as NAS?
In our environment there is one without ready to use command like “Remote Shutdown” but with some searching I managed to get what I wanted: Remote shutdown when server connected to the UPS shuts down.
Other thing is waking the NAS after power is back, but I will describe it at the end.
So what we need?
- UPS with monitoring interface, such as EATON 5115
- Management software – Eaton provides two: Intelligent Power Protector and LAN Safe (we use LAN safe)
- NAS storage, like Thecus N7700PRO, firmware 5.0.3.02
- plink,puttygen and PuTTY software. this can be found at www.putty.org
- some time…
I would like to thank putty team for providing very good documentation of their software.
Enabling remote shutdown(and then, remote power on) on Thecus N7700PRO consists of the following steps:
- Downloading and installing HISSH module (if it’s not already installed)
- Generating Private and Public Keys for PKI authentication over SSH
- Saving Public Key in N7700Pro config
- Checking if we can shutdown over SSH/PuTTY session
- Creating a .bat with plink.exe and it’s config
- Assigning above .bat to the shutdown task
- Enabling Wake-On-Lan in the Thecus N7700PRO
1. Download and install HISSH module
This can be done by either by automatic installer (if your Thecus is connected to the internet) or manually, both methods are well documented by Thecus, links below:
Manual installation described on page 124 in the user manual:
link to HISSH module:
After installation one, should be able to successfully connect using default credentials and Putty SSH connection
2. Generate PKI key pair for Putty
According to Putty documentation has to:
- Run PuttyGen.exe – I think this doesn’t need further explanations 🙂
- Configure options – I choose following options: Key type: SSH2-DSA, Key length: 1024bit
- Save public and private keys are also pretty simple, just click appropriate buttons but do not close this window (it will be used next)
3. Configure HISSH to authorize our keys
I did it with WinSCP, since I have limited trust to VI and CLI 🙂
Once you connect with WinSCP to thecues, you have to:
- Open/Edit file called: Authorized_Keys or Authorized_keys2 (depends on SSH version) located in /home/.ssh/ if file doesn’t exists, simply create it and copy and paste public key into the file replacing all data. It should look like:
You can if the connection with PKI works by selecting private key in PuTTY options. There’s a link if one, would have problems.
Save the connection in putty config. Mine is saved as NAS.
4,5,6 Remote Shut down of NAS
Once we configure and test PKI connection we can shut down or reboot our Thecus NAS using Plink by executing following command:
plink.exe -load NAS /img/bin/model/sysdown.sh poweroff
reboot command will be:
plink.exe -load NAS /img/bin/model/sysdown.sh reboot
IF you did all correctly your NAS should close and Power off !
Now, it’s just a matter of putting in all together in one catalogue, create a bat and add it as shut down script in your UPS software. I will not describe how to do it, since there are too many UPS and software version out there, but if someone will have problems, just leave a comment, I will try to help
7. Enable wake on LAN on Thecus
Basically waking up your NAS requires only 2 things:
- Enabling necessary option
- Sending Magic Packet from third party software from your computer/mobile phone. I used wol.exe since it’s easy “batchable”
Additionally you can add a bat file to server startup script or startup task to make sure your NAS will be powered on after power is back again.
That would be all, if you have any comments/suggestions please leave a comment.