February 22, 2010

Booting computers on the network from Bubba|Two

I have a Linux computer on the network which I use for boring tasks that Bubba is not powerful enough to handle (tip: do not try to start jboss on Bubba|Two), but it's noisy and power hungry, so I turn it off when it's not in use. This is of course a bit of a bother when I need to access it from somewhere else.

The solution; Wake on LAN.
First off, you need a motherboard (or motherboard/network card combo) that supports WOL. Head into bios and enable it, often under the power settings. Do this for all computers you wish to be able to start over the network. Next you need to find the MAC address of the respective computers. On linux computers use the ifconfig command (try /sbin/ifconfig if it's not on your path), on windows open a command window (start -> run -> 'cmd' -> enter) and type 'ipconfig /all'. Write down the HWaddr/Physical address of the interface. It should look something like 00:12:34:56:78:9a. I recommend storing these in a file on your bubba/the computer you access from the outside. Shut down the computer.

Now, on bubba as root, install wakeonlan, I installed 'at' too, for part 2.
> apt-get install at wakeonlan

To boot the computer we will broadcast a "magic packet" to the network, using the hardware address from the previous step:
> wakeonlan 00:12:34:56:78:9a

I stored it in a script, start_something.sh. To make it executable use the command
> chmod u+x start_something.sh

Note: for WOL to work you have to shut down your computers to power-standby, not by holding the power button for a few seconds, turning off the power supply, etc. This will terminate power and the network card will not be able to listen for the power-on instruction. You also need the appropriate ACPI modules in you kernel. (which seems to be default in the latest ubuntu at least)

No comments:

Post a Comment