When most folks hear “UPS” they think, “Go Brown”, well this take isn’t package delivery, and in our case “brown” means “brownout.”
The key to fighting data loss during a brown/black out is using a UPS or Uninterruptible Power Supply with your NAS. Unlike laptops that automatically switch to their built-in battery during power loss, your Synology NAS is suspect to data loss if it suddenly loses power while writing data. A UPS setup to guard your NAS can help reduce a common cause of data corruption by allowing your NAS to safely shut down.
Synology’s DSM OS uses a Linux NUT (Network UPS Tools) package that includes the usbhid-ups driver which is an open standard for Linux based operating systems to communicate with UPS devices. Special thanks to Sang at Synology for this info and for updating their website.
Read below on how to choose and setup your UPS. This is an important step to that should be done before you start to copy loads of data over to your NAS.
Which UPS to buy?:
By and large this is pretty much a one horse race with American Power Corporation (APC) owning the lion share of compatible UPS devices. Your UPS device should also have a USB port for power down management (ability to signal the NAS to shutdown).
If you end up getting a new APC UPS that isn’t listed I would encourage you to add it to the user reported list after you verify that unplugging the UPS power cord results in the NAS doing a graceful shutdown.
If cost is a consideration there are several inexpensive APC models under $150 that aren’t much larger than a regular power strip, but will give your NAS enough time to shut down correctly.
If you decide to skip using a UPS then at least get a power strip with power surge/lightning protection to prevent catastrophic loss and damage to electro-magnetic hard drives.
How to correctly setup your UPS to work with your Synology NAS:
If you’ve think you’ve already got this covered by plugging your NAS power cord into any generic UPS device make sure you didn’t miss these other additional steps.
- Make sure you look at your UPS’s electrical power strip closely. Often there are 2 kinds of slots, battery backup with power surge protection, and NO BATTERY BACKUP with power surge protection. Make sure your Synology NAS power cord is plugged into your UPS’s “powered” slot, and not just a conditioned slot because it is an easy mistake to make.
- In addition to power, connect the Synology NAS to your UPS via a USB cable. This allows the UPS to signal Synology what UPS device it is, and notify when it is time to spin down the drives before the battery runs out. This does take one of your Synology’s USB ports, but you can use a port replicator for the second USB port if you have other USB devices to connect (external hard drives, USB printers, WiFi adapters, etc.).
- Turn on UPS support by logging into your Synology Disk Station and going to: Main Menu > Control Panel > Power > UPS and “enabling UPS support.” Clicking “Device Information” should correctly report your UPS device’s info.
- Verify that your Synology is set to automatically restart after a power failure. Main Menu > Control Panel > Power > General Settings, check the box that says, “Restart automatically after a power failure.” If you don’t have this option set and you need remote access after a power outage has been restored you’ll have to make the trip home to turn your Synology NAS unit back on.
Setup a notification to be notified when your Synology NAS loses power. You can also setup Email or SMS text message notifications to let you know about error and status changes to your Synology NAS by going to: Main Menu > Control Panel > Notification and entering your Email info.OMG – Just tried this and step 6 and it turns out Synology doesn’t support notification for letting you know when the NAS is running on UPS power backup or if the NAS is attempting a safe shutdown. The next blog is dedicated to setting up email and SMS Notifications and I’ll go over what it does (and doesn’t) notify you about.
- Once everything is setup do a final test before entrusting your new NAS with any data. Have the NAS plugged into your UPS via power cord and USB cable. Unplug the UPS power cord from the wall outlet and verify that your NAS goes thru the shutdown process with all the lights turning off (Status, LAN, Power, HDD Activity). After you are satisfied that it shut down correctly, plug the power back into your UPS and verify your NAS rebooted and came back online.
What happens during a power outage?
With your UPS correctly configured your Synology NAS will get the USB signal that it is running off the UPS’s battery when the power goes out. The default setting is to have the NAS enter “SAFE MODE” and immediately stop all services and unmount the hard disk volume(s). You can set a longer delay, but once low battery is detected the NAS will do a safe shutdown. This allows the drive head to park correctly in anticipation of the UPS running out of battery power. You will see the HDD lights on the NAS go blank followed by the LAN and status lights turning off. Finally you’ll see the blue power button light on your NAS turn off.
You can also have the NAS tell the UPS to turn off. This can be done in the Main Menu > Control Panel > Power > UPS and choosing “shut down UPS when the system enters Safe Mode.” Your NAS communicates this via the USB cable. This allows the UPS to retain some of it’s backup power, but I don’t use this setting. I like to keep the UPS running to power the router and modem without the NAS so that our wireless devices can continue to access the internet for a few more hours even though the rest of the house is without power.
Once power is restored the UPS will come back online and begin to recharge the batteries, and your Synology NAS will detect that power has been restored and automatically power back on as long as you did step #5 above. If all goes well you may not have even noticed you lost power (except for all the clocks in the house that have to be reset!).
Did the lights really go out?
If you aren’t sure if your NAS had a power outage you can check the system log file. This can be accessed by going to the Main Menu (arrow in upper left corner) > System Information (blue circle with letter i). In the log tab look for a yellow warning triangle that reports the Server is on battery, followed by a second yellow triangle stating the server is going to safe shutdown.
What to do after a power outage?
If you are using a UPS and everything shut down correctly you should be fine. If you think the UPS didn’t worked correctly and that data loss may have occured you should run the S.M.A.R.T. tests on each HDD after a power failure. S.M.A.R.T. tests can be accessed by going to Main Menu (drop down arrow in the upper left corner)> Storage Manager, select the “HDD Management” tab, select a drive and choose the “S.M.A.R.T. Test button. Do a quick test on each drive, followed by an extended test. It would be nice if Synology made this an automatic option. If any errors are reported you should consider swapping out hard drives and rebuilding your NAS. You can then use your drive manufacturer’s drive test tools to test the drive further to see if the drive can be reconditioned and put back into use or if it should be replaced (hopefully under warranty).
Connecting your Mac to UPS
Since this blog is about using Macs with Synology I thought I’d take the time to cover how to connect your UPS to both your Synology NAS and your Mac (most likely a desktop since laptops don’t need UPS since they have their own built in battery backup).
How to connect your UPS to both your Synology NAS and your Mac? Most UPS devices only have 1 USB connector. You can use a simple USB hub and connect it to your UPS to allow both the NAS and the Mac (or PC) to also be connected to talk to the UPS. If your UPS device uses the older style USB Type B connector commonly found on USB printers you may need to get some additional cables to connect the USB hub. A “USB Type A Female to Female adapter” should allow your USB B to A cable to connect to your USB hub. Your cable linkage would look like this: UPS USB slot Type B – USB B to USB A cable – USB A Female to Female Adapter – USB Hub – 2 USB A cables each connected from the hub to the mac or the NAS.
On a Mac running Snow Leopard (10.6.7 in my case) you can access the UPS settings by going to Apple Icon (upper left corner) > System Preferences > Energy Saver. The Energy Save panel should open and have both Power and UPS as options to select (if you don’t have UPS as a choice then your Mac isn’t seeing the UPS via USB cable).
In the UPS settings you can make the computer sleep times more immediate. You should select “shutdown options” and turn on all 3 options. It is important to note the the Mac will initiate shutdown on which ever shut down option criteria is met first.
The two biggest gotchas with Macs and using a UPS are:
If you are at the Mac when you lose power, if your display monitor isn’t also on the UPS you will not be able to see your Mac’s screen in order to save out of any programs or see the following message.
If you aren’t at the Mac, but left an application open in an unsaved state your Mac will halt the UPS shut down process to ask you if you want to save. If you aren’t at the Mac this means that you will lose that work when the UPS gives out (which it will do quickly since the Mac’s power needs will drain your UPS quickly). Setting your Mac to sleep in the first dialog for UPS options will help cut power usage. Setting all of the apps that have auto-save features to automatically save frequently is a good idea. Whenever you leave your Mac get in the habit of saving and shutting down, or at least hitting Option+Command+Eject to put your Mac to sleep is a good practice.
Mac Sleep vs Shutdown. Macs at sleep power down the hard drive and dvd drive, but keep power to your RAM and a minimal amount of power to your CPU so that your Mac can quickly be awakened. Shutdown completely turns off all power and requires a full system boot to turn on.
If your Energy saver doesn’t have UPS as an option and looks like the screenshot below you don’t have your UPS connected via USB to your Mac. Typical Apple UI to hide options unless they are accessible.
Synology’s UPS FAQ can be found here.
I did a test of disconnecting the USB cable from the NAS and noticed that DSM did not know it was disconnected. Even after going back into the UPS settings and selecting device information. Main Menu > Control Panel > Power > UPS tab. It appears that DSM only does the UPS USB cable check at boot up. So if your NAS runs 24/7 you will need to remember to occasionally reboot it to perform the UPS cable check. The good news is that once it does reboot, you’ll get a notification if it is no longer connected.
In addition to your NAS and your Mac you may also want to connect your Internet Provider’s Modem, your Router (Airport Extreme, Time Capsule, Airport Express), and your gigabit switch to your UPS to make sure your Internet connection stays online when the power goes off. This allows your iPhones, Mac laptops and other wireless devices to stay connected to the internet even though the power is off in the house.
Interesting quote from Wiki article on S.M.A.R.T. compatible HDDs and how they try to prevent data loss without a UPS:
The inability to read some sectors is not always an indication that a drive is about to fail. One way that unreadable sectors may be created, even when the drive is functioning within specification, is through a sudden power failure while the drive is writing. In order to prevent this problem, modern hard drives will always finish writing at least the current sector immediately after the power fails (typically using rotational energy from the disk). Also, even if the physical disk is damaged at one location, such that a certain sector is unreadable, the disk may be able to use spare space to replace the bad area, so that the sector can be overwritten.