https://wiki.archlinux.org/api.php?action=feedcontributions&user=A1russell&feedformat=atomArchWiki - User contributions [en]2024-03-28T13:33:13ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Pm-utils&diff=91198Pm-utils2010-01-07T03:06:45Z<p>A1russell: /* Available Variables for use in config files */ added HIBERNATE_MODE</p>
<hr />
<div>[[Category:Power management (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Pm-utils}}<br />
{{i18n_entry|简体中文|Pm-utils 电源管理 (简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
== Introduction ==<br />
'''pm-utils''' is the new suspend and powerstate setting framework. It is designed to replace such scripts as those provided by the <tt>powersave</tt> package.<br />
<br />
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. 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.<br />
<br />
Used in conjunction with the [[Cpufrequtils]] package, notebook (and desktop) owners are provided with a complete power management suite.<br />
<br />
== Installation ==<br />
<br />
The <tt>pm-utils</tt> package is now available from the [http://www.archlinux.org/packages/search/?q=pm-utils Extra] repository:<br />
# pacman -S pm-utils<br />
<br />
{{note|If you run into issues when resuming video, it might be necessary to also sync <tt>vbetool</tt> from [extra].}}<br />
<br />
== Basic Configuration ==<br />
=== Hibernation (suspend2disk) ===<br />
In order for suspend2disk (hibernate) to work, we need to edit ''/boot/grub/menu.lst'' as root and add '''resume=/path/to/swap/drive''' (e.g. /dev/sda2) to the kernel options, for example:<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,0)<br />
kernel /vmlinuz26 root=/dev/sda3 '''resume=/dev/sda2''' ro vga=0<br />
initrd /kernel26.img<br />
<br />
Raid swap example:<br />
# (0) Arch Linux<br />
title Arch Linux<br />
root (hd0,0)<br />
kernel /vmlinuz26 root=/dev/md2 resume=/dev/md0 ro md=0,/dev/sda2,/dev/sdb2 md=2,/dev/sda5,/dev/sdb5 vga=773<br />
initrd /kernel26.img<br />
<br />
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?<br />
<br />
Even if your swap partition is smaller than RAM, you still have a big chance in hibernating successfully. According to [http://www.mjmwired.net/kernel/Documentation/power/interface.txt kernel documentation], ''/sys/power/image_size controls the size of the image created by the suspend-to-disk mechanism'', which has a default value of 512M. ''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.<br />
<br />
=== Execute suspend/hibernate without root password ===<br />
Because the <tt>pm-utils</tt> 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 <tt>/etc/sudoers</tt> file with visudo, for example:<br />
# visudo<br />
<br />
add the following lines, replacing ''username'' with your own:<br />
''username'' ALL = NOPASSWD: /usr/sbin/pm-hibernate<br />
''username'' ALL = NOPASSWD: /usr/sbin/pm-suspend<br />
save and exit visudo<br />
<br />
Or you can enable it for a group, using the following lines, of course replacing ''group'':<br />
''%group'' ALL = NOPASSWD: /usr/sbin/pm-hibernate<br />
''%group'' ALL = NOPASSWD: /usr/sbin/pm-suspend<br />
<br />
Note: These must come after any user privilege specifications, e.g., "username ALL=(ALL) ALL", or they won't work.<br />
<br />
You can now run the scripts without a password by simply typing:<br />
$ sudo pm-hibernate<br />
or <br />
$ sudo pm-suspend<br />
<br />
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.<br />
<br />
# gpasswd -a ''username'' power<br />
<br />
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...<br />
<br />
== Advanced Configuration ==<br />
The main configuration file is '''<tt>/usr/lib/pm-utils/defaults</tt>'''. You ''should not edit this file'', since after a package update it might be overwritten with the default settings. Put your config file into '''<tt>/etc/pm/config.d/</tt>''' instead.<br />
You can just put a simple text file with<br />
SUSPEND_MODULES="button uhci_hcd"<br />
named "modules" or "config" into <tt>/etc/pm/config.d</tt> and it will override the settings in the system wide configuration file.<br />
<br />
=== Available Variables for use in config files ===<br />
SUSPEND_MODULES="button" # the list of modules to be unloaded before suspend<br />
SLEEP_MODULE="tuxonice uswsusp kernel" # The default sleep/wake systems to try<br />
HIBERNATE_MODE="shutdown" # forces the system to shutdown rather than reboot<br />
<br />
=== Disabling a hook ===<br />
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.<br />
You can however easily disable hooks by just creating an empty file corresponding to the hook in <tt>/etc/pm/sleep.d/</tt>. Say you want to disable the hook <tt>/usr/lib/pm-utils/sleep.d/45pcmcia</tt>, you can do this easily by calling<br />
# touch /etc/pm/sleep.d/45pcmcia<br />
Do not set the executable bit on that dummy-hook.<br />
<br />
=== Creating your own hooks ===<br />
If you want to do something specific to your setup during suspend / hibernate, then you can easily put your own hook into <tt>/etc/pm/hooks</tt>. 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.<br />
<br />
I'm showing a pretty useless demonstration hook here, that will just put some informative lines into your logfile:<br />
<br />
#!/bin/bash<br />
case $1 in<br />
hibernate)<br />
echo "Hey guy, we are going to suspend to disk!"<br />
;;<br />
suspend)<br />
echo "Oh, this time we're doing a suspend to RAM. Cool!"<br />
;;<br />
thaw)<br />
echo "oh, suspend to disk is over, we are resuming..."<br />
;;<br />
resume)<br />
echo "hey, the suspend to RAM seems to be over..."<br />
;;<br />
*) echo "somebody is calling me totally wrong."<br />
;;<br />
esac<br />
<br />
Put this into /etc/pm/sleep.d/66dummy, do a <tt>chmod +x /etc/pm/sleep.d/66dummy</tt> and it will spew some useless lines during suspend / resume.<br />
<br />
'''''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.''<br />
<br />
== How it Works ==<br />
The concept is quite easy: the main script (<tt>pm-action</tt>, called via symlinks as either <tt>pm-suspend</tt>, <tt>pm-hibernate</tt> or <tt>pm-suspend-hybrid</tt>) executes so-called "hooks", executable scripts, in the alphabetical sorted order with the parameter <tt>suspend</tt> (suspend to RAM) or <tt>hibernate</tt> (suspend to disk).<br />
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 <tt>resume</tt> (resume from RAM) or <tt>thaw</tt> (resume from disk).<br />
The hooks do various stuff, for example preparing the bootloader, stopping the bluetooth subsystem or unloading of critical modules.<br />
<br />
Both pm-suspend and pm-hibernate are usually called from HAL, initiated by desktop applets as gnome-power-manager or kpowersave.<br />
<br />
{{Box Note|<tt>suspend-hybrid</tt> is a placeholder right now, it is not completely implemented.}}<br />
<br />
There is also the possibility to set the machine into high-power and low-power mode, the command <tt>pm-powersave</tt> is used with an additional parameter of <tt>true</tt> or <tt>false</tt>. It works basically the same as the suspend framework.<br />
<br />
The hooks for suspend are placed in<br />
* <tt>/usr/lib/pm-utils/sleep.d</tt> (distribution / package provided hooks)<br />
* <tt>/etc/pm/sleep.d</tt> (hooks added by the system administrator)<br />
<br />
The hooks for the power state are placed in <br />
* <tt>/usr/lib/pm-utils/power.d</tt> (distribution / package provided hooks)<br />
* <tt>/etc/pm/power.d</tt> (hooks added by the system administrator)<br />
<br />
Hooks in <tt>/etc/pm/</tt> take precedence over those in <tt>/usr/lib/pm-utils/</tt>, so the system administrator can override the defaults provided by the distribution.<br />
<br />
== Troubleshooting ==<br />
If suspend or hibernate did not work correctly, you will probably find some information in the logfile '''<tt>/var/log/pm-suspend.log</tt>''', for example which hooks were run and what the output of them was.<br />
<br />
=== Resume Hook ===<br />
<br />
It has been suggested that some systems require the <tt>resume</tt> hook be added to the initrd image, otherwise the kernel will '''not''' resume. To do so, edit <tt>/etc/mkinitcpio.conf</tt> as root and add <tt>resume</tt> to the HOOKS array:<br />
HOOKS="base udev autodetect ide scsi sata '''''resume''''' filesystems "<br />
<br />
Note that this is an example, and your HOOKS array may look different.<br />
<br />
<tt>resume</tt> must be placed ''after'' 'ide', 'scsi' and/or 'sata' but before 'filesystems'. Of course there has to be an appropriate 'resume' file in /lib/initcpio/hooks, it should already be there, as it is part of the package 'mkinitcpio'.<br />
<br />
Finally, you must rebuild the initrd image for these changes to take effect:<br />
<br />
# mkinitcpio -p kernel26<br />
<br />
{{Box Note|If you use a custom kernel then you might have to change the value of the '-p' option.}}<br />
<br />
== Tips and Tricks / FAQ ==<br />
=== Triggering suspend manually ===<br />
If you want to trigger suspend manually for debugging, without using HAL and other frameworks, call '''<tt>pm-suspend</tt>''' or '''<tt>pm-hibernate</tt>''' as root.<br />
=== Automatically deactivate kwin compositing before suspend===<br />
<br />
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?).<br />
To automatically deactivate kwin compositing add a new hook under /etc/pm/sleep.d/00togglecompositing with this content:<br />
<br />
#!/bin/bash<br />
USER=`finger|grep '*:0'|grep -o '^\w*'`<br />
DBUS_SESSION_BUS_ADDRESS=`grep -o 'DBUS_SESSION_BUS_ADDRESS=.*' /home/$USER/.dbus/session-bus/*|sed s/DBUS_SESSION_BUS_ADDRESS=//`<br />
case $1 in<br />
hibernate)<br />
;;<br />
suspend)<br />
if `sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin compositingActive`;<br />
then<br />
sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin toggleCompositing;<br />
sleep 1<br />
fi<br />
;;<br />
thaw)<br />
;;<br />
resume)<br />
sudo -u $USER -i DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS qdbus org.kde.kwin /KWin toggleCompositing;<br />
;;<br />
*) echo "somebody is calling me totally wrong."<br />
;;<br />
esac<br />
<br />
I don't know if it's very secure or if it can be done simpler. Feel free to add better versions.<br />
<br />
=== Using another sleep backend (like uswsusp) ===<br />
Create a file with a SLEEP_MODULE variable, like this:<br />
$ cat /etc/pm/config.d/module <br />
SLEEP_MODULE=uswsusp<br />
I don't know but you may have to <code>chmod +x</code> it. To list available modules, use:<br />
$ pacman -Ql pm-utils | grep module.d<br />
<br />
=== Having the hd power management level automatically set again on resume ===<br />
Do it like this:<br />
$ cat /etc/pm/sleep.d/50-hdparm_pm <br />
#!/bin/dash<br />
<br />
if [ -n "$1" ] && ([ "$1" = "resume" ] || [ "$1" = "thaw" ]); then<br />
hdparm -B 254 /dev/sda > /dev/null<br />
fi<br />
<br />
=== Restarting the mouse ===<br />
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 <tt>i8042</tt>) through a hook in <tt>/etc/pm/hooks</tt> (see [[#Creating_your_own_hooks|hooks]])<br />
<br />
#!/bin/sh <br />
echo -n "i8042" > /sys/bus/platform/drivers/i8042/unbind<br />
echo -n "i8042" > /sys/bus/platform/drivers/i8042/bind<br />
<br />
=== It seems to not do anything / where is the logfile ===<br />
If it seem to not do anything when called via the desktop applets, then try to call <tt>pm-suspend</tt> or <tt>pm-hibernate</tt> [[#Triggering_suspend_manually|manually from a root shell in a terminal]]. Maybe you'll already get some output that will point you to the problem.<br />
The suspend scripts also write a [[#Troubleshooting|logfile at '''<tt>/var/log/pm-suspend.log</tt>''']].<br />
<br />
=== Add sleep modes to Openbox menu ===<br />
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 <tt>~/.config/openbox/menu.xml</tt>, for example:<br />
<menu id="64" label="Shutdown"><br />
<item label="Lock"> <action name="Execute"> <execute>xscreensaver-command -lock</execute> </action> </item><br />
<item label="Logout"> <action name="Exit"/> </item><br />
<item label="Reboot"> <action name="Execute"> <execute>sudo shutdown -r now</execute> </action> </item><br />
<item label="Poweroff"> <action name="Execute"> <execute>sudo shutdown -h now </execute> </action> </item><br />
'''''<item label="Hibernate"> <action name="Execute"> <execute>sudo pm-hibernate</execute> </action> </item>'''''<br />
'''''<item label="Suspend"> <action name="Execute"> <execute>sudo pm-suspend</execute> </action> </item>'''''<br />
</menu><br />
<br />
=== Blank screen issue ===<br />
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 [http://wiki.archlinux.org/index.php/Pm-utils#Resume_Hook Resume Hook] for more details on building the new image.<br />
<br />
=== Handling "sleep" and "power" buttons ===<br />
"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.<br />
<br />
=== [[HAL]] will not recognize new devices on resume ===<br />
With the 2.6.30 kernel, HAL will on some systems bug on resume, not recognizing new USB devices. Adding the following bash script with a name like "02hal" to /etc/pm/sleep.d works around the problem by stopping HAL and starting it again after resuming.<br />
<br />
#!/bin/bash<br />
case $1 in<br />
hibernate)<br />
;;<br />
suspend)<br />
/etc/rc.d/hal stop<br />
;;<br />
thaw)<br />
;;<br />
resume)<br />
/etc/rc.d/hal start<br />
;;<br />
*)<br />
;;<br />
esac<br />
<br />
Remember to mark it executable with "chmod +x 02hal".<br />
<br />
== Other Resources ==<br />
* [https://wiki.ubuntu.com/UnderstandingSuspend Understanding Suspend] - Ubuntu article explaining how suspend-to-ram works<br />
*[http://people.freedesktop.org/~hughsient/quirk/ HAL Quirk Site] - Common solutions and frequently asked questions<br/><br />
*[[Cpufrequtils]] - CPU Frequency Scaling and CPU Power schemes<br/><br />
*[[SpeedStep]] - More information on CPU frequency scaling (some of which is obsolete)<br/><br />
*[[Acpid]] - daemon for delivering ACPI events.<br />
<br />
== Credits ==<br />
''This wiki entry was originally sourced from the [http://en.opensuse.org/Pm-utils OpenSUSE Wiki] (Licensed under GPL). A big thank you goes to the <tt>pm-utils</tt> developers and documenters for their time.''</div>A1russellhttps://wiki.archlinux.org/index.php?title=Hibernate-script&diff=91197Hibernate-script2010-01-07T03:05:16Z<p>A1russell: /* Editing /etc/suspend.conf */ Added shutdown method configuration.</p>
<hr />
<div>[[Category:Power management (English)]] [[Category:Laptops (English)]] [[Category:HOWTOs (English)]]<br />
{{Article summary start|Summary}}<br />
{{Article summary text|Succesfully suspending to disk with hibernate-script and improving its usage}}<br />
{{Article summary heading|Language}}<br />
{{i18n_entry|English|Suspending to Disk with hibernate-script}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Suspending to RAM with hibernate-script}}<br />
{{Article summary wiki|pm-utils}}<br />
{{Article summary wiki|Laptop}}<br />
{{Article summary end}}<br />
{{accuracy}}<br />
This article describes how to suspend a computer to disk. This means that all the running processes are saved to the hard drive and the power is completely shut down. The article discusses the two main methods to accomplish this task, that is userspace suspension (uswsusp) and tuxonice (formerly known as suspend2). See the [http://suspend.sourceforge.net/ ususpend website] and the [http://www.tuxonice.net/ tuxonice website] for complete documentation. There is a third method: using the kernelspace functionalities of the vanilla kernel. However, this method is the least developed, the slowest and the less reliable. On the contrary, tuxonice and ususpend are competing in features and stability. The only method to decide which method is better for you is to try both of them. From a general point of view, we can say that uswsusp does not force you to patch, configure and compile a kernel, while tuxonice does. However, tuxonice can be used without an initrd/initramfs, while using ususpend without an initrd/initramfs is discouraged; moreover, tuxonice allows you to suspend on a regular file if you have not a swap partition, while uswsusp give this possibility only if you run an experimental and unstable mm kernel.<br />
<br />
It is important to distinguish the core method of suspension to disk from the userspace application which you use to hibernate your machine to disk. A userspace application is required because the large majority of the laptops require some quirks in order to accomplish a proficient, successful hibernation cycle: unloading modules, restarting services, unmount windows partitions and usb keys, and so on.<br />
<br />
There are two widely used userspace applications for this purpose: [[pm-utils]] and hibernate-script. You can find both of them in the extra repo. However, since in this guide we need to describe two different, competing core methods, we will focus on the hibernate-script. The script, developed by the tuxonice development team, can be used nonetheless also to hibernate your machine with the ususpend method, and even to suspend the machine to ram (actually it is an excellent tool also for this task, but we are not going to discuss this aspect in this document, see [[Suspend to RAM]]).<br />
<br />
If you prefer to use pm-utils, refer to the specific [[pm-utils|wiki article]]. pm-utils is a serious competitor of the hibernate-script. Nonetheless, the hibernate-script is still much more configurable and documented, so this guide still assumes that you are using it (although it is very easy to translate each info for pm-utils).<br />
<br />
Thus:<br />
# pacman -S hibernate-script<br />
<br />
The discussion will be articulated in four parts. First of all, we will discuss the userspace method, secondly the tuxonice one, thirdly we will see how to use the power of the hibernate-script in order to circumvent some problems which could impair your ability to accomplish successful suspend/resume cycles. These last tips can be used with both methods. On the contrary, the first two parts will include instructions to use the hibernate-script in order to accomplish the basic operations with the two methods. In the fourth and last part, we will see how to combine suspension to disk and [[Suspend to RAM]]. <br />
<br />
When there is the need to modify the configuration of the bootloader, we will be always under the assumption that you use grub, but it should not be difficult to act analogously on the configuration of lilo.<br />
<br />
=Uswsusp method=<br />
The userspace method lets you resort to some advanced suspension abilities included in vanilla kernels > 2.6.17. You need two userspace tools, called s2disk and resume, which do what their names say. They are both included in the uswsusp package (which includes also s2ram, see [[Suspend to RAM]] ). You can find uswsusp in the community repo, install it with:<br />
<br />
# pacman -S uswsusp<br />
<br />
==Editing /etc/suspend.conf==<br />
On the contrary, you need to edit the s2disk configuration file, called /etc/suspend.conf. It is essential that you modify the resume device parameter:<br />
resume device = /dev/sda3<br />
<br />
It needs to point to your swap partition: in this case, the third partition of a primary pata-sata drive. It is also a good thing to enable compression, because this speeds up greatly your suspension/resume routine.<br />
<br />
Note that it is important that this configuration file be edited *before* recreating the initramfs (done below). Presently, the initramfs build process reads this configuration file, and embeds the current resume parameter. If not changed from the default '<path_to_resume_device_file>', this causes problems such as seeing, on bootup:<br />
# Could not stat the resume device file '<path_to_resume_device_file>'<br />
# Please type in the full path name to try again or press ENTER to boot the system.<br />
<br />
If you have experiencing this problem, simply edit the file as appropriate, and then rebuild the initramfs.<br />
<br />
Another line that you may want to add to the configuration file is:<br />
shutdown method = shutdown<br />
<br />
This explicitly configures the system to shutdown instead of reboot.<br />
<br />
==Recreate the intramfs==<br />
Now you need to recreate an initramfs with the new hook. So edit the /etc/mkinitcpio.conf file. In the HOOKS list add the '''uresume''' hook ('''it is different from the resume hook, which is on the contrary required by the tuxonice method'''). You should put it immediately before the filesystem hook. When the hook is executed the device file for the swap partition (which you have defined in /etc/suspend.conf) needs to exist (the standard udev hook will take care of this). Now proceed to regenerate your initramfs:<br />
# mkinitcpio -p kernel26<br />
<br />
You need to adjust this command according to the kernel you plan to use and the name of the initramfs in the grub configuration. Anyway you should not need to modify anything in the grub configuration.<br />
<br />
==Support for splash screens and suspension to file==<br />
The uswsusp package does not provide support for splash screens: uswsusp itself would support splashy and fbsplash, but you need a modified PKGBUILD in order to compile uswsusp with libsplashy or fbsplash support. For Fbsplash there is the [http://aur.archlinux.org/packages.php?ID=16233 uswsusp-fbsplash package] in the AUR. For splash see the HOWTO and README in the source tarball for details if you want to modify the PKGBUILD yourself.<br />
<br />
Please note that uswsusp can also suspend to a file, but only if you use an experimental mm-patched kernel. If you want to suspend to file, tuxonice is probably the way to go. In the case you like experimental things, see the instructions in the HOWTO of the uswsusp source tarball.<br />
<br />
==Setting the suspend method==<br />
If you use hibernate-sript, your preferred suspend/hibernation method can be set in the file /etc/hibernate/hibernate.conf. If you list several methods, the first one will be used. Note that ''hibernate'' can also be used with [[Suspend to RAM]] or vanilla swsusp).<br />
<br />
For Uswsusp use:<br />
TryMethod ususpend-disk.conf<br />
<br />
If you use pm-utils: http://wiki.archlinux.org/index.php/Pm-utils#Using_another_sleep_backend_.28like_uswsusp.29<br />
<br />
Or just try to do it like:<br />
# echo "SLEEP_MODULE=uswsusp">>/etc/pm/config.d/module<br />
<br />
==Suspending==<br />
Now you could try to suspend directly calling s2disk from the command line:<br />
# s2disk<br />
<br />
However, this is highly likely to fail, because some services could need to be stopped, some modules unloaded, etc. Thus it is probably necessary to resort to a userspace tool which calls internally s2disk, like [[Pm-utils]] since version 1.1 (which is now in core) or hibernate-script. See [[Suspend to Disk#Editing /etc/hibernate/hibernate.conf|below]] about details for defining the ususpend-disk method as default in /etc/hibernate/hibernate.conf. For the moment being, remember that you can define specific options in /etc/hibernate/ususpend-disk.conf and, after having configured also /etc/hibernate/common.conf, you can suspend to disk with the uswsusp method with the following command:<br />
# hibernate -F /etc/hibernate/ususpend-disk.conf<br />
<br />
==Support for encryption==<br />
The package in the AUR does already support encryption. You need to:<br />
* generate a key with the suspend-keygen utility included in the uswsusp package;<br />
* write the name of the key in /etc/suspend.conf;<br />
* uncomment or add the following line in /etc/suspend.conf<br />
encrypt = y<br />
RSA key file = <path_to_keyfile><br />
* build a new initramfs with the uresume hook just before the filesystem one.<br />
<br />
=Tuxonice method=<br />
There is a dedicated [[Tuxonice]] page which covers the basics of installing and configuring Tuxonice.<br />
<br />
=Hibernate tricks with the hibernate.script=<br />
This is a brief overview of the hibernate script. If you want to tweak it further, examine the ''common.conf'' and ''suspend2.conf'' files further and read the excellent and exhaustive man pages for hibernate and hibernate.conf.<br />
<br />
==Editing /etc/hibernate/common.conf==<br />
The options in this file are used with any hibernation method (actually, the file is sourced by the configuration files of each method) and also by [[Suspend to RAM]] when accomplished with the hibernate-script. This file is complex and well commented. The man page hibernate.conf describes adequately all the options. Here, we can only stress the most commonly useful parts.<br />
<br />
Uncomment the lines for any filesystems that have the potential to change while your computer is suspended (for example shared partitions with windows like vfat or ntfs ones). They will be remounted upon resume. Otherwise you would risk corrupting the filesystems.<br />
### filesystems<br />
# Unmount /nfsshare /windows /mnt/sambaserver<br />
# UnmountFSTypes smbfs nfs<br />
# UnmountGraceTime 1<br />
# Mount /windows<br />
<br />
If you don't explicitly restore the volume levels, ALSA may have the sound channels muted after resuming. If this happens, look for:<br />
### services<br />
in /etc/hibernate/common.conf and change the line just below to:<br />
RestartServices alsa<br />
<br />
The alsa service will be stopped before suspension and restarted after resuming: the sound channels and volumes will be as before.<br />
You may want to restart other problematic services here.<br />
<br />
A common issue is that some drivers do not support suspension, that is they do not work properly after a suspension cycle or even they prevent the system from suspending or resuming properly. <br />
In these cases (which should be reported - at least for modules in the vanilla kernel - to the suspend-devel@lists.sourceforge.net mailing list, so that they can be fixed upstream) you can unload the module before suspension and reload it after resuming: the hibernate-script can automatize this routine with the LoadModules and UnloadModules options. Actually, the hibernate-script already unload some problematic modules, listed in /etc/hibernate/blacklisted-modules, so you can also add the modules in that file.<br />
<br />
To re-connect to networks after rebooting, you may want to add<br />
OnSuspend 25 netcfg2 -a<br />
OnResume 20 netcfg-auto-wireless <your-network-interface><br />
This will disconnect from all networks, then should automatically choose the correct one. If you use another way to connect to a network (such as netcfg2 <profile-name> then of-course, put that there instead.<br />
<br />
One 'gotcha' to watch out for is the priority level you put on your user-commands, this won't work:-<br />
OnSuspend 5 netcfg -a<br />
You'll need to set the priority as 05 instead. Its normally best to use something within the range of 20-50 for your user scripts.<br />
<br />
If you need/want to eject all PcCards before suspending and reinsert them after resuming, change the ''EjectCards'' setting in ''common.conf'':<br />
### pcmcia<br />
EjectCards yes<br />
<br />
This is necessary on some laptops, if the pccards stop working after resume.<br />
<br />
Finally, the most problematic aspect is constituted by the video card: its status needs often to be restored after resuming. In other cases, it is necessary to switch from X to the console.<br />
The following options in /etc/hibernate/common.conf will probably fix these issues (whose symptom could be a frozen machine or only a black display after resuming):<br />
### vbetool<br />
#EnableVbetool yes<br />
#RestoreVbeStateFrom /var/lib/vbetool/vbestate<br />
#VbetoolPost yes<br />
# RestoreVCSAData yes<br />
<br />
### xhacks<br />
#SwitchToTextMode yes<br />
#UseDummyXServer yes<br />
#DummyXServerConfig xorg-dummy.conf<br />
<br />
You can uncomment one or many of them in order to see if the problem is solved. In order to use the first block of options, you need to install the vbetool package from the extra repository. Each of the option is documented in man hibernate.conf. <br />
Please note that it is very important to try all the different combinations of these options before than anything else, becaause the problems with the display are the most common source of troubles in a suspension cycle.<br />
<br />
== NVIDIA specific settings ==<br />
If you have an [[NVIDIA]] graphics card and use a driver version >177, you need to add the following line to /etc/hibernate/common.conf <br />
ProcSetting extra_pages_allowance 7500<br />
<br />
A value lower than 7500 might also work on certain systems, though 7500 should be a working default. Setting this option should allow you to hibernate and resume without any additional X hacks. You will also need to comment out the nvidia module in /etc/hibernate/blacklisted-modules for this to work.<br />
<br />
The suggested value for extra_pages_allowance for driver versions <177 is 0:<br />
ProcSetting extra_pages_allowance 0<br />
<br />
This setting has also been reported to help with the binary ATI driver.<br />
<br />
If you have an AGP Nvidia card and are using the binary driver, you might also have to add the following line to your /etc/X11/xorg.conf:<br />
Option "NvAGP" "1"<br />
<br />
== Suspending with fglrx ==<br />
Following addition to /etc/hibernate/suspend2.conf is required:<br />
# For fglrx<br />
ProcSetting extra_pages_allowance 20000<br />
<br />
== Dropping disk caches ==<br />
:<small>''From: [http://www.linuxinsight.com/proc_sys_vm_drop_caches.html drop_caches introduction]''</small><br />
<br />
As a way to speed up suspending, you can free the memory used for disk caches so there will be less to write to the disk. The downside is the risk of crashing your system. but I have had no trouble with it so far, while reducing the size of the suspended image by half. Just add something like this to the common.conf:<br />
OnSuspend 00 sync; echo 3 > /proc/sys/vm/drop_caches<br />
<br />
=Combining suspend to disk with suspend to RAM=<br />
If your motherboard or laptop supports [[Suspend to RAM]], you can combine it with suspend2. This will result in the following behavior:<br />
<br />
* When you call hibernate, your system will suspend to disk and after that suspend to RAM instead of powering down.<br />
* When you turn your system back on, it will resume directly from RAM (which only takes a few seconds)<br />
* If your battery fails in the meantime (and the image in your memory is therefore lost), you will be able to resumes from disk.<br />
<br />
This can be done both with uswsusp and with tuxonice. <br />
<br />
With uswsusp, you should use s2both. You can also call s2both from the hibernate script (with all its richness of options), resorting to the ususpend-both.conf method. Please note that s2both works only if s2ram (see [[Suspend to RAM]]) works in your system. There is no way to force it to work if your laptop model is not whitelisted in s2ram. See [[Suspend to RAM]] for instructions about how to whitelist your laptop in the local copy of s2ram and how to report that your laptop suspend to ram properly so that it is whitelisted in the next uswsusp release.<br />
<br />
To do it with tuxonice, edit ''/etc/hibernate/suspend2.conf'':<br />
## Powerdown method - 3 for suspend-to-RAM, 4 for ACPI S4 sleep, 5 for poweroff<br />
PowerdownMethod 3<br />
<br />
For this to work, your computer must be able to use suspend to RAM also without s2ram.<br />
<br />
=Take action based on events=<br />
''Tuning hibernate-script for context sensitive modal operation''<br />
<br />
==After pressing power button==<br />
Edit the following file <code>/etc/acpi/events/power</code><br />
# This is called when the user presses the power button<br />
event=button/power (PWR.||PBTN)<br />
# To Hibernate uncomment the following line<br />
#action=hibernate <br />
# To Suspend uncomment the following line<br />
#action=suspend<br />
<br />
==After closing lid==<br />
Edit the following file <code>/etc/acpi/events/lid</code><br />
# This is called when the user closes the lid<br />
event=button/lid<br />
# To Hibernate uncomment the following line<br />
#action=hibernate <br />
# To Suspend uncomment the following line<br />
#action=suspend<br />
<br />
Alternatively you can edit <code>/etc/acpi/actions/lm_lid.sh</code> this is the file that is executed when the lid state is changed<br />
<br />
Example:<br />
#!/bin/bash<br />
# lid button pressed/released event handler<br />
#laptop mode helps minimized hdd activity<br />
test -x /usr/sbin/laptop_mode && /usr/sbin/laptop_mode auto<br />
# get the -xauth variable so we can access the display<br />
XAUTH="$( ps -C X f | sed -n 's/.*-auth \(.*\)/\1/p' )"<br />
if [[ -z $XAUTH ]]; then<br />
# if XAUTH is blank try another way to get it <br />
XAUTH="$( ps -C xinit f | sed -n 's/.*-auth \(.*\)serverauth.*/\1Xauthority/p' )"<br />
fi<br />
#Find out if the lid is open or closed<br />
if grep -q open /proc/acpi/button/lid/LID/state; then<br />
# the screen is on, forces it to be on<br />
ACTION="on"<br />
XAUTHORITY=$XAUTH /usr/bin/xset -display :0.0 dpms force $ACTION<br />
else<br />
# screen is off, forces off<br />
ACTION="off"<br />
XAUTHORITY=$XAUTH /usr/bin/xset -display :0.0 dpms force $ACTION<br />
# script waits for 10 minutes<br />
sleep 10m<br />
# checks to make sure screen is still closed<br />
if grep -q closed /proc/acpi/button/lid/LID/state; then<br />
# if it is, then it suspends to disk<br />
s2disk<br />
else<br />
# or it turns it back on<br />
XAUTHORITY=$XAUTH /usr/bin/xset -display :0.0 dpms force on<br />
fi<br />
fi<br />
<br />
This script is derived from [http://gentoo-wiki.com/HOWTO_Automatically_turn_off_your_monitor The Gentoo Wiki]. The script turns the monitor off or on. But if the screen is left shut for 10 minutes, it will suspend to the disk automatically. <code> man sleep</code> for more info on the sleep command.<br />
<br />
==Interacting with HAL==<br />
With new versions of HAL and policykit (>= 0.5.11-7, 0.9-7), the following is enough to make sure hal-triggered hibernates (e.g. from gnome-power-manager or xfce-power-manager) use hibernate-script. Make sure policykit is installed, add your username to the "power" group, then edit the following lines in <code>/usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux</code> in the place where pm-hibernate is called, so it looks like this:<br />
<br />
# We only support pm-utils...not anymore!<br />
if [ -x "/usr/sbin/hibernate" ] ; then<br />
# Suspend2 tools installed<br />
/usr/sbin/hibernate --force<br />
RET=$?<br />
elif [ -x /usr/sbin/pm-hibernate ] ; then<br />
/usr/sbin/pm-hibernate $QUIRKS<br />
RET=$?<br />
else<br />
unsupported<br />
fi<br />
Now restart HAL <code>/etc/rc.d/hal restart</code> and give it a shot.<br />
<br />
The previous method, which may be outdated, is to create script /usr/lib/hal/scripts/hal-system-power-hibernate-own :<br />
#!/bin/sh<br />
## /usr/lib/hal/scripts/hal-system-power-hibernate-own<br />
. hal-functions<br />
hal_check_priv org.freedesktop.hal.power-management.hibernate<br />
## suspend command<br />
# replace this with command you want to use<br />
# hibernate<br />
s2disk<br />
<br />
Give right permissions with command <code>chmod 655 /usr/lib/hal/scripts/hal-system-power-hibernate-own</code><br />
<br />
Next you have to replace old command with new. Create file /etc/hal/fdi/policy/09-power-mgmt-policy.fdi<br />
<?xml version="1.0" encoding="UTF-8"?><br />
<deviceinfo version="0.2"><br />
<device><br />
<match key="info.udi" string="/org/freedesktop/Hal/devices/computer"><br />
<merge key="org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths" type="strlist">hal-system-power-suspend</merge><br />
<append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths" type="strlist">hal-system-power-suspend-hybrid</append><br />
<append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths" type="strlist">hal-system-power-hibernate-own</append><br />
<append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths" type="strlist">hal-system-power-shutdown</append><br />
<append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths" type="strlist">hal-system-power-reboot</append><br />
<append key="org.freedesktop.Hal.Device.SystemPowerManagement.method_execpaths" type="strlist">hal-system-power-set-power-save</append><br />
</match><br />
</device><br />
</deviceinfo><br />
<br />
Finally restart HAL <code>/etc/rc.d/hal restart</code></div>A1russellhttps://wiki.archlinux.org/index.php?title=TIMEZONE&diff=83119TIMEZONE2009-11-11T19:17:00Z<p>A1russell: /* UTC vs. localtime */ Setting HARDWARECLOCK to anything other than UTC or localtime can trigger a mount bug at boot time.</p>
<hr />
<div>[[Category: About Arch (English)]]<br />
[[Category:Internationalization (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|TIMEZONE}}<br />
{{i18n_entry|Nederlands|Tijdzone}}<br />
{{i18n_entry|Українська|Часовий пояс}}<br />
{{i18n_entry|Русский|Часовой пояс}}<br />
{{i18n_entry|简体中文|TIMEZONE (简体中文)}}<br />
{{i18n_entry|Español|TIMEZONE (Español)}}<br />
{{i18n_links_end}}<br />
== What is it ==<br />
<br />
The <code>TIMEZONE</code> variable is specified in the <code>/etc/rc.conf</code> file. It defines what timezone is the computer clock showing.<br />
<br />
== What can it be ==<br />
The complete list of possibilities can be shown using this command:<br />
pacman -Ql tzdata | grep zoneinfo | grep -v posix | grep -v right | grep -v .tab | grep -v /$ | sed "s@tzdata /usr/share/zoneinfo/@ @"<br />
<br />
== UTC vs. localtime ==<br />
The hardware clock can be set to UTC or to local time.<br />
Usually hardware clock on Linux machines is set to UTC time. If you use Linux with Windows on the same machine, then your clock is usually set to local time.<br />
<br />
Setting hardware clock mode is done via <code>HARDWARECLOCK</code> variable:<br />
HARDWARECLOCK="UTC"<br />
or<br />
HARDWARECLOCK="localtime"<br />
<br />
<br />
'''NOTE:''' Linux will change to and from DST when the <code>HARDWARECLOCK</code> setting is set to <code>UTC</code>, regardless of whether Linux was running at the time DST is entered or left.<br />
<br />
'''IMPORTANT:''' When the <code>HARDWARECLOCK</code> setting is set to <code>localtime</code>, Linux will '''not''' adjust the time, operating under the assumption that your system may be a dual boot system at that time and that the other OS takes care of the DST switch. If that was not the case, the DST change needs to be made manually.<br />
<br />
== Modifying Timezone ==<br />
If your timezone changes then you will have to manually reflect this change in Arch.<br />
# Run <code>tzselect</code> to find your desired timezone.<br />
# Modify <code>TIMEZONE</code> in <code>[[rc.conf]]</code> with your chosen timezone (eg. <code>Asia/Tokyo</code>).<br />
# Either reboot, or as root run <code>cp /usr/share/zoneinfo/&lt;tzselect output&gt; /etc/localtime</code>. The change should be reflected immediately.</div>A1russell