Wake On Lan to wake from sleep (pm-suspend)

Some Linux machines wakes up correctly on WOL packet when they are normally powered off, but ignores the signal when they are in sleep. Found out that for configurations with Realtek network cards this can be fixed by (easy) substituting the kernel driver.

My system can be woken up with wakeonlan command from the other host in the LAN if have been powered off, but if I put it to sleep the WOL does not work. The only way to wake it is to press a key or a power button. This have nothing to do with network card mode (ethtool always shows ‘Wake-on: g’ — no problem there).

It turns out that the stock kernel module for that network card (r8169.ko) just can’t do it.

There is an alternative r8168 module by Realtek itself, mirrored on Google code that listen to Wake On Lan magic packets also when computer is in ACPI S3 sleep.

The installation is very simple:

wget http://r8168.googlecode.com/files/r8168-8.035.00.tar.bz2
tar -xjf r8168-8.035.00.tar.bz2
cd r8168-8.035.00
./autorun.sh

One more important info: the LED next to the ethernet port does TURN OFF when computer is put to sleep. Apparently it does not mean that the whole network interface is powered off. It still listen and wake on WOL packet.

Update:
Above version of the Realtek’s driver (8.035.00) does not compile with Linux kernel 3.8.x. Before Realtek updates it source it is possible to make it work by applying r8168-8.035.00-linux-3.8.patch (I have extracted it from Evangelos Foutras update).

So the recipe for r8168 module for Linux 3.8 is:

wget http://r8168.googlecode.com/files/r8168-8.035.00.tar.bz2
tar -xjf r8168-8.035.00.tar.bz2
cd r8168-8.035.00
wget http://juljas.net/linux/files/r8168-8.035.00-linux-3.8.patch
patch -p 1 < r8168-8.035.00-linux-3.8.patch
./autorun.sh
For the record, the affected system is:
- PC running Fedora 17
- kernel 3.5.3-1.fc17.x86_64 (and 3.8.3-103.fc17.x86_64 after the update)
- motherboard: Asus P8H77-V LE
- network card (integrated): Realtek RTL8111/8168B PCI Express Gigabit Ethernet (10ec:8168)
But I assume that the instruction is true for any distribution or motherboard that uses that series of Realtek network
This entry was posted in Linux and tagged , , , , , , , , , , . Bookmark the permalink.

2 Responses to Wake On Lan to wake from sleep (pm-suspend)

  1. Anonymous says:

    I solved the problem. I boot with the r8169 driver and made a script in /etc/pm/sleep.d that trades in the r8168 just before sleep. Now it wakes up from sleep, then I trade the r8169 back in. Best of both worlds! Here is the simple script if it helps someone:
    cat /etc/pm/sleep.d/50ethernet
    #!/bin/bash
    case $1 in
    suspend)
    modprobe -r r8169
    modprobe r8168
    ethtool -s eth0 wol bg
    ;;
    resume)
    modprobe -r r8168
    modprobe r8169
    ethtool -s eth0 wol bg
    ;;
    esac

    Thanks again!

  2. Anonymous says:

    Heh, well it didn’t get my 1st post. The problem I solved in the above post was the r8169 driver wakes from complete shutdown but not sleep. The r8168 driver when modified as Jan shows wakes from sleep but on my machine none of the r8168 drivers will wake from complete shutoff. Let each driver do what it does best I say :D

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>