How to use Wake-on-LAN on XenServer
In this post, we'll see how to activate the Wake-on-LAN (WOL) on XenServer.
Hardware configuration
Naturally, it depends of your hardware configuration. If you don't have any Server Manager Tool, like iLO (HP) or iDRAC (Dell), you can count on the WOL feature of your network card.
In our lab, we got basic hardware: ITX cards and Core i5 CPU, not the kind of hardware you'll find in a data-center, but it's compatible with WOL.
Configure the operating system
XenServer 6 is based on CentOS. By default, when you shutdown the host, it doesn't activate the network card. In this case, you can't wake the box, because your interface is completely off. So, we need to configure it:
- connect in SSH to your host
- do a
ethtool -s eth0 wol g
- that's all!
But if you want to do this permanently, this command will do the trick:
echo '/usr/sbin/ethtool -s eth0 wol g' >> /etc/rc.d/rc.local
Now, when the system shutdown, it's ready to listen for a WOL packet.
Configure XenServer
But that's not enough to start a server using Xen Orchestra or XenCenter. You need to tell the XAPI how to wake it: because we saw there is different options to do that (WOL, iDRAC/iLO, even custom scripts).
Again, go in SSH on your host (or any host in the pool) and use this:
xe host-set-power-on-mode uuid=<MyHost_UUID> power-on-mode=wake-on-lan
For people using iDRAC or iLO, just replace wake-on-lan
by DRAC
or iLO
respectively, but that's not all. You need to give to XAPI the IP and the credentials of your Server Manager Tool. The command will look like this:
xe host-set-power-on-mode uuid=<MyHost_UUID> power-on-mode=DRAC power-on-config=xx.xx.xx.xx, user, password
with xx.xx.xx.xx the IP of your DRAC controller. For iLO, just replace DRAC
by iLO
. That's it!
In Xen Orchestra
Since the 3.5.2 release, you'll see a Start button in the host menu if your host is Halted. Just click and you can boot it.
Now, you can imagine what it's possible to do in XO with this kind of feature:
- scheduled shutdown for some hosts in the evening (e.g: hosts only used for developer VMs during the day) and start them in early in the morning. A lot of energy saved!
- shutdown some hosts automatically when your architecture is not stressed, then, if necessary, boot them and migrate some VM on it.
- a lot of other useful cases. Everything is possible now with Xen Orchestra!