Powernap – The Server Power Management


I recently moved into a new home and one of the first things that I HAD to do was setup the home media server with a XBMC front end. So I set it up and I have been watching movies and television happily for a month now. All was going well until I got my first electricity bill. Wow was it painful. Of course it include the usage of a fridge and other appliances, but the media server had not been turned off for the whole month even though I only used it maybe 2 hours a day.

To this end I set out to find a way to reduce power consumption. The first thing that I thought of was a simple shutdown script for the XBMC front end that would turn off the server before it turned off. This worked well but there where problems, that sometimes the front end wasn’t turned off for long periods with idle time, or sometimes after I turned off the front end I still wanted to access the server and I still had to manually turn the server on. Clearly this was not a long term solution.

The next concept was to get the computer to be turned on via Wake On Lan. Wake On Lan (WoL) is a method of sending a special command to a computers motherboard via an Ethernet connection. This is easy to setup but hard actually do. Searching around online I found a program Powerwake written by Dustin Kirkland which using a very simple interface can perform as required. On Ubuntu this can be installed and used to wake a computer like so:

sudo apt-get install powerwake

sudo powerwake 10.0.0.12

*Replace 10.0.0.12 with the the address of the computer you want to wake.

This can be used to wake a sleeping computer. I use a simple script built into the front end which when runs wakes the server, waits about 30 seconds and then tries to remount the fstab file. If it the remount fails it waits another 30 seconds and then tries again. When the remount succeeds the computer reloads XBMC – easy.

This leaves only the problem of getting the server to turn off after inactivity. For this I installed the powernap program. This is a great application, again from Dustin Kirkland, which acts much like a screen saver for a server or non-GUI system. It is was quite complex to setup, but once you understand how it works it becomes much simpler.

Unfortunately time has run out and this post must end now. Stay tuned for updates of how I installed Powernap and a better look at how the program works.

As power is becoming a more and more costly and a limited resource (until we switch to renewable energy sources) tools such as powernap and powerwake will become more and more necessary for both hobbyists and professionals alike.

%d bloggers like this: