SDB:Pm-utils

Jump to: navigation, search
Icon-obsolete.png
This article or section refers to the version '11.3' and it is now obsolete!
Please refer to this article's discussion page for more information.
pm-utils is a suspend and powerstate setting 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.

Tested on openSUSE

Recommended articles


Basic functionality

Pm-utils is easily extensible by putting custom hooks into a directory, which can either be done by the system administrator or those hooks can be part of a package, especially if this package needs special attention during a system suspend or power state transition.

The concept is quite easy:

  • The main script pm-action (called via symlinks as either pm-suspend, pm-hibernate or pm-suspend-hybrid) executes so-called "hooks", executable scripts, 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.

There is also the possibility to set the machine into high-power and low-power mode, the command pm-powersave is used with an additional parameter of true or false. It works basically the same as the suspend framework.

The hooks for suspend are placed in

  • /usr/lib/pm-utils/sleep.d (distribution / package provided hooks)
  • /etc/pm/sleep.d (hooks added by the system administrator)

The hooks for the power state are placed in

  • /usr/lib/pm-utils/power.d (distribution / package provided hooks)
  • /etc/pm/power.d (hooks added by the system administrator)

Hooks in /etc/pm/ take precedence over those in /usr/lib/pm-utils/, so the system administrator can override the defaults provided by the distribution.


Configuration

The main configuration file is /usr/lib/pm-utils/defaults. You should not edit this file, since after a package update it might be overwritten with the default settings. Put your config file into /etc/pm/config.d/ instead. You can just put a simple text file with

SUSPEND_MODULES="button uhci_hcd"

named "modules" or "config" into /etc/pm/config.d and it will override the settings in the system wide configuration file.

Variables in config files

List of modules to be unloaded before suspend

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 the Suspend to RAM page for more information.

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/sleep.d. 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.

Icon-warning.png
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

Here is 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/sleep.d/66dummy, do a chmod +x /etc/pm/sleep.d/66dummy and it will spew some useless lines during suspend / resume.


Various tips and tricks / FAQ

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.

Icon-warning.png
Warning: 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 a configfile in /etc/pm/config.d/, see Configuration. 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 creating an empty file corresponding to the hook in /etc/pm/sleep.d/. Say you want to disable the hook /usr/lib/pm-utils/sleep.d/45pcmcia, you can do this easily by calling

touch /etc/pm/sleep.d/45pcmcia

Do not set the executable bit on that dummy-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

It seems to not do anything / where is the logfile

If it seem to not do anything when called via the desktop applets, then try to call pm-suspend or pm-hibernate manually from a root shell in a terminal. Maybe you'll already get some output that will point you to the problem. The suspend scripts also write a logfile at /var/log/pm-suspend.log.


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.


See also


External links