[rhelv6-list] SOLVED power saving (suspend) automatic setup

Gary Gatling gsgatlin at ncsu.edu
Thu Feb 24 16:17:11 UTC 2011


Hello,

I kind of stumbled across the answer to my question yesterday by accident. 
I thought some other RHEL 6 users might find what I am trying to do 
interesting? (I'd like to do this on my home CentOS/fedora boxes at 
some point)

It turns out when the machine first boots and no one has logged in yet 
"root" controls the power settings. But if root has never had an X 
session, the dotfiles will be missing. So I needed to run commands like:

gconftool-2 --type integer --set /apps/gnome-power-manager/timeout/sleep_computer_ac 600

as user root. But I didn't want to change the default settings for all 
users. If someone logs in and wants to change "their" settings they can 
in the preferences app but by default I want it not to hibernate or 
suspend. Only want to suspend when the machines are idle or unused.

Here is what I am trying to do..

We have a system here called VCL. (http://vcl.ncsu.edu/) A student can go 
to a web page and request a machine so that they can ssh into it. Then 
they can run whatever programs they want back to their X display. The web 
page spits out an IP address for them to use. That way labs can be used 
even when they are physically closed by users at home. (The web app will 
pick the fastest systems in whatever labs)

Gnome doesn't know about students sshing into a box. It will just suspend 
a box if someone is logged in through some other method than GNOME. :(

So I run a shell script via a cron job every 15 minutes to see if someone 
is logged in. If they are, I set root's setting NOT to suspend. If no one 
is logged in I change root's settings TO suspend after 600 seconds of 
inactivity. This should keep it from suspending right on the hour mark 
mostly I hope in case I run wol scripts on an even hour via cron from a 
server. It seems to work as expected.

One thing I discovered about suspend to RAM in Linux is that normally 
devices don't have permission to wake up a PC. (Like ethernet) So besides 
setting up stuff in the BIOS, you have to mess with the file 
/proc/acpi/wakeup, at least in RHEL 6. Probably older RHELs/fedoras 
also.

/proc/acpi/wakeup contains a list of devices that could possibly wake up 
the pc. By default they are all disabled. I made a script to walk the 
list and change each / every entry to enabled. The script runs at each 
boot as a init script in runlevel 345.

With these two things in place I can send "wol" packets to the PCs to wake 
them or a user can press the keyboard and wake the PC to log in. The mouse 
on my DELL doesn't seem to wake the PC for some reason. But on our KVM 
switch the mouse does wake the PC. I guess its some kind of power issue 
with usb probably. They can also press the power button. Eventually the 
script could be made fancier and do hibernate instead of suspend. Maybe if 
no one has logged in for like 3 days?

If anyone else might be interested in the rpm I created to do this I could 
make it availible in a public repo. (Its very simple) I do need to tweak 
it some more before I can use it. The power saving improvements in RHEL 6 
seem pretty cool to be able to do stuff like this. So thanks Red Hat. :)

Cheers,

Gary Gatling      | ITECS Systems




More information about the rhelv6-list mailing list