Pm-utils 10.2
From openSUSE
| Version: 10.2
| The information below is for openSUSE 10.2. For newer releases, please read Pm-utils |
Contents |
pm-utils - The next-generation suspend infrastructure
pm-utils will be the new suspend framework. It is usually used by HAL to execute the various hacks needed to work around bugs in drivers and subsystems that are not yet aware of suspend.
Although pm-utils is a framework that will be common between all Linux distributions in the future, there are still some SUSE-specific features and patches that are not yet upstream. I will mark the configuration variables that are SUSE specific as such.
Basic functionality (or "How it works")
The concept is quite easy: the main script (pm-action, called via symlinks as either pm-suspend or pm-hibernate) executes so-called "hooks", scripts that are located in /etc/pm/hooks, in the alphabetical sorted order with the parameter suspend (suspend to RAM) or hibernate (suspend to disk). Once all hooks are done, it puts the machine to sleep. After the machine has woken up again, all those hooks are executed in reverse order with the parameter resume (resume from RAM) or thaw (resume from disk). The hooks do various stuff, for example preparing the bootloader, stopping the bluetooth subsystem or unloading of critical modules.
Both pm-suspend and pm-hibernate are usually called from HAL, initiated by desktop applets as gnome-power-manager or kpowersave.
Configuration
The main configuration file is /etc/pm/config, additional configuration files can be put into /etc/pm/config.d. Note that the config files and the hooks must have the "x" bit set to be executed.
Variables in /etc/pm/config
SUSPEND_MODULES="button" # the list of modules to be unloaded before suspend
SUSE-specific variables
HIBERNATE_METHOD={userspace,kernel} # selects the suspend to disk method. Defaults to userspace.
S2RAM_OPTS="" # options that are passed to s2ram. See also s2ram for more information.
Troubleshooting
If suspend or hibernate did not work correctly, you will probably find some information in the logfile /var/log/pm-suspend.log, for example which hooks were run and what the output of them was.
Creating your own hooks
If you want to do something specific to your setup during suspend / hibernate, then you can easily put your own hook into /etc/pm/hooks. The hooks in this directory will be called in alphabetic order during suspend (that's the reason their names all start with 2 digits, to make the ordering explicit) and in the reverse order during resume.
I'm showing a pretty useless demonstration hook here, that will just put some informative lines into your logfile:
#!/bin/bash
case $1 in
hibernate)
echo "Hey guy, we are going to suspend to disk!"
;;
suspend)
echo "Oh, this time we're doing a suspend to RAM. Cool!"
;;
thaw)
echo "oh, suspend to disk is over, we are resuming..."
;;
resume)
echo "hey, the suspend to RAM seems to be over..."
;;
*) echo "somebody is calling me totally wrong."
;;
esac
Put this into /etc/pm/hooks/66dummy, do a chmod +x /etc/pm/hooks/66dummy and it will spew some useless lines during suspend / resume.
Please note that this directory has been moved to /usr/lib/pm-utils/sleep.d/ in OpenSuSE 10.3.
WARNING: all the hooks run as user root. This means that you need to be careful when creating temporary files, check that the PATH variable is set correctly etc. to avoid security problems.
Various tips and tricks
Triggering suspend manually
If you want to trigger suspend manually for debugging, without using HAL and other frameworks, call pm-suspend or pm-hibernate as root.
Attention: this is only useful for debugging and it would be good if you knew what you are doing when using this.
Using suspend to RAM on machines that are not in the s2ram whitelist
If you want to force suspend to RAM, you need to add -f to the S2RAM_OPTS-Variable in /etc/pm/config. You also need to put all other options that you need for your machine into this variable. An example might be:
S2RAM_OPTS="-f -a 3"
It might be a good idea to report your machine on as described in the s2ram-Page, so that you do not need to do this in the future.
Disabling a hook
If a hook is run which you do not like or which you think is not useful or even harmful, we'd appreciate a bugreport for that. You can however easily disable hooks by just disabling the "x" bit from the file with
chmod -x /etc/pm/hooks/the_hook
Restarting the mouse
On some laptops the mouse will hang after an otherwise successful suspend. One way to remedy this is to force a reinit of the PS/2 driver (here i8042) through a hook in /etc/pm/hooks (see hooks)
#!/bin/sh echo -n "i8042" > /sys/bus/platform/drivers/i8042/unbind echo -n "i8042" > /sys/bus/platform/drivers/i8042/bind
--Esox81 20:30, 22 August 2007 (UTC)

