# How to power off a system but still keep it available on the network

I'm looking into installing a file server on my network, for serving data and backups.

I want this machine to be available at all times, but I would rather not keep it on all the time (as to conserve power).

Is it possible to set things up so that the thing automatically suspends (or powers off) after some time and then automatically powers back on when I try to connect to it (using some wake-up on LAN magic, without having to send explicit WOL packets)?

-

OS X can do this now, as of Snow Leopard. It's made possible through the Sleep Proxy Service. It's pretty much automatic. The only requirement is that you have a second always-on Apple device on your LAN that can act as the sleep proxy. Their current low-power embedded boxes all support this, I believe: Airport, Time Machine, and Apple TV.

In the general case, though, I believe the answer is no. I'm not aware of any other OS that has implemented a service like this. The technology is open source, so there's no reason this couldn't be everywhere eventually. It's probably too new to see widespread adoption just yet.

You might now be asking, why do you need a second Apple box on the LAN?

When a PC is asleep, the kernel — and therefore the network stack — is not running, so there is no code in your OS that can respond to a "magic" packet of the sort you're wishing for.

Wake-on-LAN magic packets aren't handled by the OS. They're recognized by the network interface IC, which responds by sending a signal to the CPU that releases it from the sleep state. It can do this because the IC remains powered up in some sleep states. (This is why the Ethernet link light stays on while a PC is "off" on some machines.)

The reason the Apple technology works is that just before the PC goes to sleep, it notifies the sleep proxy. The sleep proxy then arranges to temporarily accept traffic for the sleeping machine, and if it gets something interesting, it sends a WOL packet to the PC and hands off the traffic it received.

-
"arrange to temporarily accept traffic for the sleeping machine" - as in ARP poisoning? Cool. –  Wim Coenen Aug 31 '10 at 16:53
This is no more a use of ARP poisoning than is NIC fail-over. The term ARP poisoning carries intent with it, for one: no one is trying to attack anything with this technology. For another, the Sleep Proxy Service is a way for the sleeping PC to explicitly authorize the proxy to watch for traffic while it's asleep. You might as well indict phone message services for identity theft as call this ARP poisoning. –  Warren Young Aug 31 '10 at 17:13
I upvoted this because even though it does not provide a general solution it explains the nature of that solution well in the last paragraph. –  Mr. Shiny and New 安宇 Sep 2 '10 at 18:30

I have had luck using PowerNap (it is packaged for ubuntu-sever, but the source is there so you should be able to compile it on anything) to suspend backup machines when they aren't doing anything. However, this won't wake them up automatically. There is also a PowerWake program bundled with the PowerNap source tarball (packaged as powerwake in Ubuntu) that provides a bit of abstraction to the Wake-On-Lan process (makes it easy to send WOL just with the hostname, for instance), but it is still not automatic.

Edit. Another Option:

I don't know much about it because I've never used it, but some cards are capable of waking on any unicast message. You can see if your card has the capability using ethtool

# ethtool eth0


Substitute eth0 for your network device. Then look at the output for the line starting with "Supports Wake-on:". If "u" is listed on that line, then you can do the following at boot(ie, in an init script or something similar):

ethtool -s eth0 wol u


Combined with PowerNap or anything else that puts the machine to sleep under some conditions, this should provide what you are looking for.

-
Where could I find ethertool? –  Gert Sep 1 '10 at 7:07
Sorry, this was a typo--the tool is ethtool. I've corrected the typo and added a link to ethtool. –  Steven D Sep 1 '10 at 16:22
powerwake seems to be included in a separate, eponymous package, at least under ubuntu 10.10. –  intuited Jan 4 '11 at 7:54
I see. powernap and powerwake are included in the same source tree but in such a way as to make two packages. I'll update the post in a bit, once I think of a good way to mention this fact. –  Steven D Jan 4 '11 at 20:48