Phillip Pearson - web + electronics notes

tech notes and web hackery from a new zealander who was vaguely useful on the web back in 2002 (see: python community server, the blogging ecosystem, the new zealand coffee review, the internet topic exchange).

2007-6-8

Wake on LAN

I have two locations: home, and the office. Each has an always-on server (a Linux box in the office, and a hacked Linksys NSLU2 at home). Various other computers are scattered around, though, and it finally occurred to me the other day that I could configure them for Wake-on-LAN and remotely turn them on if need them. Here's a record of my successes and failure; hopefully it can help someone else in future.

SOLARIS BOX (office) - WORKED FIRST TIME - Athlon 1333 on Abit KT7 motherboard (circa 2001). This doesn't have built-in ethernet, so I used a cheap RT8139 card. Hooked up the Wake-on-LAN cable from the card to the motherboard, configured it in the BIOS, ran etherwake on the Linux server, and it woke up just fine. Shutting down and re-trying, it consistently worked.

WINDOWS XP BOX (office) - STILL NOT WORKING - Athlon XP 2800+ on Gigabyte motherboard (2005) with built-in ethernet. Configured Wake-on-LAN in the BIOS. If I boot into Windows XP then shut down, when I send the 'magic packet' the fans start up for a second, then stop. If I turn it on, then turn it off straight after the BIOS POST screen comes up, i.e. before Windows starts booting, it'll properly respond to the magic packet and wake up fine. It looks like XP is de-configuring WOL somewhere. I turned on the option in the network adapter to allow it to bring the machine out of suspend mode, but no luck.

LINUX BOX (home) - WORKED AFTER SOME HACKING - Athlon XP 2800+ on Asrock K7S41GX motherboard (2005) with built-in etnernet. Configured Wake-on-LAN in the BIOS (it's called something like 'Power on from PCI' - the thing to look for is a mention of PME# in the option description text). Booted into Linux and shut down, and it failed to wake up on command. Did some reading and found that I need to enable WOL manually on Linux, with ethtool -s eth0 wol g.

A problem here is that I'm running Xen on this box, and it moves all the network interfaces around. If I turn off all the Xen bridging with /etc/xen/scripts/network-bridge stop then enable WOL with ethtool -s eth0 wol g, though, the server wakes up fine.

When the bridge is running, eth0 becomes peth0, and ethtool -s peth0 wol g appears to set the WOL state up properly (ethtool peth0 correctly reports 'Wake-on: g' rather than 'Wake-on: d'), but if I shut down without stopping the bridge, the server won't wake up.

Someone reported this as a Xen bug on 1 Aug 2006.

I just got this working by adding this script as /etc/init.d/xen-bridge-phil to stop the bridge on shutdown (with update-rc.d xen-bridge-phil start 19 2 3 4 5 . stop 19 0 1 6 .):

#!/bin/sh

. /lib/lsb/init-functions

stop()
{
        /etc/xen/scripts/network-bridge stop
}

case "$1" in
  stop)
        log_daemon_msg "Stopping Xen network bridge so WOL will work" "xen-bridge-phil"
        stop & log_end_msg 0 || log_end_msg 1
        ;;
esac

exit 0