Saturday, August 02, 2008

Power off your UPS after hibernating.

A recent email the Linux Kernel Mailing List sought a way to turn off a UPS after hibernating.

I haven't had the chance to give this a try yet, but think it should be possible with any recent TuxOnIce. Here are the steps:

1. Compile and install a TuxOnIce enabled kernel with the KeepImage mode compile time option enabled.
2. Create an initrd or initramfs that contains everything necessary to power off your UPS. This initrd/ramfs should be completely self contained. It should NOT mount your root (or other) filesystems. Test this initrd/ramfs by creating a separate Grub or Lilo menu entry.
3. On one of your partitions, create a small file that the file allocator can use. (You can use a swap partition instead, but it seems a waste of a partition table entry). Get the resume= command line parameter you need for this file and put it in the grub/lilo entry for the initrd/ramfs you created in step 2.
4. Modify the initrd/ramfs you created in step 2 so that, prior to doing the power off, it hibernates. In addition, modify it so that it enables the keep-image mode (echo 1 > /sys/power/tuxonice/keep_image) prior to doing the hibernate.
5. Now boot your kernel with the initrd/ramfs. It should hibernate rather turn off the UPS. This gets the powering off part ready.
6. Now boot with your normal kernel. Use the normal location for hibernating (NOT the file we set up in step 3).
7. Modify your /etc/hibernate/suspend2.conf so that it includes "ProcSetting alt_resume_param [value_from_step_]>" (Where "[value_from_step_3]" is replaced by the resume= value for the power-off-the-UPS-initrd/ramfs).

Now, when you hibernate, it should write the image as normal. Then, when the image has been written, it should start to resume from the image which you created in step 5. Once that image is resumed, the kernel will continue in your special initrd/ramfs with the commands to power off.
8. To go back to work, boot your normal kernel, as usual.

Labels: , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home