Linux services without mains power
Originally from Cape Town, Stevan Lockhart now lives in the north west of Scotland in a house that is off the electricity grid. Using a wind generator, some solar panels and free and open source software he and his wife both run their businesses off just 20W of power. Here Stevan explains the software and hardware decisions that made this lifestyle possible.
We live in the north west of Scotland, in the crofting area of Assynt. From here my wife runs her hand-dyed yarn business and I run my small free software consultancy as well as “attending” video conference lectures for my UHI Millennium Institute course. We bought the house about 12 years ago, and one of the appealing factors was that it was off the grid. I had always wanted a chance to see whether it was viable to operate without mains power, and here we were faced with either spending a fair amount on getting power to the house or looking at harnessing natural power. So we chose to install a wind generator with some solar panels to provide electric energy. We do, however, have telephone and broadband connections.
Assynt is a wonderful place to live, and it’s not surprising that my wife’s blog, which is ostensibly about knitting and crafts, also documents some of the beauty of the area, and the unusual things we cope with, such as rescuing a stranded lamb, and having on otter in our kitchen overnight.
The first critical issue when you win your power from the wind is to reduce your requirements. Our wind generator and solar panels charge a battery bank, from where inverters convert the power to conventional 230V AC from which point it is no different to any other household. A larger inverter is brought into operation when we need extra power, such as for running a vacuum cleaner or microwave, and a much smaller, 350W inverter, runs lights, hi-fi, television, battery charging for laptops, the broadband router and a Linux server. Running energy-saving light bulbs helps to reduce the power requirement, especially necessary in winter when it is dark at 3:30 and doesn’t get light until 9:30 in the morning. These days, LCD television sets can be reasonably efficient (but many sets are surprising power hogs – be careful when you choose). But the server needs to be on all the time and with us, excessive consumption isn’t a nice-to-have to add to your green credentials, it’s the difference between a depleted battery bank and not having to worry about enough power. The other services that are on all the time are the hi-fi on standby, the cordless telephone and the printer.
These days, there is a wide choice of lower-power mainboards, but this was not the case a few years ago. At that time, the Via-based mini-ITX boards were a good option, though. Our server runs a Via Esther processor running at 1.2GHZ MHz. It is connected to a laptop-style 2.5″ 320GB SATA disk and 512MB of memory. The system runs off a 12v power supply via a standard 50w “brick” power supply. We run a Netgear WG834GT router with wireless, which helpfully also runs off a 12V supply. Theoretically, we can run the router and server directly from the battery bank, but the voltage on that fluctuates meaning voltage stabilisers would be necessary, so frankly, it’s easier to run a normal 230VAC environment. The router consumes 10w measured at the battery, and the server 12-18w. However, add the two together off a single power supply brick, and the inefficiencies of the transformers are reduced, so we run the two together, and the usual consumption is just 18w, rising to 22w when the server is working hard.
Those 20w of power provide the following services:
- Broadband router
- Wireless Access Point
- Email, including anti-spam etc
- File sharing
- Printer sharing
- Groupware (diary, address books, etc)
- Music streaming
- Weather station data collection and display
- Database services (mysql, postgresql)
- Nagios system monitoring
- Remote Access VPN
- Other intranet services like photo albums, pets health logs etc
With a relatively underpowered processor, as well as wanting to save CPU cycles, software choice is important. One of the beauties of free software, which is often portrayed as a drawback, is choice. There is no “right” way to do any given task, and your choice of software may well differ from mine yet be equally valid. That’s fine and correct in our world.
The system runs Ubuntu 8.04 LTS. I wanted to run an apt-based distribution and the long term support options are relevant to clients, so felt I should run the same as I would install on other sites, though running Debian would have been just as valid. I ran Gentoo for a while, whose optimisations are great for this type of application, but you really need to be a full time sysadmin to achieve the same consistency as with a non-source-based distribution. Arch Linux is also tempting (I run that on my Asus eeepc with XFCE 4.6) but a little too leading edge for this server requirement, for my taste.
The system runs Postfix as the MTA. Exim would be a good option, but I’m used to Postfix now, and it has utilities like mailgraph which are great for showing email stats, spam, viruses and blocked connection attempts graphically. Usually I run this with amavis to wrap anti-virus and anti-spam, but amavis does use a reasonable amount of system resource. So I installed clamsmtp for anti-virus scanning and run spamassassin in daemon mode for spam clearup. Postfix uses Realtime Black Lists to reject the majority of spamming attempts, after which the mail is handed off to clamsmtp to check the mail for viruses and dodgy content (the Sanesecurity signatures are great for this) and then on to spamassassin for spam checking. Postfix drops the message if it is considered to be sufficiently spammy, or delivers it to the user’s spam folder if the spaminess is marginal.
Secure IMAP (IMAPS) only is used for client access, using Dovecot. Dovecot also provides the SASL mechanism for Postfix to authenticate SMTP sending via TLS. No unencrypted external access is available, though easy to add, of course. The version of dovecot in Ubuntu 8,04 does not include Dovecot’s sieve manager, so pysieved is used for this. This allows automatic clientpcontrolled filtering of mail and works well with the Groupware application.
In a different environment, Samba could be used, but as we only run free software here, the server runs NFS. Nothing much to add here – it’s simple to set up and just works.
CUPS is the solution to this. With CUPS clients, the printer automatically appears to the clients without driver installation. We run a Canon Pixma IP6600D as our main printer which does duplex, is reasonably fast, and is great for pictures. With chipped, compatible cartridges, it is reasonably cheap to run. However, it hates being powered down and powered back up, and consumes a lot of ink in the process. We found, though, that in standby it used about 2w of power, so we simply leave it on, connected to the server for instant access. The printer is well supported by CUPS. Using Linux desktops, the ability to print multiple pages on a single A4 sheet, duplexed, saves both ink and paper.
The easy choice would be apache, of course. But lighttpd is an interesting alternative, is fast and requires little resource footprint. Configuration is straight forward. PHP is provided by fastcgi which, though perhaps frowned upon when you have an apache module option, works well in practice. Other CGI options are possible.
eGroupware is our choice for this, running against a MySQL database. This provides a wide variety of groupware services, but the ones that are important to us are diary facilities, address books, the info log and we also use the client for remote access to our email. The email client is a pretty good one, and sieve scripts can be created and managed from here. It also supports SyncML, which allows corporate clients to sync PDAs and mobile phones easily.
We use the Lightning add-on to Thunderbird for calendar access on our laptops. This is stable enough for everyday use, though under an Ubuntu desktop, and possibly others, you must install the libstdc5 library to install the add-on.
There are many options for this, but our requirements are simple. So the easy little edna service is fine for us. More recently we have tended to use direct access to the music directory via NFS from our clients running rhythmbox or amarok. The music is, of course, in ogg-vorbis format. Edna can also be hacked to stream video, but again, in our environment, network access is simpler.
This is a TFA-badged Irox system USB-connected to the server. The server runs the Weather Display command-line client and some scripts to view current weather via the web server. A recent addition, on realising that Weather Display produced a delimited output file that could be scavenged for data, was some rrd scripts to graph hourly, daily, weekly monthly and annual trends.
Nagios monitors the system along with monit, and also monitors some third party systems on behalf of clients. This works well with lighttpd.
Apart from certificate-based ssh access, clients use OpenVPN to gain full remote access to our network. The easy-rsa scripts that come with OpenVPN make it easy to manage client certificates, and the overhead is negligible in this context.
We’ve found useful utilities like elogd great for small web-based “databases” such as pet health logs and so on. When I was testing the weather station software, I ran a small Debian-based virtual machine under Qemu on the server too. Performance was by no means sparkling, but it was adequate for what I was doing.
As would be expected in a techie’s household, we run a number of machines, including Asus eee PCs for convenience and low power consumption. My wife prefers the standard Xandros-based original software on eeegie, her Asus, but I prefer Arch Linux running the XFCE desktop on bumpkin, mine. For tasks needing a bigger screen, such as image manipulation on Helen’s blog, she uses an ancient IBM X22 running Xubuntu. I mostly use an almost-as-old IBM X31 with Ubuntu for my day-to-day requirements, including Ekiga for video conferenced UHI lectures. Interestingly, though musch larger and more powerful, the X31 uses about the same power as the little Asus eee pc’s.
So all in all, that’s a pretty full range of services running on just 20w of power. There are many other ways of delivering similar services, including the very frugal options provided by running services on a router, or small servers in an electrical plug. Yes, we could reduce that by choosing a different processor type, or get more CPU power for a similar electrical power consumption, but it’s not necessary to squeeze the last few watts from the system which will always be a compromise between power consumption, service quality and choice of services. I was reluctant to choose a non-x86 processor so that I could stay with similar systems to those clients would want, and also to demonstrate that running off grid power did not necessarily mean compromise in terms of service.
Stevan Lockhart was born and educated in Cape Town and has more than 20 years IT experience, from the early days of PC networking, the rise of the Internet and the change of computing from pure business tools to general purpose communication and collaboration platforms. Stevan also has more than 11 years’ experience in the deployment of free and open source software in a commercial environment. TNC Applied Technology provides consultancy on free and open source software infrastructures, as well as mentoring services to companies in the early stages of piloting and deploying free software servers and desktops.
House and wind generator pictures copyright Stevan Lockhart.
Do you want to be a Tectonic guest writer?