I have 3 computers. My laptop a Thinkpad X30, another Thinkpad which acts as server and a desktop computer. I have all my main data on my server and use the files on my laptop and desktop by sshfs and NFS.
The only files I don’t store on my server is media files, such as movies and music – these are stored on my desktop. This was the problem – if I was out I couldn’t access my files since my desktop was turned off when I am not home. I need something to turn on my desktop when I wasn’t home.
Wake on Lan
Wake on Lan (WOL) is a technology to turn on a computer by sending it a specific network package. When a WOL-enabled computer is turned off the network port will stay active and listen for a certain packages and in if it receives such a package it will boot the computer.
Two things are needed:
- Enable WOL on my Desktop.
- Installing a program to send the magical network package on my server.
Somewhere in the BIOS there will hopefully be some setting to enable WOL. I didn’t find it in the BIOS of my ASUS PW5 DH motherboard, but it works fine. A good indicator is to check whether the lights around the network cable is turned on or not on the back of the computer when the computer has been shutdown.
Enabling WOL in Windows
It always takes more screenshots to explain anything in Windows, but there is not really any way around it. In Windows I need to go to the network setting and choose my network adapter. After selecting “configure” as in the screenshot:
I selected the fan called “advanced” where I found to settings I need to turn on:
Wake from shutdown:
Wake up capabilities:
That’s it. 🙂
Enabling WOL in Linux
To enable WOL from Linux the option has to be set before shutting Linux down. First I see what is supported by network driver:
root@bohr:/home/tjansson# ethtool eth1 Settings for eth1: ... Supports Wake-on: pg Wake-on: d ...
So it supports pg which means (from man ethtool):
<code> p Wake on phy activity g Wake on MagicPacket(tm)
The g option is the interesting part. So I set the option on the my network driver:
root@bohr:~# ethtool -s eth1 wol g
but I don’t want to do this every time I shut down the computer, so I will make a script in /etc/init.d/ named wol.sh containg the lines:
#!/bin/bash ethtool -s eth1 wol g
and make it executable:
root@bohr:/etc/init.d# chmod +x wol.sh
and finally tell Linux to execute the script on every runlevel, which I quite a overkill, but it doesn’t really mater – it works:
root@bohr:/etc/init.d# update-rc.d -f wol.sh defaults
Now WOL is enabled under Linux as well.
Sending the magical package from Linux
The last thing I need to do is to wake the computer after it has been shut down. I do this from my Linux server on the same local network. The only information needed is the hardware adress of network interface on the desktop machine. I can find this by running ifconfig under Linux or some networkgui on Windows on the desktop machine:
tjansson@bohr:~$ /sbin/ifconfig ... eth1 Link encap:Ethernet HWaddr 00:18:F3:CD:78:A0 ...
Now I can start the desktop computer by running wakeonlan from my server:
root@nobel:/home/tjansson# wakeonlan 00:18:F3:CD:78:A0 Sending magic packet to 255.255.255.255:9 with 00:18:F3:CD:78:A0
Waking the computer from other OS’s
In the bottom of the wikipediaentry on WOL there is a long list of other programs to send the magical network package but I haven’t tried any of these my self.