Tuesday 14 August 2012

HP Microserver N40L - WOL problem (wake on lan)

UPDATE (April 2014) - a comment from a poster states that he had to change "eth0 to em1" for it to work under Ubuntu 14.04 

I've recently purchased a beautifully crafted mini server made by HP; it's the HP N40L microserver.

Leaving my PC switched on all day consumed anywhere between 110-180 watts of power so I was looking at ways of reducing energy consumption and this box only uses around 60 watts.

Memory has been increased from 2Gb to 8Gb, and the spare 2Gb stick of RAM now sits in my main PC - result!

Windows 7 worked OK until the legendary 'dazloader' patch was installed, and then it wouldn't boot (BSOD). BIOS problems might be the cause of that?

Anyway, the annoying thing about this box and Linux (specifically Ubuntu 10.10) is that the Wake On Lan functionality does not work. I did see a post about this mentioned on another blog here http://confoundedtech.blogspot.co.uk/2011/06/enable-wol-on-ubuntu-hp-microserver.html but the instructions didn't seem too clear to me and needed a tidy-up/re-write.

Here's the 3 lines of code we will be using later:

ifconfig eth0 down

It is more than likely that ethtool is not installed on your system by default, so install it with the following command:

sudo apt-get install ethtool

Once installed, see if your ethernet card supports WOL:

sudo ethtool eth0

This should return the following information:

Settings for eth0:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Half 1000baseT/Full
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Half 1000baseT/Full
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Speed: 100Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown
    Supports Wake-on: g
    Wake-on: g
    Current message level: 0x000000ff (255)
    Link detected: yes

As you can see, both the 'Supports Wake-on' and 'Wake-on' fields show 'g' which means it is supported.

We now need to make an entry in the /etc/rc.local file, which may be empty already. Insert the following line of code into the file, using whichever editor your prefer (vi/emacs or gedit for those GUI-lovers out there)

sudo ethtool -s eth0 wol g

Save the file away to disk.

Entries now need to be created for correct shutdown operation. We will be using the 3 lines of code mentioned earlier in this article:

sudo vi /etc/rc6.d/K99wol_poweroff

Paste these 3 lines of code into the file:

ifconfig eth0 down

Save the file to disk.

Mark the file executable:

sudo chmod 755 /etc/rc6.d/K99wol_poweroff

Now copy the file to 2 separate locations:

sudo cp /etc/rc6.d/K99wol_poweroff /etc/rc6.d/K9ls
sudo cp /etc/rc6.d/K99wol_poweroff /etc/rc0.d/K99wol_poweroff

You should now be able to shutdown the server. Please note that mine seemed to hang on shutdown the first time, but a subsequent reboot/shutdown seemed to clear it.

Try pinging the ethernet interface with your favourite/preferred magic ping packet tool. I tend to use the wol client from my Buffalo WHR-G300N router that's running DD-WRT.