HOW-TO:Set up Wake-on-LAN for Ubuntu: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>MacUsers
>MacUsers
Line 82: Line 82:


===Automatic start-up at boot===
===Automatic start-up at boot===
"sysv-rc-conf" is Run-level configuration for Sys-V like init script links. From the man page: sysv-rc-conf gives an easy to use interface for managing "/etc/rc{runlevel}.d/" symlinks. sysv-rc-conf is not installed by default and needs to be installed first.
"sysv-rc-conf" is run-level configuration for Sys-V like init script links. From the man page: sysv-rc-conf gives an easy to use interface for managing "/etc/rc{runlevel}.d/" symlinks. sysv-rc-conf is not installed by default and needs to be installed first.
<source lang="bash">sudo apt-get install sysv-rc-conf</source>
<source lang="bash">sudo apt-get install sysv-rc-conf</source>
and when done, use
and when done, we enable the walk-on-lan service for runlevel 2,3,4 & 5, using --level option
<source lang="bash">sudo sysv-rc-conf --level 2345 walk-on-lan on</source>
<source lang="bash">sudo sysv-rc-conf --level 2345 walk-on-lan on</source>
  xbmc@htpc:~$ sysv-rc-conf --list | grep walk
  xbmc@htpc:~$ sysv-rc-conf --list | grep walk

Revision as of 19:17, 30 May 2010

Template:XBMC wiki toc Inline This page is incomplete; writing in progress...


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

Set Wake-on-LAN options

Run the following command to enable it:

sudo ethtool -s eth0 wol g
  • Note: Not all devices support this.

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

Get it enabled at system start-up

Debian/Ubuntu uses Sys-V like init system for executing commands during the system bootup and shutdown time. If you wish to add a new service to start when the machine boots the script should be added to the directory /etc/init.d/ and then the "/etc/rc{runlevel}.d/" symlinks cause the script to be executed.

The init.d script

Create a file, say "walk-on-lan" in the "/etc/init.d/" (just copy & paste the entire code in the terminal)

sudo cat << EOF >> /etc/init.d/walk-on-lan
#!/bin/bash
#
### BEGIN INIT INFO
# Provides:             walk-on-lan
# Required-Start:       \$local_fs
# Required-Stop:        \$local_fs
# Default-Start:        2 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
EOF
sudo chmod 755 /etc/init.d/walk-on-lan

Automatic start-up at boot

"sysv-rc-conf" is run-level configuration for Sys-V like init script links. From the man page: sysv-rc-conf gives an easy to use interface for managing "/etc/rc{runlevel}.d/" symlinks. sysv-rc-conf is not installed by default and needs to be installed first.

sudo apt-get install sysv-rc-conf

and when done, we enable the walk-on-lan service for runlevel 2,3,4 & 5, using --level option

sudo sysv-rc-conf --level 2345 walk-on-lan on
xbmc@htpc:~$ sysv-rc-conf --list | grep walk
walk-on-lan  2:on	3:on	4:on	5:on

Extra info

Wake-on-LAN is platform-independent; any application that sends "magic packets" can wake up computers from shutdown state (as long as it's not off from mains) regardless of OS it boots into afterward.