HOW-TO:Set up Wake-on-LAN for Ubuntu: Difference between revisions
>MacUsers No edit summary |
>MacUsers No edit summary |
||
Line 5: | Line 5: | ||
First off, the motherboard should support the WOL (Wake On LAN) and it should be enabled in the BIOS. Different BIOS/motherboard do it differently; on ASUS (P5N7A-VM), it's under Power > APM Configuration and in there "Resume On PCIE Wake" and "Resume On LAN(MAC)" should be enabled. | First off, the motherboard should support the WOL (Wake On LAN) and it should be enabled in the BIOS. Different BIOS/motherboard do it differently; on ASUS (P5N7A-VM), it's under Power > APM Configuration and in there "Resume On PCIE Wake" and "Resume On LAN(MAC)" should be enabled. | ||
= | =Enabling WOL in the OS= | ||
Even though WOL works in network layer 2, OS support is still one of the important things to make it work. Even if you see the light on the Ethernet port is on after the halt/shutdown, the OS shuts off the Ethernet internally. One must tell Ethernet controller to WOL when boots up and tell "halt" script not to bring down controller during shut-down. | Even though WOL works in network layer 2, OS support is still one of the important things to make it work. Even if you see the light on the Ethernet port is on after the halt/shutdown, the OS shuts off the Ethernet internally. One must tell Ethernet controller to WOL when boots up and tell "halt" script not to bring down controller during shut-down. | ||
===Install ethtool=== | ===Install ethtool=== | ||
Line 12: | Line 12: | ||
sudo apt-get ethtool | sudo apt-get ethtool | ||
</source> | </source> | ||
and then run the following command to enable it | |||
<source lang="bash"> | |||
sudo ethtool -s eth0 wol g | |||
</source> | |||
After that, this can be verified running ethtool on ethX (where X is the name/number of the Ethernet device). | |||
xbmc@htpc:~$ sudo ethtool eth0 | |||
[sudo] password for xbmc: | |||
Settings for eth0: | |||
Supported ports: [ MII ] | |||
Supported link modes: 10baseT/Half 10baseT/Full | |||
100baseT/Half 100baseT/Full | |||
1000baseT/Full | |||
..... | |||
..... | |||
Auto-negotiation: on | |||
Supports Wake-on: g | |||
Wake-on: g | |||
Link detected: yes | |||
===Create an init.d script=== | ===Create an init.d script=== | ||
Next, create a file, say "walk-on-lan" in the "/etc/init.d" to automatically start WOL at the boot time. | Next, create a file, say "walk-on-lan" in the "/etc/init.d" to automatically start WOL at the boot time. |
Revision as of 19:32, 28 May 2010
Before you start
First off, the motherboard should support the WOL (Wake On LAN) and it should be enabled in the BIOS. Different BIOS/motherboard do it differently; on ASUS (P5N7A-VM), it's under Power > APM Configuration and in there "Resume On PCIE Wake" and "Resume On LAN(MAC)" should be enabled.
Enabling WOL in the OS
Even though WOL works in network layer 2, OS support is still one of the important things to make it work. Even if you see the light on the Ethernet port is on after the halt/shutdown, the OS shuts off the Ethernet internally. One must tell Ethernet controller to WOL when boots up and tell "halt" script not to bring down controller during shut-down.
Install ethtool
I found "ethtool" is one of the easiest to use to enable WOL; install it first if it's not there yet.
sudo apt-get ethtool
and then run the following command to enable it
sudo ethtool -s eth0 wol g
After that, this can be verified running ethtool on ethX (where X is the name/number of the Ethernet device).
xbmc@htpc:~$ sudo ethtool eth0 [sudo] password for xbmc: Settings for eth0: Supported ports: [ MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full ..... ..... Auto-negotiation: on Supports Wake-on: g Wake-on: g Link detected: yes
Create an init.d script
Next, create a file, say "walk-on-lan" in the "/etc/init.d" to automatically start WOL at the boot time.
#!/bin/bash # ### BEGIN INIT INFO # Provides: walk-on-lan # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: 3 4 5 # Default-Stop: 0 6 # Short-Description: Enable Wake-On-Lan ### END INIT INFO # . /lib/lsb/init-functions do_start() { ethtool -s eth0 wol g exit } do_stop() { ethtool -s eth0 wol d exit } case "$1" in start) do_start ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) do_stop ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;; esac
Configure WOL service to start upon boot
"sysv-rc-conf" is Run-level configuration for SysV like init script links. sysv-rc-conf is not installed by default
sudo apt-get install sysv-rc-conf