From the Canyon Edge -- :-Dustin

Wednesday, February 25, 2009

Ubuntu Server: Suspend/Hibernate/Resume Call for Testing!

Late last week, Mark announced the next Ubuntu release, Karmic Koala. Mark noted that:
the best way to conserve energy is to go to sleep,
and these days even servers can suspend and resume,
so imagine if we could make it possible to build
a cloud computing facility that drops its energy use
virtually to zero
In December of 2008, I asked what you thought about suspending and hibernating Ubuntu Servers. While the "poll" wasn't unanimous, the overwhelming majority of you thought it might actually be useful in some situations.

It's not too early to start looking at this feature for Karmic. So I spent some time last week testing this, and I must say that I'm impressed with the very preliminary results. I was able to install the Ubuntu Jaunty Server on my hardware, both suspend and hibernate the system from the command line, and then remotely resume the system using wake-on-lan.

Impressively, my test system's power consumption is reduced by ~80% while in the suspended state, and can wake in ~5 seconds!

My test hardware is actually a desktop kit system (Asus P1-AH2, AMD x2 5800, 4GB, nVidia), running the Jaunty amd64 server.

At this point, I'm quite interested in gathering any feedback from the Ubuntu Server community on their experience suspending/hibernating/resuming the Jaunty Server on whatever hardware they might have. Here are some detailed instructions...

Server BIOS Setup

Check your BIOS for any relevant settings:
  • Make sure that wake-on-lan is enabled. This setting takes a variety of names in different BIOS implementations.
  • Make sure that low-power states are enabled (my bios had a setting for "S1 & S3" power states). Again, this may be labeled differently, but should be something along the lines of "Advanced Power Management".
Server OS Setup

Install Ubuntu Jaunty Server (i386 or amd64).

Install pm-utils and ethtool, both of which are now on the Jaunty Server CD.
  • sudo apt-get install pm-utils ethtool
Configure your network interface to wake-on-lan.
  • sudo ethtool -s eth0 wol g
I want this setting persistent across reboots, so I put this in /etc/rc.local.

Obtain the MAC address of your server, such that you can send the wake-on-lan magic packet from another system.
  • ifconfig eth0 | head -n1 | sed 's/^.*HWaddr //'
First, let ensure that wake-on-lan is working. Power this system down.
  • sudo poweroff
From another system, install the wakeonlan package.
  • sudo apt-get install wakeonlan
And send the magic packet to the MAC address you obtained earlier.
  • wakeonlan 00:11:22:33:44:55
If your server powers itself on, congratulations, wake-on-lan is working. If not, you need to get this working before you proceed further.

Once the server is back up, test suspend. Launch a program to run in the background, to ensure that the resume restored this state. And then run the pm-suspend command
  • screen top
  • (new window in screen-profiles)
  • sudo pm-suspend
Make sure that the system enters a lower power state. On my machine, the hard drives stop spinning, as well as the cdrom drive, cpu fans, case fans, etc. I tested resume twice, once by hitting the power button, and once by sending the wakeonlan signal.
  • wakeonlan 00:11:22:33:44:55
Then, test hibernate in a similar manner.
  • pm-hibernate
  • wakeonlan 00:11:22:33:44:55
Make sure that your context was saved, and the system is still running 'screen top' or whatever you chose to run.

Automated Testing

Next, I ran the automated test-suspend script developed by Andy Whitcroft on the Ubuntu Kernel team. I sent him a minor patch that tailored it a bit better for server testing. For details, see:
  • wget
  • sudo bash test-suspend --full --server

And I recorded my results at:
noting that this machine (Asus P1-AH2) was running the Ubuntu Server.

Do you have a server running Jaunty? Would you care to share your results?