pm-utils is a suspend and powerstate setting framework. It is designed to replace such scripts as those provided by the powersave package.

pm-utils is a collection of shell scripts that wrap the kernel mode suspend/resume with the various hacks. These hacks are needed to work around bugs in drivers and subsystems that are not yet aware of suspend. It 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.

If you are starting from a clean install, make sure that you have acpi installed.

Run pm-suspend, pm-suspend-hybrid or pm-hibernate as root to trigger suspend manually. The suspend scripts write log to /var/log/pm-suspend.log.

Installing alternative suspend backend (optional)

The Arch Linux package ships with support for the following backends: kernel, tuxonice and uswsusp which can be seen from command:

pacman -Ql pm-utils | grep module.d

Suspend backend is specified by the SLEEP_MODULE configuration variable in /etc/pm/config.d and defaults to the kernel backend. To use the alternative suspend backends the respective packages need to be installed. Both of these are available in the Arch User Repository:

Furthermore, pm-utils ships with its own video quirks database in /usr/lib/pm-utils/video-quirks/.

Basic configuration

Standby/suspend to RAM

In the ideal case, running pm-suspend as root should initiate suspend to memory, meaning that all running state will be preserved in RAM and all components other than RAM will be shut down to conserve power. Pressing the power button should initiate a resume from this state.

Note: It is always recommended to put your network drivers in SUSPENDED_MODULES because most wireless drivers are known to cause issues after standby. Intel's iwlwifi, Atheros' ath5k and Realtek's r8* drivers were all reported to have issues after resume on the forums. Iwlwifi even drops to 1Mbps connection if it is not reloaded after resume.

In some cases, it is possible that running pm-suspend causes hangs or other issues. This may be due to specific "misbehaving" modules. If you know which modules could cause such issues, adding a SUSPEND_MODULES config to /etc/pm/config.d/modules of the form:

SUSPEND_MODULES="uhci_hd button ehci_hd iwlwifi"

should cause these modules to be specifically unloaded before suspend and reloaded after resume.

To configure invoking pm-suspend automatically on power events like laptop lid close, please refer to Acpid.

User permission method

Because the pm-utils scripts must be run as root, you may want to make the scripts accessible to normal users by running sudo without the root password. To do so, edit the /etc/sudoers file with visudo as root. For more information, see sudo.

Add the following lines, replacing username with your own user name, then save and exit visudo:

Note: These must come after any user privilege specifications, e.g., username ALL=(ALL) ALL, or they will not work.

You can now run the scripts without a password by simply running:

$ sudo pm-hibernate

or:

$ sudo pm-suspend

Also, add yourself to the powergroup so that way using things like applets to do suspend will work. If you do not do this, when you try to use suspend though things like GNOME's shutdown applet, your computer will just play a very annoying loud triple beep and lock the screen.

# gpasswd -a username power

You should now be able to use your Desktop Environment's power management tools to automatically suspend or hibernate when doing things like closing the laptop lid, running low on battery power, etc.

Power saving

pm-utils supports running commands depending on whether the system is connected to the AC adapter or not; therefore, a script has to be created inside the folder /etc/pm/power.d/. An example of such a script can be found in the crunchbang forum. Be aware that upower must be running in order to detect changing AC states (see more information).

Change brightness depending on AC state

One possible example looks as follows and changes brightness according to the AC state. Create a file called /etc/pm/power.d/00-brightness with the following content and change the path to the brightness setting as well as the value written into the file with echo according to your system.

Suspend on idle/inactivity

One method relies on xautolock program. Add following: xautolock -time 30 -locker "sudo pm-suspend" & to ~/.xinitrc. This implies that pm-suspend is called after 30 minutes of inactivity.

Using Swap file instead of regular swap partition

If you want use swap file instead of regular swap partition, see Swap File.

Advanced 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.

Available variables for use in config files

SUSPEND_MODULES="button"

the list of modules to be unloaded before suspend

SLEEP_MODULE="tuxonice uswsusp kernel"

the default sleep/wake systems to try

HIBERNATE_MODE="shutdown"

forces the system to shut down rather than reboot

Disabling a hook

If a hook is run which you do not like or which you think is not useful or even harmful, we would appreciate a bug report 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.

Note: Make sure you create the dummy files in the appropriate directory. For example if you are trying to disable hooks in /usr/lib/pm-utils/power.d, you will need to place the dummy file in /etc/pm/power.d.

Alternative method

Create a file in /etc/pm/config.d with the modules you want to blacklist in the HOOK_BLACKLIST variable.
For example, to manage power saving yourself, use:

Creating your own hooks

Note: If you are using systemd, then these hooks located in sleep.d will probably not work. In these cases you want to consider using sleep hooks of systemd.

If you want to do something specific to your setup during suspend or 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 is the reason their names all start with 2 digits, to make the ordering explicit) and in the reverse order during resume. The general convention to be followed on number ordering is:.

00 - 49

User and most package supplied hooks. If a hook assumes that all of the usual services and userspace infrastructure is still running, it should be here.

50 - 74

Service handling hooks. Hooks that start or stop a service belong in this range. At or before 50, hooks can assume that all services are still enabled.

75 - 89

Module and non-core hardware handling. If a hook needs to load/unload a module, or if it needs to place non-video hardware that would otherwise break suspend or hibernate into a safe state, it belongs in this range. At or before 75, hooks can assume all modules are still loaded.

90 - 99

Reserved for critical suspend hooks.

I am showing a pretty useless demonstration hook here, that will just put some informative lines into your log file:

#!/bin/bash
case $1 in
hibernate)
echo "Hey guy, we are going to suspend to disk!"
;;
suspend)
echo "Oh, this time we are 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 and resume.

Warning: All the hooks run as root. This means that you need to be careful when creating temporary files, check that the PATH environment variable is set correctly, etc. to avoid security problems.

How it works

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 perform various tasks, such as preparing the bootloader, stopping the Bluetooth subsystem, or unloading of critical modules.

Both pm-suspend and pm-hibernate are usually called from Udev, initiated by desktop applets like gnome-power-manager or kpowersave.

Note: suspend-hybrid is a placeholder right now -- it is not completely implemented.

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.

Pm-suspend internals

This outlines the internal actions when pm-suspend is run, describing how pm-utils gracefully falls back onto the kernel method if the requirements of other methods are not met.

$ pm-suspend

The first step is set-up preliminary variables and source parent scripts:

The variable METHOD is extracted from the executable name, suspend from pm-suspend and hibernate from pm-hibernate.

The location of runtime configuration parameters is defined in /usr/lib/pm-utils/pm-functions as PM_UTILS_RUNDIR="/var/run/pm-utils" and STORAGEDIR="${PM_UTILS_RUNDIR}/${STASHNAME}/storage". Therefore STORAGEDIR="/var/run/pm-utils/pm-suspend/storage"; this is where pm-suspend will cache its configuration. Disabled hooks are stored as plain text files with the hook name prefixed by "disable_hook:". Configuration parameters are appended to the parameters file:

Then pm-functions will source the files located in /etc/pm/config.d/ in addition to /usr/lib/pm-utils/defaults. Upon returning, pm-functions will proceed to source the files specified by $SLEEP_METHOD as /usr/lib/pm-utils/module.d/$SLEEP_METHOD[...] if they exist:

Assuming $SLEEP_MODULE is not empty and uswsusp is specified, /usr/lib/pm-utils/module.d/uswsusp is executed. This script checks several requirements (these are the requirements for being able to use uswsusp):

The first function, add_before_hook disables the pm-utils hooks 99video since this functionality is subsumed by s2ram.
The second function, add_module_help, adds uswsusp-module-specific help, which in essence replaces the help function provided by 99video.

The method _run_hooks, will for each hook in "${PM_UTILS_LIBDIR}/$1.d" and "${PM_UTILS_ETCDIR}/$1.d", check that sleep has not been inhibited and update the runtime parameters stored in $PARAMETERS before running each hook via run_hook $hook $2. In the case of Suspend-to-RAM, all the hooks in {/usr/lib/pm-utils/sleep.d/,/etc/pm/sleep.d/} will be enumerated, and run_hook will be passed the parameters $hook and "suspend suspend". The method run_hook uses the hook_ok function to verify that the hook has not been disabled before executing the hook with the "suspend suspend" parameters.

Troubleshooting

If suspend or hibernate did not work correctly, you will probably find some information in the log file /var/log/pm-suspend.log. For example, which hooks were run and what the output of them was should be in that log file.

Also, check the output of the pm-is-supported command. This command (with the --hibernate or --suspend flag) will do some sanity checking and report any errors it finds in your configuration. It will not detect all possible errors, but may still be useful.

Segmentation faults

If you experience segmentation faults that might result in an unresponsive system and missing keys then try to set the UUID in the resume-path in /boot/grub/menu.lst as explained above.

Reboot instead of resume from suspend

This problem started when saving NVS area during suspend was introduced (in 2.6.35-rc4) (mailing list post). However, it is known that this mechanism does not work on all machines, so the kernel developers allow the user to disable it with the help of the acpi_sleep=nonvs kernel command line option. This option could be pass to the kernel through GRUB options by editing the file /boot/grub/menu.lst (GRUB 0.97) on the kernel line.

Resume from suspend shuts down instead of wake up

On an Acer Aspire AS3810TG, resuming from suspend shuts down the computer instead of waking it up. If you experience a similar issue, try passing the parameter i8042.reset=1 to your kernel. In GRUB, the line in /boot/grub/grub.cfg should be something like this:

Although I have not tested this, you could also set this parameter live without having to restart by doing:

# sysctl -e -w i8042.reset=1

Blank screen when waking from suspend

Some laptops (e.g. Dell Inspiron Mini 1018) will just show a black screen with no backlight after resuming from suspend. If this happens to you, try going into the BIOS of the laptop and disabling Intel SpeedStep if it is present.

You could also try, without disabling SpeedStep, creating a quirk in /etc/pm/sleep.d/ with this content (requires vbetool):

save it as you want but with a 00 in front of the name so this is called last when resuming; remember to chmod +x the script.
Try adjusting the sleep time if the other commands are called too soon, or if it works well, you can also try removing that line.

Some other laptops (e.g. Toshiba Portégé R830) will just show a black screen with no backlight after resuming from suspend, with fans blowing at top speed. If this is what you're seeing, try going into the BIOS and disable the VT-d virtualization setting by switching to "VT-x only".

VirtualBox problems

The VirtualBox kernel modules cause pm-suspend and pm-hibernate to fail on some laptops. (See this discussion). Instead of suspending or hibernating, the system freezes and indicator LEDs blink (the suspend indicator in the case of ThinkPads and the Caps Lock and Scroll Lock indicators in the case of the MSI Wind U100). The pm-suspend and pm-hibernate logs appear normal.

The problem can be fixed by removing the modules before suspension or hibernation and reloading them afterwards. That can be accomplished through a script:

#!/bin/sh
rmmod vboxdrv
pm-hibernate
modprobe vboxdrv

Note: Some users reported that it is sufficient to rebuild the kernel module by running vboxbuild as root.

Hibernate with missing swap partition

If you try to hibernate without an active swap partition, your system will look like it is going into hibernate, and then immediately resume again. There are no error messages warning you that there is no swap partition, even when verbose logging is activated, so this problem can be very hard to debug. On my system, the swap partition was somehow corrupted and deactivated, so this may happen even if you set up a swap partition during install. If hibernate displays this behaviour, make sure that you actually have a swap partition that is being used as such. The output of the blkid command should look e.g. like

with one of the lines having "swap" as the type. If this is not the case, consult Swap#Swap partition for instructions on re-creating/activating the swap partition.

Black screen with unblinking cursor when trying to suspend

If you get a black screen with unblinking cursor when trying to do

$ sudo pm-suspend

have a look at /var/log/pm-suspend.log and search for "ehci" or "xhci". Some of the names you could find may be "ehci_hd", "xhci_hd" or "ehci_hcd".

Then as root create the file /etc/pm/config.d/modules and include this code with the exact name of the ehci or xhci module you found. For example:

SUSPEND_MODULES="ehci_hcd"

Suspend should now be working.

Blank screen issue

Some users have reported having issues with their laptops not resuming after a suspend or hibernate. This is due to the autodetect hook in "HOOKS" array of the /etc/mkinitcpio.conf file. This can be disabled using the same method for adding the resume hook. Just remove autodetect from the list and follow the steps to build the new image. See Resume Hook for more details on building the new image.

Note: If you are using plymouth it may be an other reason to this issue. Adding resume before plymouth in "HOOKS" array of the /etc/mkinitcpio.conf file should fix this.

Unable to resume with 64 bit OS

Certain motherboards/BIOS combinations (specifically known are some Zotac ITX boards, perhaps others) will not resume properly from suspend if any 64 bit operating system is installed. The solution is the enter your BIOS setup and Disable the "Memory Remapping Hole" in your DRAM configuration page. This will probably fix the suspend to RAM problem but will probably result in your OS not detecting all of your RAM.

Tips and tricks

Having the HD power management level automatically set again on resume

Restarting the mouse

On some laptops the mouse will hang after an otherwise successful suspend. One way to remedy this is to force a re-initialization of the PS/2 driver (here i8042) through a hook in /etc/pm/hooks (see hooks)

Handling "sleep" and "power" buttons

"Sleep" and "power" buttons are handled by acpid in /etc/acpi/handler.sh (see "button/power" and "power/sleep" entries). You may want to substitute the default actions with calls to pm-suspend and pm-hibernate.

Please note that systemd handles power events on its own and does not use pm-utils or any scripts from /etc/pm/*.

Locking the screen saver on hibernate or suspend

You may wish to run a screen locking utility when the system suspends (so that a password is required after waking up). This can be done by adding a script to the /etc/pm/sleep.d folder. Make sure the script is executable (chmod 755) and owned by root:root.

Replace /usr/bin/slimlock with the path to your screen locking utility of choice.

If you do not wish to hard-code your username (e.g., if you have multiple users), then it is necessary to determine the current X11 username and display number. For systems using systemd, you can use xuserrun and the following sleep.d script (be sure to modify the path to xuserrun and your desired screen locker):