{"id":524,"date":"2009-11-27T22:56:14","date_gmt":"2009-11-28T02:56:14","guid":{"rendered":"https:\/\/lowtek.ca\/roo\/?p=524"},"modified":"2009-11-28T00:22:09","modified_gmt":"2009-11-28T04:22:09","slug":"wake-on-lan","status":"publish","type":"post","link":"https:\/\/lowtek.ca\/roo\/2009\/wake-on-lan\/","title":{"rendered":"Wake On Lan"},"content":{"rendered":"<p>The ability to wake a machine up over the network is really nice.\u00a0 This feature is referred to as <a href=\"http:\/\/en.wikipedia.org\/wiki\/Wake-on-LAN\">wake on lan<\/a> (WOL).\u00a0 Most modern hardware supports this, and many operating systems have it nicely integrated (Mac OSX for one) &#8211; under Linux it required a bit more magic.\u00a0 This post is specific to <a href=\"http:\/\/www.ubuntu.com\/\">Ubuntu<\/a> 9.10, however it probably applies to other versions and variants.<\/p>\n<p>Primarily I was looking to wake up from suspended state as I tend to let my machine sleep when I&#8217;m not using it, however WOL works with both hibernate and full shutdown. If you are having trouble, its a good idea to validate that your <a href=\"http:\/\/en.wikipedia.org\/wiki\/BIOS\">BIOS<\/a> settings are correct &#8211; as support for WOL can be enabled\/disabled in the BIOS.<\/p>\n<p>Unfortunately since everyone has different hardware, the details of the solution will be different.\u00a0 I learned a lot of this from <a href=\"http:\/\/ubuntuforums.org\/showthread.php?t=814939&amp;page=4\">a thread in the ubuntu forums<\/a>.\u00a0 Here is my specific solution, read on past the break if you want to understand how I arrived at this solution.<\/p>\n<p>I created a file \/etc\/init.d\/wakeonlan with the following contents<\/p>\n<p><code>#! \/bin\/sh<br \/>\n### BEGIN INIT INFO<br \/>\n# Provides:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 wake on lan<br \/>\n# Required-Start:\u00a0\u00a0\u00a0 $network<br \/>\n# Required-Stop:<br \/>\n# Default-Start:\u00a0\u00a0\u00a0\u00a0 2 3 4 5<br \/>\n# Default-Stop:\u00a0\u00a0\u00a0\u00a0\u00a0 0 1 6<br \/>\n# Short-Description: Configures WOL<br \/>\n# Description:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Configures Wake-On-Lan<br \/>\n### END INIT INFO<br \/>\n#<br \/>\nethtool -s eth0 wol g<br \/>\necho enabled &gt;\u00a0 \/sys\/class\/net\/eth0\/device\/power\/wakeup<br \/>\necho SLOT &gt; \/proc\/acpi\/wakeup<br \/>\necho KBC &gt; \/proc\/acpi\/wakeup<\/code><\/p>\n<p>Ensuring the permissions allow execute (chmod a+x wakeonlan).\u00a0 And added it to the startup sequence:<\/p>\n<p><code>sudo update-rc.d -f wakeonlan defaults<\/code><\/p>\n<p>Now every reboot you&#8217;ll get WOL setup, and the keyboard will wake up the machine too.<\/p>\n<p><!--more--><\/p>\n<p>The rest of this post covers how I figured out what magic went into the init.d script. First we need to tweak the network driver to enable WOL behaviour, in my case that&#8217;s eth0:<\/p>\n<p><code>sudo ethtool -s eth0 wol g<\/code><\/p>\n<p>In my case it seems I also need to set the wake up flag in the driver to enabled, otherwise the card loses power and the WOL flag we just set doesn&#8217;t help since the power is off.<\/p>\n<p><code>sudo sh -c \"echo enabled &gt;\u00a0 \/sys\/class\/net\/eth0\/device\/power\/wakeup \"<\/code><\/p>\n<p>Now that we have the card configured to stay powered (to some level) and react to the WOL packet, we need to configure the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Advanced_Configuration_and_Power_Interface\">ACPI<\/a> wakeup file (\/proc\/acpi\/wakeup) to enable the ethernet card.\u00a0 This is where things will be system dependent &#8211; my file looks like:<\/p>\n<p><code>$ cat \/proc\/acpi\/wakeup<br \/>\nDevice\u00a0\u00a0 \u00a0S-state\u00a0\u00a0 \u00a0\u00a0 Status\u00a0\u00a0 Sysfs node<br \/>\nUSB1\u00a0\u00a0 \u00a0\u00a0 S3\u00a0\u00a0 \u00a0 disabled\u00a0 pci:0000:00:1d.0<br \/>\nUSB2\u00a0\u00a0 \u00a0\u00a0 S3\u00a0\u00a0 \u00a0 disabled\u00a0 pci:0000:00:1d.1<br \/>\nUSB3\u00a0\u00a0 \u00a0\u00a0 S3\u00a0\u00a0 \u00a0 disabled\u00a0 pci:0000:00:1d.2<br \/>\nUSB4\u00a0\u00a0 \u00a0\u00a0 S3\u00a0\u00a0 \u00a0 disabled\u00a0 pci:0000:00:1d.3<br \/>\nUSBE\u00a0\u00a0 \u00a0\u00a0 S3\u00a0\u00a0 \u00a0 disabled\u00a0 pci:0000:00:1d.7<br \/>\nSLOT\u00a0\u00a0 \u00a0\u00a0 S5\u00a0\u00a0 \u00a0 disabled\u00a0\u00a0 pci:0000:00:1e.0<br \/>\nKBC\u00a0\u00a0 \u00a0\u00a0 S3\u00a0\u00a0 \u00a0 disabled\u00a0\u00a0 pnp:00:07<br \/>\nCOMA\u00a0\u00a0 \u00a0\u00a0 S5\u00a0\u00a0 \u00a0 disabled\u00a0 pnp:00:0b<\/code><\/p>\n<p>Hmm, so none of these say &#8220;ethernet&#8221; or &#8220;eth0&#8221;- now what?\u00a0 We turn to the lspci command<\/p>\n<p><code>$ lspci -tv<br \/>\n-[0000:00]-+-00.0\u00a0 Intel Corporation 82865G\/PE\/P DRAM Controller\/Host-Hub Interface<br \/>\n+-02.0\u00a0 Intel Corporation 82865G Integrated Graphics Controller<br \/>\n+-06.0\u00a0 Intel Corporation 82865G\/PE\/P Processor to I\/O Memory Interface<br \/>\n+-1d.0\u00a0 Intel Corporation 82801EB\/ER (ICH5\/ICH5R) USB UHCI Controller #1<br \/>\n+-1d.1\u00a0 Intel Corporation 82801EB\/ER (ICH5\/ICH5R) USB UHCI Controller #2<br \/>\n+-1d.2\u00a0 Intel Corporation 82801EB\/ER (ICH5\/ICH5R) USB UHCI Controller #3<br \/>\n+-1d.3\u00a0 Intel Corporation 82801EB\/ER (ICH5\/ICH5R) USB UHCI Controller #4<br \/>\n+-1d.7\u00a0 Intel Corporation 82801EB\/ER (ICH5\/ICH5R) USB2 EHCI Controller<br \/>\n+-1e.0-[0000:03]----08.0\u00a0 Intel Corporation 82562EZ 10\/100 Ethernet Controller<br \/>\n+-1f.0\u00a0 Intel Corporation 82801EB\/ER (ICH5\/ICH5R) LPC Interface Bridge<br \/>\n+-1f.1\u00a0 Intel Corporation 82801EB\/ER (ICH5\/ICH5R) IDE Controller<br \/>\n+-1f.3\u00a0 Intel Corporation 82801EB\/ER (ICH5\/ICH5R) SMBus Controller<br \/>\n\\-1f.5\u00a0 Intel Corporation 82801EB\/ER (ICH5\/ICH5R) AC'97 Audio Controller<br \/>\n<\/code><br \/>\nSo now we know the PCI address for eth0 is<\/p>\n<p><code>+-1e.0-[0000:03]----08.0\u00a0 Intel Corporation 82562EZ 10\/100 Ethernet Controller<br \/>\n<\/code><br \/>\nand we match that the to \/proc\/acpi\/wakeup file line<\/p>\n<p><code>SLOT\u00a0\u00a0 \u00a0\u00a0 S5\u00a0\u00a0 \u00a0 disabled\u00a0\u00a0 pci:0000:00:1e.0<br \/>\n<\/code><\/p>\n<p>This tells us that we need to enable the SLOT device in the wakeup file:<\/p>\n<p><code>sudo sh -c \"echo SLOT &gt; \/proc\/acpi\/wakeup\"<\/code><\/p>\n<p>I thought it&#8217;d be nice to make my keyboard also able to wake the machine up from sleep, this simply requires enabling the KBC device:<\/p>\n<p><code>sudo sh -c \"echo KBC &gt; \/proc\/acpi\/wakeup\"<\/code><\/p>\n<p>The last step is to do these steps every time we clean boot the system.\u00a0 There was <a href=\"http:\/\/ubuntuforums.org\/showthread.php?t=234588\">another useful thread<\/a> in the ubuntu forums that describes how to create an \/etc\/init.d script to do it.\u00a0 My script was presented above in its complete form.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The ability to wake a machine up over the network is really nice.\u00a0 This feature is referred to as wake on lan (WOL).\u00a0 Most modern hardware supports this, and many operating systems have it nicely integrated (Mac OSX for one) &#8211; under Linux it required a bit more magic.\u00a0 This post is specific to Ubuntu &hellip; <a href=\"https:\/\/lowtek.ca\/roo\/2009\/wake-on-lan\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Wake On Lan&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-524","post","type-post","status-publish","format-standard","hentry","category-computing"],"_links":{"self":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/524","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/comments?post=524"}],"version-history":[{"count":10,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/524\/revisions"}],"predecessor-version":[{"id":534,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/posts\/524\/revisions\/534"}],"wp:attachment":[{"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/media?parent=524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/categories?post=524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lowtek.ca\/roo\/wp-json\/wp\/v2\/tags?post=524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}