Gentoo Wiki


Note: This page was copied from the TuxOnIce page. The information should probably be externalized to here to reduce the length and size there.

For desktop environments that utilize the Hal framework, like Gnome and KDE, usage of hibernate-script has become depreciated in favor of pm-utils. Short for Power Management Utilities, pm-utils does most of the needed legwork outside of the kernel. This package gives you three commands to play with once installed: pm-hibernate, pm-suspend and pm-suspend-hybrid. One of the strengths of pm-utils is Hal intermediates the hibernation commands, allowing user usage without unnecessary fuss with permissions. A prerequisite to this page is setting up a form of suspend support in the kernel, such as TuxOnIce.


Installation and Setup

  1. Make sure the acpi USE flag is enabled universally. sys-power/pm-utils should be installed automatically.
  2. Log in as root in a terminal and try the pm-hibernate and pm-suspend commands to see if they work without errors.
  3. If something went wrong, check the log at /var/log/pm-suspend.log for clues. Usually it is a module or video card problem. Check out the troubleshooting section below for ideas. pm-utils has a common errors section at
  4. When done, continue to the Advanced Configuration section.

Advanced Configuration

Advanced configuration of pm-utils can be much more pain in the butt than hibernate-script. If you're uncomfortable with bash, you may want to check out a tutorial to brush up. To make pm-utils do anything fancy, you're going to have to play with the its hooks functionality by adding some scripts to /etc/pm/sleep.d.

Basically, all executable scripts in the /etc/pm/sleep.d directory are run in alphabetical order when hibernate/suspend is called. When returning from hibernate/suspend, all files in the directory are called in reverse alphabetical order. If you name your hook the same name as one of the predefined hooks in /usr/lib/pm-utils/sleep.d, it will override it with your own. This can be good or bad. An example custom hook skeleton file is below.

File: /etc/pm/sleep.d/50custom
case $1 in
       echo "Hibernating"
       echo "Suspending"
       echo "Returning from hibernation"
       echo "Returning from suspend"

You can test your custom hook without actually hibernating/suspending by calling it with the correct argument. For example, /etc/pm/sleep.d/50custom suspend. I hope this was enough to get you started in the right direction. Below are some examples that you may find useful.

Change TuxOnIce Kernel Variables

Unlike hibernate-script, your only choice for forcing some settings will be by echoing some strings directly at files in /sys/power/tuxonice from one of your custom hooks. For example, from the command line you can use the line below to temporarily change the userui variable without recompiling the kernel.

echo "/sbin/tuxoniceui_text" > /sys/power/tuxonice/user_interface/program

Thus you could make a custom hook with this code.

case $1 in
       echo "/sbin/tuxoniceui_text" > /sys/power/tuxonice/user_interface/program

If you think one of the special fixes of hibernate-script may apply to you like extra_pages_allowance for you video card and pm-utils doesn't do it automatically, this is how you can force the setting.

Restarting Services

Restarting services can be accomplished with:

case $1 in
       /etc/init.d/serviceName stop
       /etc/init.d/serviceName start

Unmounting Automounted Drives

Unmounting all automounted drives on hibernation or suspend can be done with:

case $1 in
      for drive in $( ls /media/ ); do
         gnome-umount -bnp ${drive} > /dev/null
         if [ $? -eq 0 ]; then
            echo "Unmounting ${drive} successful"
            echo "Unmounting ${drive} failed"

Hibernate Script through Power Management Utilities

Making hal use the hibernate scripts isn't so much difficult as pain in the butt. This is because whenever a new update is emerged, the custom scripts get overwritten. One way around this is to create a hook for pm-utils that reapplies the changes to the hal scripts whenever it is run. The idea is this script would only get run when hal is not using the hibernate scripts.

File: /etc/pm/sleep.d/01hibernateScripts


case $1 in
        /bin/mv ${HAL_HIBERNATE} ${HAL_HIBERNATE}.original
        /bin/echo "#!/bin/bash"              >> ${HAL_HIBERNATE}
        /bin/echo "/usr/sbin/hibernate"      >> ${HAL_HIBERNATE}
        /bin/echo "exit \$?"                 >> ${HAL_HIBERNATE}
        /bin/chmod +x ${HAL_HIBERNATE}
        /usr/bin/killall pm-hibernate
        /usr/bin/chvt 7
        /bin/mv ${HAL_SUSPEND} ${HAL_SUSPEND}.original
        /bin/echo "#!/bin/bash"              >> ${HAL_SUSPEND}
        /bin/echo "/usr/sbin/hibernate-ram"  >> ${HAL_SUSPEND}
        /bin/echo "exit \$?"                 >> ${HAL_SUSPEND}
        /bin/chmod +x ${HAL_SUSPEND}
        /usr/bin/killall pm-suspend
        /usr/bin/chvt 7

The the script above automatically makes a backup of the previous script, but it is usually easier to just reinstall hal if you want to reset it to the default settings and then delete the custom hook.

# emerge --oneshot hal
# rm /etc/pm/sleep.d/01hibernateScripts


There is a script that may help you figure out exactly what to do here at freedesktop. Screens that stay black or becomes glitchy during resume are strong signs of video adapter problems. Some services can become confused when coming out of suspend. In that case you should try simply restarting them. If that doesn't fix it, it's probably a module problem.


If you figured out a module is causing a problem, you need to unload/load it during suspend/resume. Of course there is the prerequisite that the driver must be compiled as a module in the kernel first. Once that is done, create a file like the one below.

File: /etc/pm/config.d/modules
#the list of modules to be unloaded before suspend
SUSPEND_MODULES="modulename1 modulename2 modulename3"


Restarting services automatically can be accomplished with the hooks functionality of sys-power/pm-utils. Since the file is basically a bash script, you just just have to add /etc/init.d/servicename restart to the appropriate places. Please go to the Advanced Configuration section for more information. If restarting the service doesn't fix it, you're likely dealing with a problematic module.

Video Adapters

General video adapter quirks should be detected by sys-apps/hal. If not, you can try the script at freedesktop to get some ideas what might be going wrong or use pm-suspend --help to get a list of all possible quirks you can try out. To apply the quirk permanently, look at the documentation at freedesktop to add your machine to the quirk list of Hal. The --quirk-radeon-off quirk requires app-laptop/radeontool to be installed and the --quirk-vbe quirks require sys-apps/vbetool to be installed.


Not written yet.


Retrieved from ""

Last modified: Thu, 09 Oct 2008 11:43:00 +0000 Hits: 128