I have a headless HP Proliant Microserver with ubuntu installed. This machine has samba shares on it serving media and I usually rdp or ssh into it. Now my issue is I want the machine to go into sleep mode(so the state is saved from ram to the harddrive) and it will seem like it is turned off after an hour of idling.

If there is any attempt to access the samba share through LAN I would like it to wake up. Now my motherboard supports this function, can anyone point me in the right direction for achieving this easily?



The best instruction I have found on the web was the XBMC wiki for WOL. In short (more info in the link):

  1. You need to enable WOL on your motherboard;
  2. Install ethtool: sudo apt-get install ethtool;
  3. Set Wake-on-LAN options: sudo ethtool -s eth0 wol g;
  4. Get it enabled at system start-up with an init script. There's an init script in the wiki link.

Untested; info from the wiki link


Further than sleep mode, what you're looking for is hibernate, as you want to save your state in your harddisk and shutdown completely the server.

So, as many have pointed, the answe is WOL (Wake On Lan). There are a lot of tutorials about it, but mainly you need to set up the following:

  • Your router has to bypass the magic packet (as the WOL packet is called) to your server, so you need to do the port forwarding. It's usually located in the LAN section. The default ports are 7 and 9.
  • Your motherboard needs to be listening on LAN port when is powered off. The most of modern MBs provide this feature, but is disabled by default. Check it! In my case, it is called "Power on by Ring on Lan".

Server doesn't need more setting than the suitable power management configuration to get the system down after an hour of inactivity (it could be done from System > Administration > Power management).

Obviously, you have to wait for a while after you sent the WOL packet, as your system needs to de-hibernate and it could take a few.

Good luck


I decided I wanted a solution to wake my media server automatically when accessed that wasn't dependent on dd-wrt.

I have a raspberry pi so I used it because it is low power and I don't mind keeping it on all the time, of course it could be run from any linux machine.

The final solution I found for myself was writing a little bash script. The raspberry-pi dependencies are etherwake and tcpdump. Both are not installed by default on rasbian. Also on the server Wake On Lan needs to be enabled as mentioned in the other posts.

sudo apt-get install etherwake
sudo apt-get install tcpdump

The wake script is as follows:

nano ~/wol.sh



pingInterval=60 #time interval, in seconds, between checks that the server is still awake.
target=192.168.x.x  #WOL target ip address
targetMAC=00:11:22:33:44:55  #WOL target MAC

wake () {
    tcpdump -i eth0 -c 1 -p host $target
    etherwake $targetMAC
    #echo WOL sent to $target at $targetMAC

while sleep $pingInterval; do
varPing=`ping -s 1 -c 2 $target > /dev/null; echo $?`
    if [ $varPing -eq 0 ]; then
        #echo ping success
        #echo ping fail

The primary idea is that it is run from my raspberry-pi which will wake the server if it notices a single arp request for the server. If the server is awake then it wont be listening for an arp request but send a few pings every now and then to make sure it is still awake.

I named the file wol.sh and made it executable. Then put it in the sudo crontab to launch @reboot as root. This is for tcpdump which needs elevated access to listen to eth0 and etherwake.

sudo chmod +x /home/pi/wol.sh
sudo crontab -e

add this to the bottom

@reboot sh /home/pi/wol.sh > /dev/null

With WoL enabled on your server to get it to wake up to specific protocol traffic you would need something like a script running on your router that has packet rules and can send the WoL magic packet when it receives the request.

Webserver wakeup example


Wake On Lan is the key, nearly all cards today support all modes (but not in linux :( ).

Easiest solution is a card which has a working Linux driver that supports Wake On Lan modes: pumbg in ethtool, you want something like unicast mode. So your computer starts as soon as you access its network address. But it is even more hard to get a list of cards which are supported by Linux, one I have found is Intel Gigabit Netzwerkadapter Pro/1000 GT PCI.

A workaround is, if you have a card that does not support all modes: Nearly all linux driver supports the g mode => magic packet. So you have to explictly turn your server on before you use it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.