Tuesday, November 19, 2013

Notes on Wake on Lan (WOL)

These are some notes on a current problem, even more disjointed than usual. I wanted to have Wake on Demand working on both mac and linux on the same machine, with the same ethernet port. This isn't working out well (in linux at the moment), so I'm shelving it and at some point maybe I'll get back to it.

In MacOS, I found that the intel driver fails but the atheros card works fine for WOMP and WOD, and USB keyboard.

Under linux:
To enable wake with USB keyboard, you need to add:
# enable waking from sleep from USB HID devices
# $ lsusb -d 046d:
# the above gets the usb bus and device, but not port (5 in the case below)
echo enabled > /sys/bus/usb/devices/usb3/power/wakeup
echo enabled > /sys/bus/usb/devices/usb3/3-5/power/wakeup
to /etc/rc.local

The Intel card works fine for Wake on Magic packet (but since it doesn't for the mac, I've abandoned it for the moment).

Wake on Magic Packet fails for Atheros card. This appears to be an issue in the alx drivers, which aren't being updated it seems (maybe they are?). The lights are off during suspend. There is a compounding issue in that if you suspend via dbus (which appears to be what gnome/cinnamon does), when you come back the ethernet card will not work properly, irrespective of what you put in /usr/lib/pm-utils/sleep.d/50unload_alx to not disable/re-enable the alx driver (which was itself put there to fix a third bug in alx, which was apparently causing sleep to fail altogether).  (Updating alx doesn't help). You have to run rmmod alx; modprobe alx as root to re-enable networking after waking. If instead of using dbus, you simply call pm-suspend, there are no issues with the Ethernet connection dropping upon awake.

Note that enabling the disabled wakeup options for the card and its pci bus as below make no difference:
echo enabled > /sys/bus/pci/devices/0000\:00\:1c.0/power/wakeup
echo enabled > /sys/bus/pci/devices/0000\:00\:1c.3/power/wakeup
echo enabled > /sys/bus/pci/devices/0000\:02\:00.0/power/wakeup
( lspci & lspci -tv help with these)

Here's the dbus suspend command I've used: dbus-send --system --print-reply \
    --dest="org.freedesktop.UPower" \
    /org/freedesktop/UPower \
    org.freedesktop.UPower.Suspend

*** Actually, this guy has some interesting troubleshooting and it seems pm-hibernate might work with WOL (and since I have an SSD, isn't that different from sleep). But, I tried pm-hibernate and I seem to be getting the third bug in alx mentioned above, that hibernate fails to actually go into hibernation.

The cool app SleepProxyClient, which I'd really like to get working on the machine, uses pm-suspend (at least now). If it worked, we could sleep and then have things awake when needed (eg, samba requests), by making use of the bonjour sleep proxy on my appletv. I haven't tested it with the intel card, which might just work. Here are some useful pages about this:
http://www.cnpbagwell.com/mac-os-x/bonjour-sleep-proxy
http://stuartcheshire.org/SleepProxy/
Avahi is the linux implementation of bonjour.

There is a link about autoshutdown on the sleepproxyclient page above, and this may also help in deciding when to sleep. So might this, which I found somewhere:

#!/bin/bash
hdparm -C /dev/sda | grep "active" > /dev/null
SDA=$?
hdparm -C /dev/sdb | grep "active" > /dev/null
SDB=$?
if [ $SDA -eq 1 ] && [ $SDB -eq $SDA ]
then
 echo "drives asleep" 
 LOAD=`awk {'print $1'} /proc/loadavg`
 echo $LOAD
 if [ "$LOAD" == '0.00' ]
 then
  echo "load hit threshold"
  echo "Sleeping"
  # Call sleep process here
 fi
fi

No comments:

Post a Comment