View  Edit  Attributes  History  Attach  Print  Search

WakeOnLan

So with my new MediaServer I thought that I would save some power by putting it to sleep whenever I don't use it. It uses about 80 W, when on and 15 W when halted or totally off.

First I switched the sleep mode to S3 (that's sleep-but-hold-content-in-RAM). In order to make hibernate to work, you need at least the same swap area as RAM memory (since in Linux saves the RAM contents to Swap) and I have 2GB RAM but only 1 GB SWAP. Also enable WakeOnLan in BIOS.

You need ethtool installed, so if you don't have that installed already run:

# sudo apt-get install ethtool

Now you can check if your hardware supports WakeOnLan, and if it's enabled:

# sudo ethtool eth0
Settings for eth0:
        Supported ports: [ MII ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: external
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Link detected: yes

It shows that WakeOnLan is supported (Supports Wake-on: g) and that it is disabled Wake-on: d To enable it run:

# sudo ethtool -s eth0 wol g

To make it turn on at reboot I added a line to /etc/network/interfaces

iface eth0 inet dhcp
up ethtool -s eth0 wol g

Someone suggested to use 'up ethtool -s $IFACE wol g' but since I only have one ethernet port, I haven't tried that.

Now we see that it's turned on:

# sudo ethtool eth0
Settings for eth0:
       Supports Wake-on: g
       Wake-on: g
       Link detected: yes

We also must make sure that the network interface is not switched off during halt (and perhaps also reboot?). Do that by deleting the -i option in /etc/init.d/halt (and perhaps /etc/init.d/reboot). You will notice that if the light at the ethernet port is on, even when you later have powered off the system, you have succeeded in enabling the network interface.

Now we need to make a note of the MAC address

Now that you know WakeOnLan is turned on you need to do one more thing. The Wakeonlan software requires that you know the MAC address of the machine you wish to switch on, rather than the IP address.

To determine the MAC address you can either:

Discover it on the machine itself before it is switched off, by using ifconfig Determine it remotely, whilst the machine is powered on and running. To determine the MAC address via ifconfig just run it:

~$ ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:18:F3:E2:6B:4A  
          inet addr:192.168.10.138  Bcast:192.168.10.255  Mask:255.255.255.0
          inet6 addr: fe80::218:f3ff:fee2:6b4a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1492  Metric:1
          RX packets:1043848 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1204221 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:273478278 (260.8 MiB)  TX bytes:1220053134 (1.1 GiB)
          Interrupt:233 Base address:0xc000 

The MAC address was 00:18:F3:E2:6B:4A, it's on the first line and is described as the "HWaddr".

Now you can shutdown the machine:

# sudo shutdown -h now

And try to wake it with some tool...