Pm-utils (Italiano)

From ArchWiki
Revision as of 19:47, 15 October 2011 by Veleno77 (talk | contribs) (creata pagina italiana)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary end

Tango-preferences-desktop-locale.pngThis article or section needs to be translated.Tango-preferences-desktop-locale.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Pm-utils (Italiano)#)
Attenzione: Questo articolo è in fase di traduzione. Seguite per ora le istruzioni della versione inglese.

pm-utils is the new suspend and powerstate setting framework. It is designed to replace such scripts as those provided by the Template:Codeline package.

It is usually used by upower to execute the various hacks 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.

A lesser known feature is one that mimmicks toggling done by Laptop Mode Tools, although the responsible scripts have been deleted from the Arch Linux package.

Used in conjunction with the cpufrequtils package, notebook (and desktop) owners are provided with a complete power management suite.


The Template:Codeline package is now available from the Extra repository:

# pacman -S pm-utils
Note: If you run into issues when resuming video, it might be necessary to also sync Template:Codeline from [extra].
Note: If you are starting from a clean install, make sure that you have Template:Codeline installed.

Basic Configuration

Hibernation (suspend2disk)

In order for suspend2disk (hibernate) to work, we need to edit Template:Filename as root and add resume=/path/to/swap/drive (e.g. Template:Filename) to the kernel options, for example:

# (0) Arch Linux
title  Arch Linux
root   (hd0,0)
kernel /vmlinuz26 root=/dev/sda3 resume=/dev/sda2 ro vga=0
initrd /kernel26.img

Raid swap example:

# (0) Arch Linux
title  Arch Linux
root   (hd0,0)
kernel /vmlinuz26 root=/dev/md2 resume=/dev/md0 ro md=0,/dev/sda2,/dev/sdb2 md=2,/dev/sda5,/dev/sdb5 vga=773
initrd /kernel26.img

If you want to use the UUID of the device instead then use the following example (The UUID itself can be found out by using the blkid command as root.):

# (0) Arch Linux
title  Arch Linux
root   (hd0,0)
kernel /vmlinuz26 cryptdevice=/dev/sda2:main root=/dev/mapper/main-root resume=/dev/disk/by-uuid/1d893194-b151-43cd-a89e-6f89bd8b9f99 ro
initrd /kernel26.img

When the machine is placed into hibernation, it will now move all data from RAM to the swap partition... you did make your swap partition large enough to hold your RAM data, right?

For GRUB2, adjust the "linux" (kernel) line in Template:Filename of your OS in question. Here my example (obviously, change the resume path to your swap partition):

linux   /boot/vmlinuz26 root=/dev/disk/by-uuid/818dc030-8108-4428-8859-b73a58d0b0f3 ro  quiet resume=/dev/sda2

For discussion regarding permanence, please refer to this thread.

Even if your swap partition is smaller than RAM, you still have a big chance in hibernating successfully. According to kernel documentation, Template:Filename controls the size of the image created by the suspend-to-disk mechanism, which has a default value of 500M. The suspend-to-disk mechanism will do its best to ensure the image size will not exceed that number. You may either decrease it due to a small swap partition or increase it in purpose of possible hibernation speed up.

Warning: You may have to add the Template:Codeline hook to Template:Filename, see below!

Suspend/Hibernate as regular user

Three methods are available to suspend without the need for a root password: using HAL, using UPower, and giving the user permissions with visudo.

UPower method

Install Upower

# pacman -S upower

To suspend to RAM:

$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" \
/org/freedesktop/UPower org.freedesktop.UPower.Suspend

To suspend to disk (hibernate):

$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" \
/org/freedesktop/UPower org.freedesktop.UPower.Hibernate

User Permission Method

Because the Template:Codeline 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 Template:Filename file with Template:Codeline, for example:

# visudo

add the following lines, replacing username with your own:

username  ALL = NOPASSWD: /usr/sbin/pm-hibernate
username  ALL = NOPASSWD: /usr/sbin/pm-suspend

save and exit visudo

Or you can enable it for a group, using the following lines, of course replacing group:

%group   ALL = NOPASSWD: /usr/sbin/pm-hibernate
%group   ALL = NOPASSWD: /usr/sbin/pm-suspend

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 typing:

$ sudo pm-hibernate


$ sudo pm-suspend

Also, add yourself to the power group 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 the gnome shutdown applet to suspend/hibernate 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 gnome power management tools (and kpowersave?) to automatically suspend/hibernate when doing things like closing the laptop lid, running low on battery power etc...


pm-utils support to run commands depending on whether the system is connected to AC or not. Therefore a script has to be created inside the folder Template:Filename. An example of such a script can be found in the crunchbang forum.

Advanced Configuration

The main configuration file is Template:Filename. You should not edit this file, since after a package update it might be overwritten with the default settings. Put your config file into Template:Filename instead. You can just put a simple text file with

SUSPEND_MODULES="button uhci_hcd"

named Template:Filename or Template:Filename into Template:Filename 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 shutdown 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 Template:Filename. Say you want to disable the hook Template:Filename, you can do this easily by calling

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

Do not set the executable bit on that dummy-hook.

Alternative method

Create a file in Template:Filename with the modules you want to blacklist in the HOOK_BLACKLIST variable. For example, to manage power saving yourself, use:

HOOK_BLACKLIST="intel-audio-powersave journal-commit laptop-mode pcie-aspm sata_alpm sched-powersave"

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 Template:Filename. 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:

case $1 in
        echo "Hey guy, we are going to suspend to disk!"
        echo "Oh, this time we are doing a suspend to RAM. Cool!"
        echo "oh, suspend to disk is over, we are resuming..."
        echo "hey, the suspend to RAM seems to be over..."
    *)  echo "somebody is calling me totally wrong."

Put this into Template:Filename, do a Template:Codeline and it will spew some useless lines during suspend / resume.

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.

How it Works

The concept is quite easy: the main script (Template:Codeline, called via symlinks as either Template:Codeline, Template:Codeline or Template:Codeline) executes so-called "hooks", executable scripts, in the alphabetical sorted order with the parameter Template:Codeline (suspend to RAM) or Template:Codeline (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 Template:Codeline (resume from RAM) or Template:Codeline (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 HAL, initiated by desktop applets like Template:Codeline or Template:Codeline.

Template:Box Note

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

The hooks for suspend are placed in

The hooks for the power state are placed in

Hooks in Template:Filename take precedence over those in Template:Filename, so the system administrator can override the defaults provided by the distribution.


If suspend or hibernate did not work correctly, you will probably find some information in the log file Template:Filename, for example which hooks were run and what the output of them was.

Resume Hook

It has been suggested that some systems, including those using LVM, require the Template:Codeline hook be added to the initrd image, otherwise the kernel will not resume. You can see if this is happening if the hibernation works fine, no error messages appear in Template:Filename and the kernel logs the following message: "PM: Hibernation image not present or could not be loaded." To add the resume hook, edit Template:Filename as root and add Template:Codeline to the HOOKS array:

HOOKS="base udev autodetect ide scsi sata lvm2 resume filesystems "

Note that this is an example, and your HOOKS array may look different.

Template:Codeline must be placed after 'ide', 'scsi', 'sata' and/or 'lvm2', but before 'filesystems'. Of course, there has to be an appropriate 'resume' file in Template:Filename, but it should already be there, as it is part of the Template:Codeline package.

Finally, you must rebuild the initrd image for these changes to take effect:

# mkinitcpio -p linux

Template:Box Note


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 Template:Filename 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 Template:Codeline kernel command line option. This option could be pass to the kernel through GRUB options by editing the file Template:Filename (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 Template:Codeline to your kernel. In GRUB, the line in Template:Filename should be something like this:

kernel /vmlinuz26 root=/dev/vg00/root resume=/dev/vg00/swap i8042.reset=1 ro

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.

VirtualBox problems

The VirtualBox kernel modules cause Template:Codeline and Template:Codeline to fail on some laptops. (See this discussion). Instead of suspending or hibernating, the system freezes and indicator LED's 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:


rmmod vboxdrv
modprobe vboxdrv

Tips and Tricks / FAQ

Triggering suspend manually

If you want to trigger suspend manually for debugging, without using HAL and other frameworks, call Template:Codeline or Template:Codeline as root.

Automatically deactivate kwin compositing before suspend

At the moment, pm-suspend fails to resume with garbled screen when you resume from suspend with active AIGLX clients, such as kwin compositing (only ati-catalyst?). To automatically deactivate kwin compositing add a new hook under Template:Filename with this content:

USER=`finger|grep '*:0'|grep -o '^\w*'`
case $1 in
       if `sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin compositingActive`;
               sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin toggleCompositing;
               sleep 1
               sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin toggleCompositing;
   *)  echo "somebody is calling me totally wrong."

I do not know if it is very secure or if it can be done simpler. Feel free to add better versions.

If you are having trouble getting the above script to work, you can try my version. This version removes the use of finger, and fixes the DBUS_SESSION_BUS_ADDRESS resolution which did not work for me (though my solution is admittedly quite dirty). Simply replace the first three lines with:

USER=`who | grep ':0' | grep -o '^\w*' | head -n1`
. /home/$USER/.dbus/session-bus/*

Using another sleep backend (like uswsusp)

Create a file with a SLEEP_MODULE variable, like this:

$ cat /etc/pm/config.d/module 

To list available modules, use:

$ pacman -Ql pm-utils | grep module.d

Having the hd power management level automatically set again on resume

Do it like this:

$ cat /etc/pm/sleep.d/50-hdparm_pm 

if [ -n "$1" ] && ([ "$1" = "resume" ] || [ "$1" = "thaw" ]); then
	hdparm -B 254 /dev/sda > /dev/null


$ sudo chmod +x /etc/pm/sleep.d/50-hdparm_pm

If the above bash script fails the work, the following may instead:


case "$1" in
               sleep 6
               hdparm -B 254 /dev/sda
exit $NA

Lower -B switch values may be effective. See hdparm.

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 Template:Codeline) through a hook in Template:Codeline (see hooks)

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 Template:Codeline or Template:Codeline manually from a root shell in a terminal. Maybe you will already get some output that will point you to the problem. The suspend scripts also write a [[#Troubleshooting|logfile at Template:Codeline]].

Add sleep modes to Openbox menu

Openbox users can add the new scripts as additional shutdown options within the Openbox menu by adding the items to a new or existing sub-menu in Template:Codeline, for example:

<menu id="64" label="Shutdown">
	<item label="Lock"> <action name="Execute"> <execute>xscreensaver-command -lock</execute> </action> </item>
	<item label="Logout"> <action name="Exit"/> </item>
	<item label="Reboot"> <action name="Execute"> <execute>sudo shutdown -r now</execute> </action> </item>
	<item label="Poweroff"> <action name="Execute"> <execute>sudo shutdown -h now </execute> </action> </item>
	<item label="Hibernate"> <action name="Execute"> <execute>sudo pm-hibernate</execute> </action> </item>
	<item label="Suspend"> <action name="Execute"> <execute>sudo pm-suspend</execute> </action> </item>

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

Handling "sleep" and "power" buttons

"Sleep" and "power" buttons are handled by Template:Codeline in Template:Filename (see "button/power" and "power/sleep" entries). You may want to substitute the default actions with calls to pm-suspend and pm-hibernate.

Locking the screen saver on hibernate or suspend

It is a good idea to have the system require a password after waking up. One way to do this is to make a script Template:Filename (making sure it's 755 and root:root, like other similar scripts in this area). Replace username with your username and add your desired screen locker in between the "" after su $USER -c.

# 00screensaver-lock: lock workstation on hibernate or suspend
DBUS=$(ps aux | grep 'dbus-launch' | grep -v root)
if ! -z $DBUS ;then
 USER=$(echo $DBUS | awk '{print $1}')
 USERHOME=$(getent passwd $USER | cut -d: -f6)
 export XAUTHORITY="$USERHOME/.Xauthority"
 for x in /tmp/.X11-unix/*; do
   DISPLAYNUM=$(echo $x | sed s#/tmp/.X11-unix/X##)
   if -f "$XAUTHORITY" ; then
           export DISPLAY=":$DISPLAYNUM"
 export XAUTHORITY="$USERHOME/.Xauthority"
 export DISPLAY=":0"

case "$1" in
      su $USER -c "/usr/bin/slimlock" & # or any other such as /usr/bin/xscreensaver-command -lock
   *) exit $NA

Other Resources


This wiki entry was originally sourced from the OpenSUSE WikiTemplate:Linkrot (Licensed under GPL). A big thank you goes to the Template:Codeline developers and documenters for their time.