Power Management - Sleep / Wake up Server when accessed

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?

Thanks


Solution 1:

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

Solution 2:

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