HOWTO: Remote Wake-up of Ubuntu Linux Machine
Recently I faced a problem of transferring files between my Laptop and Media Center Machine at home. My setup is like this: I use to store all my media files (Photos, Videos, Audio collections of family) in Media Center Machine which is powered by Ubuntu 9.10. My laptop which also runs on Ubuntu 9.10 is meant for development and study purpose only. I use to transfer big ISO files and media files (downloaded from camera to laptop) to Media Center Machine. Before doing this I have to power on Media Center Machine by opening the lock in AV Furniture and switch on the Machine which is at Hall. I am such a lazy person to think of avoiding this simple manual work, so thought of power-on the Media machine remotely from another room.
I use Ethernet LAN Wake-up feature to do this. Here is how I did it.
1. Ensure that BIOS in target machine has a feature of “Wake-on LAN” or “Wake-on PCI devices”. Enable this feature.
2. Boot Ubuntu on target machine. Add the following line of command in /etc/rc.local file just before “exit 0″ line.
ethtool -s eth0 wol g
In the above code, my ethernet interface is “eth0″. Consider updating it with your ethernet interface.
3. Note down the MAC Address of your ethernet interface using ifconfig command as shown below
$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:1e:ba:b2:ab:0e
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
4. Reboot this machine. Now your target machine is ready. You either Hibernate or Suspend this machine now. But ensure that this machine is connected to power.
5. In laptop (which is my source machine, initiates wake-up), install wakeonlan application as shown below
$ sudo apt-get install wakeonlan
6. Run the wakeonlan utility as shown below with your MAC Address noted down
$ wakeonlan 00:1e:ba:b2:ab:0e
7. The above step should wake-up your target machine.
8. If necessary you can create a link to the above command as shown below
Enjoy the remote wake-up!
To shutdown the machine from remote, it is better to hibernate, so that using the above technique, wake-up will be easy. To hibernate remotely, you can install the “powermanagement-interface” package and issue “sudo pmi action hibernate” command using a ssh terminal to remote machine.