Saturday, August 8, 2009

Waking a sleeping giant

I'm a lazy engineer. I like my machines to do my work for me. In particular, I like my machines to wakeup when I'm ready to work and I hate having to walk the 5 feet or less to turn on the damned 'puter.

Of course, I'm not the first one to be bothered by this so the good folks at AMD wrote a few patents and did some initial work on this. Other enterprising, but apparently equally physical exertion averse individuals built the technology into network cards and the supportive folks in the Linux community decided to make it a part of the Ubuntu 8.10 release.

All seemed to work fine, except that my Ubuntu box could no longer wake up on LAN. It worked fine if it was shut down from Winders XP, but no joy if Linux was involved. Googling and Binging for it finally brought me to the solution. And by that I mean, I came across a page that described how to fix my exact problem and one that I didn't have any difficulty following in my usual sleep deprived state.

found here: http://ubuntuforums.org/showthread.php?t=1138704

So here's what one does to have WOL working on Hardy Ubuntu 8.10

First things first:

Ensure that your hardware supports WOL. You find this by going into your BIOS. In my case, the Dell box had options to turn off power to the NIC to save power. I nixed that: you want the NIC to be alive so that it can "listen" to the WOL magic packets.

Also, there were other hibernation / ACPI settings for saving power during hibernation. I switched these to S1. The other option, S3, would have killed the NIC again, and so is a no-no.

Next, install ethtool if it isn't already installed


sudo apt-get install ethtool


Check if the NIC supports WOL (assuming eth0)


sudo ethtool eth0 | grep --ignore-case wake


Output should look like below:

Supports Wake-on: g
Wake-on: d


the "d" on the second line indicates that WOL is currently disabled. We want to set this to g to allow WOL to work.


sudo ethtool -s eth0 wol g


To check if this works, halt / suspend the system and issue a WOL from another machine:


other-machine:$> wakeonlan 00:BA:AD:BA:BE:00:00


If all the settings took effect, then you are good to go. If not, check the /etc/init.d/halt script


sudo vi /etc/init.d/halt


search for NETDOWN and ensure that it is set to "no".


NETDOWN=no


Repeate above steps with ethtool and see if this works. If it does, it means that basic functionality is present, but we need to make sure that NIC is forced to stay on during shutdown.

For this we will create a script that can be called on halt / hibernate.


sudo emacs /etc/init.d/wakeonlanconfig.sh


add the following lines:

#!/bin/bash
ethtool -s eth0 wol g
exit


Add execute permissions to this file and add to rc infrastructure:


sudo chmod a+x wakeonlanconfig.sh
sudo update-rc.d -f wakeonlanconfig.sh defaults


At this point you should be good to go. To test, halt / hibernate / stand-by the system and issue a WOL from the other machine. The machine should wake up like magic.

DONE. :)

No comments: