https://wiki.archlinux.org/api.php?action=feedcontributions&user=5haffl&feedformat=atomArchWiki - User contributions [en]2024-03-29T06:40:08ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Power_management/Suspend_and_hibernate&diff=328325Power management/Suspend and hibernate2014-08-03T14:43:56Z<p>5haffl: /* Display not powering up on resume (radeon) */</p>
<hr />
<div>[[Category:Power management]]<br />
[[ja:Suspend and Hibernate]]<br />
{{Related articles start}}<br />
{{Related|Uswsusp}}<br />
{{Related|TuxOnIce}}<br />
{{Related|systemd}}<br />
{{Related|pm-utils}}<br />
{{Related|Suspending to RAM with hibernate-script}}<br />
{{Related|Suspending to Disk with hibernate-script}}<br />
{{Related|Power management}}<br />
{{Related articles end}}<br />
Currently there are three methods of suspending available: '''suspend to RAM''' (usually called just '''suspend'''), '''suspend to disk''' (usually known as '''hibernate'''), and '''hybrid suspend''' (sometimes aptly called '''suspend to both'''):<br />
<br />
* '''Suspend to RAM''' method cuts power to most parts of the machine aside from the RAM, which is required to restore the machine's state. Because of the large power savings, it is advisable for laptops to automatically enter this mode when the computer is running on batteries and the lid is closed (or the user is inactive for some time).<br />
<br />
* '''Suspend to disk''' method saves the machine's state into [[Swap|swap space]] and completely powers off the machine. When the machine is powered on, the state is restored. Until then, there is zero power consumption.<br />
<br />
* '''Suspend to both''' method saves the machine's state into swap space, but does not power off the machine. Instead, it invokes usual suspend to RAM. Therefore, if the battery is not depleted, the system can resume from RAM. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine's state has not been lost.<br />
<br />
There are multiple low level interfaces (backends) providing basic functionality, and some high level interfaces providing tweaks to handle problematic hardware drivers/kernel modules (e.g. video card re-initialization).<br />
<br />
== Low level interfaces ==<br />
<br />
Though these interfaces can be used directly, it is advisable to use some of [[#High level interfaces|high level interfaces]] to suspend/hibernate. Using low level interfaces directly is significantly faster than using any high level interface, since running all the pre- and post-suspend hooks takes time, but hooks can properly set hardware clock, restore wireless etc.<br />
<br />
=== kernel (swsusp) ===<br />
<br />
The most straightforward approach is to directly inform the in-kernel software suspend code (swsusp) to enter a suspended state; the exact method and state depends on the level of hardware support. On modern kernels, writing appropriate strings to {{ic|/sys/power/state}} is the primary mechanism to trigger this suspend.<br />
<br />
See [https://www.kernel.org/doc/Documentation/power/states.txt kernel documentation] for details.<br />
<br />
=== uswsusp ===<br />
<br />
The uswsusp ('Userspace Software Suspend') is a wrapper around the kernel's suspend-to-RAM mechanism, which performs some graphics adapter manipulations from userspace before suspending and after resuming.<br />
<br />
See main article [[Uswsusp]].<br />
<br />
=== tuxonice ===<br />
<br />
TuxOnIce is a fork of the kernel implementation of suspend/hibernate that provides kernel patches to improve the default implementation. It requires a custom kernel to achieve this purpose.<br />
<br />
See main article [[TuxOnIce]].<br />
<br />
== High level interfaces ==<br />
<br />
{{Note|The end goal of these packages is to provide binaries/scripts that can be invoked to perform suspend/hibernate. Actually hooking them up to power buttons or menu clicks or laptop lid events is usually left to other tools. To automatically suspend/hibernate on certain power events, such as laptop lid close or battery depletion percentage, you may want to look into running [[Acpid]].}}<br />
<br />
=== systemd ===<br />
<br />
[[systemd]] provides native commands for suspend, hibernate and a hybrid suspend, see [[Power management#Power management with systemd]] for details.<br />
<br />
See [[Power management#Sleep hooks]] for additional information on configuring suspend/hibernate hooks. Also see {{ic|man systemctl}}, {{ic|man systemd-sleep}}, and {{ic|man systemd.special}}.<br />
<br />
=== pm-utils ===<br />
<br />
pm-utils is a set of shell scripts that encapsulate the backend's suspend/hibernate functionality. It comes with a set of pre- and post-suspend tweaks and various hooks to customize the process.<br />
<br />
See main article [[pm-utils]].<br />
<br />
== Suspend to RAM ==<br />
<br />
Suspend to RAM should work out of the box.<br />
<br />
== Hibernation ==<br />
<br />
In order to use hibernation, you need to create swap partition or swap file. See [[Swap]] for details.<br />
<br />
=== About swap partition/file size ===<br />
<br />
Even if your swap partition is smaller than RAM, you still have a big chance of hibernating successfully. According to [https://www.kernel.org/doc/Documentation/power/interface.txt kernel documentation]:<br />
<br />
: ''{{ic|/sys/power/image_size}} controls the size of the image created by the suspend-to-disk mechanism. It can be written a string representing a non-negative integer that will be used as an upper limit of the image size, in bytes. The suspend-to-disk mechanism will do its best to ensure the image size will not exceed that number. However, if this turns out to be impossible, it will try to suspend anyway using the smallest image possible. In particular, if "0" is written to this file, the suspend image will be as small as possible. Reading from this file will display the current image size limit, which is set to 2/5 of available RAM by default.''<br />
<br />
You may either decrease the value of {{ic|/sys/power/image_size}} to make the suspend image as small as possible (for small swap partitions), or increase it to possibly speed up the hibernation process.<br />
<br />
=== Required kernel parameters ===<br />
<br />
The kernel parameter {{ic|1=resume=''swap_partition''}} has to be used. The configuration depends on the used [[boot loader]], some examples are given below. According to the boot loader configuration, use either kernel name (for example {{ic|/dev/sda1}}), or [[UUID]] path.<br />
<br />
==== Example for GRUB ====<br />
<br />
The kernel name, e.g. {{ic|/dev/sda1}}, can only be used if [[GRUB#Persistent_block_device_naming|Persistent block device naming]] is opted out in GRUB2.<br />
<br />
For example, with [[GRUB]] you can use {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} variable:<br />
<br />
{{hc|/etc/default/grub|2=<br />
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/disk/by-uuid/4209c845-f495-4c43-8a03-5363dd433153"<br />
}}<br />
<br />
Don't forget to run {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} afterwards.<br />
<br />
{{Tip|As an alternative, for GRUB2 you may try this solution from [http://wiki.debian.org/Grub#Configuring_grub_v2 debian wiki], which automatically adds your first swap partition to {{ic|1=resume=}} parameter to all found linux entries.}}<br />
<br />
==== Example for gummiboot ====<br />
<br />
If [[gummiboot]] is used as boot manager, you have to add the {{ic|1=resume=''swap_partition''}} parameter in the options-list of the entry file. <br />
<br />
For example if your efi system partition is mounted in {{ic|/boot}}, then the option list should look like this:<br />
<br />
{{hc|/boot/loader/entries/arch.conf|2=<br />
options root=/dev/sda''X'' rw resume=''swap_partition'' <br />
}}<br />
<br />
==== Hibernation into swap file ====<br />
<br />
Using a swap file instead of a swap partition requires an additional kernel parameter {{ic|1=resume_offset=''swap_file_offset''}}.<br />
<br />
The value of {{ic|''swap_file_offset''}} can be obtained by running {{ic|filefrag -v ''swap_file''}}, the output is in a table format and the required value is located in the first row of the {{ic|physical_offset}} column. For example:<br />
<br />
{{hc|# filefrag -v /swapfile|<nowiki><br />
Filesystem type is: ef53<br />
File size of /swapfile is 4294967296 (1048576 blocks of 4096 bytes)<br />
ext: logical_offset: physical_offset: length: expected: flags:<br />
0: 0.. 0: 38912.. 38912: 1: <br />
1: 1.. 22527: 38913.. 61439: 22527: unwritten<br />
2: 22528.. 53247: 899072.. 929791: 30720: 61440: unwritten<br />
...<br />
</nowiki>}}<br />
<br />
In the example the value of {{ic|''swap_file_offset''}} is {{ic|38912}}.<br />
<br />
{{Tip|The value of {{ic|''swap_file_offset''}} can also be obtained by running {{ic|swap-offset ''swap_file''}}. The ''swap-offset'' binary is provided by package {{AUR|uswsusp-git}}.}}<br />
<br />
{{Note|<br />
* Please note that in the kernel parameter {{ic|resume}} you have to provide the device of the partition that contains the swap file, not swap file itself! The parameter {{ic|resume_offset}} informs the system where the swap file starts on the resume device.<br />
* If using [[uswsusp]], then these two parameters have to be provided in {{ic|/etc/suspend.conf}} via the keys {{ic|resume device}} and {{ic|resume offset}}.<br />
}}<br />
<br />
=== Recreate initial ramdisk ===<br />
<br />
If you use an initramfs (default Arch systems do), you must add the {{ic|resume}} hook into the HOOKS in the configuration of [[mkinitcpio]]:<br />
<br />
{{hc|/etc/mkinitcpio.conf|2=<br />
# resume must be placed after block and lvm2, but before filesystems<br />
HOOKS="... block lvm2 '''resume''' filesystems ..."<br />
}}<br />
<br />
{{Warning|You must not use the [[Mkinitcpio#Common_hooks|systemd hook]], because it does not support resuming from hibernation. See {{Bug|37028}} for details.}}<br />
<br />
Finally, you must rebuild the initrd image for these changes to take effect:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|If you use a custom kernel, then you might have to change the value of the {{ic|-p}} option.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== ACPI_OS_NAME ===<br />
<br />
You might want to tweak your '''DSDT table''' to make it work. See [[DSDT]] article<br />
<br />
=== VAIO Users ===<br />
<br />
Add acpi_sleep=nonvs kernel flag to your loader, and you are done!<br />
<br />
=== Suspend/hibernate doesn't work ===<br />
<br />
There have been many reports about the screen going black without easily viewable errors or the ability to do anything when going into and coming back from suspend and/or hibernate. These problems have been seen on both laptops and desktops. This is not an official solution, but switching to an older kernel, especially the LTS-kernel, will probably fix this.</div>5hafflhttps://wiki.archlinux.org/index.php?title=Pm-utils&diff=328323Pm-utils2014-08-03T14:43:32Z<p>5haffl: /* Display not powering up on resume (radeon) */</p>
<hr />
<div>{{DISPLAYTITLE:pm-utils}}<br />
[[Category:Power management]]<br />
[[it:Pm-utils]]<br />
[[ru:Pm-utils]]<br />
[[zh-CN:Pm-utils]]<br />
{{Related articles start}}<br />
{{Related|Uswsusp}}<br />
{{Related|TuxOnIce}}<br />
{{Related articles end}}<br />
{{Out of date| Need to address pm-utils relevance compared to systemd's suspend functions}}<br />
{{Warning|1=Hibernating with Pm-utils and then updating systemd is reported to corrupt files:<br />
https://bbs.archlinux.org/viewtopic.php?pid=1423442}}<br />
'''pm-utils''' is a suspend and powerstate setting framework. It is designed to replace such scripts as those provided by the {{ic|powersave}} package.<br />
<br />
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.<br />
<br />
A lesser known feature is one that mimics toggling done by [[Laptop Mode Tools]].<br />
<br />
Used in conjunction with the [[cpupower]] package, notebook (and desktop) owners are provided with a complete power management suite.<br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] the {{Pkg|pm-utils}} package which is available in the [[official repositories]].<br />
<br />
{{Note|<br />
* If you run into issues when resuming video, it might be necessary to also install {{Pkg|vbetool}} from the [[official repositories]].<br />
* If you are starting from a clean install, make sure that you have {{Pkg|acpi}} installed.<br />
}}<br />
<br />
Run {{ic|pm-suspend}}, {{ic|pm-suspend-hybrid}} or {{ic|pm-hibernate}} as root to trigger suspend manually. The suspend scripts write log to {{ic|/var/log/pm-suspend.log}}.<br />
<br />
=== Installing alternative suspend backend (optional) ===<br />
<br />
The Arch Linux package ships with support for the following backends: {{ic|kernel}}, {{ic|tuxonice}} and {{ic|uswsusp}} which can be seen from command:<br />
pacman -Ql pm-utils | grep module.d<br />
<br />
Suspend backend is specified by the {{ic|SLEEP_MODULE}} configuration variable in {{ic|/etc/pm/config.d}} and defaults to the {{ic|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]]:<br />
* uswsusp - {{AUR|uswsusp-git}}<br />
* tuxonice - {{AUR|linux-ice}} / [[linux-pf]]<br />
<br />
Furthermore, {{Pkg|pm-utils}} ships with its own video quirks database in {{ic|/usr/lib/pm-utils/video-quirks/}}.<br />
<br />
== Basic configuration ==<br />
<br />
=== Standby/suspend to RAM ===<br />
<br />
In the ideal case, running {{ic|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.<br />
<br />
{{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.}} <br />
<br />
In some cases, it is possible that running {{ic|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 {{ic|SUSPEND_MODULES}} config to {{ic|/etc/pm/config.d/modules}} of the form:<br />
SUSPEND_MODULES="uhci_hd button ehci_hd iwlwifi"<br />
should cause these modules to be specifically unloaded before suspend and reloaded after resume.<br />
<br />
To configure invoking {{ic|pm-suspend}} automatically on power events like laptop lid close, please refer to [[Acpid]].<br />
<br />
=== Hibernation (suspend2disk) ===<br />
<br />
You need to follow instructions in [[Suspend and Hibernate#Hibernation]] in order to set up hibernation.<br />
<br />
Alternatively, if you do not use the {{ic|kernel}} backend, see [[Uswsusp#Configuration]] or [[TuxOnIce#Setting up the bootloader]].<br />
<br />
=== Suspend/hibernate as regular user ===<br />
<br />
Three methods are available to suspend without the need for a root password: using [[Udev]], using UPower, and giving the user the appropriate permissions with [[sudo|visudo]].<br />
<br />
==== User permission method ====<br />
<br />
Because the {{Pkg|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 {{ic|/etc/sudoers}} file with {{ic|visudo}} as root. For more information, see [[sudo]].<br />
<br />
Add the following lines, replacing {{ic|''username''}} with your own user name, then save and exit {{ic|visudo}}:<br />
''username'' ALL = NOPASSWD: /usr/sbin/pm-hibernate<br />
''username'' ALL = NOPASSWD: /usr/sbin/pm-suspend<br />
<br />
Or you can enable it for a group, using the following lines, replacing {{ic|''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., {{ic|1=username ALL=(ALL) ALL}}, or they will not work.}}<br />
<br />
You can now run the scripts without a password by simply running:<br />
$ sudo pm-hibernate<br />
<br />
or:<br />
<br />
$ sudo pm-suspend<br />
<br />
Also, add yourself to the {{ic|power}} [[Users and groups|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 [[GNOME]]'s shutdown applet, your computer will just play a very annoying loud triple beep and lock the screen.<br />
# gpasswd -a ''username'' power<br />
<br />
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.<br />
<br />
=== Power saving ===<br />
<br />
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 {{ic|/etc/pm/power.d/}}. An example of such a script can be found in the [http://crunchbanglinux.org/forums/post/110148/#p110148 crunchbang forum]. Be aware that upower must be running in order to detect changing AC states [https://bbs.archlinux.org/viewtopic.php?id=132125 (see more information)].<br />
<br />
==== Change brightness depending on AC state ====<br />
<br />
One possible example looks as follows and changes brightness according to the AC state. Create a file called {{ic|/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.<br />
<br />
{{bc|<br />
#!/bin/bash<br />
<br />
case $1 in<br />
true)<br />
echo "Enable screen power saving"<br />
echo 5 > /sys/class/backlight/acpi_video0/device/backlight/acpi_video0/brightness<br />
;;<br />
false)<br />
echo "Disable screen power saving"<br />
echo 14 > /sys/class/backlight/acpi_video0/device/backlight/acpi_video0/brightness<br />
;;<br />
esac<br />
}}<br />
<br />
=== Suspend on idle/inactivity ===<br />
<br />
One method relies on xautolock program. Add following: {{ic|xautolock -time 30 -locker "sudo pm-suspend" -detectsleep &}} to {{ic|~/.xinitrc}}. This implies that {{ic|pm-suspend}} is called after 30 minutes of inactivity.<br />
<br />
=== Using Swap file instead of regular swap partition ===<br />
<br />
If you want use swap file instead of regular swap partition, see [[Swap#Swap file|Swap File]].<br />
<br />
== Advanced configuration ==<br />
<br />
The main configuration file is {{ic|/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 {{ic|/etc/pm/config.d/}} instead.<br />
You can just put a simple text file with<br />
SUSPEND_MODULES="button uhci_hcd"<br />
named {{ic|modules}} or {{ic|config}} into {{ic|/etc/pm/config.d}} and it will override the settings in the system-wide configuration file.<br />
<br />
=== Available variables for use in config files ===<br />
<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 shut down rather than reboot<br />
<br />
=== Disabling a hook ===<br />
<br />
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.<br />
You can however easily disable hooks by just creating an empty file corresponding to the hook in {{ic|/etc/pm/sleep.d/}}. Say you want to disable the hook {{ic|/usr/lib/pm-utils/sleep.d/45pcmcia}}, 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 />
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.<br />
<br />
==== Alternative method ====<br />
<br />
Create a file in {{ic|/etc/pm/config.d}} with the modules you want to blacklist in the {{ic|HOOK_BLACKLIST}} variable.<br />
For example, to manage power saving yourself, use:<br />
HOOK_BLACKLIST="hal-cd-polling intel-audio-powersave journal-commit laptop-mode pcie_aspm readahead sata_alpm sched-powersave xfs_buffer wireless"<br />
<br />
=== Creating your own hooks ===<br />
<br />
{{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 [[Systemd#Sleep_hooks|sleep hooks]] of systemd.}}<br />
If you want to do something specific to your setup during suspend or hibernate, then you can easily put your own hook into {{ic|/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:.<br />
;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.<br />
;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.<br />
;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.<br />
;90 - 99: Reserved for critical suspend hooks.<br />
<br />
I am showing a pretty useless demonstration hook here, that will just put some informative lines into your log file:<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 are 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 {{ic|/etc/pm/sleep.d/66dummy}}, do a {{ic|chmod +x /etc/pm/sleep.d/66dummy}} and it will spew some useless lines during suspend and resume.<br />
<br />
{{Warning|All the hooks run as root. This means that you need to be careful when creating temporary files, check that the {{ic|PATH}} environment variable is set correctly, etc. to avoid security problems.}}<br />
<br />
== How it works ==<br />
<br />
The concept is quite easy: the main script ({{ic|pm-action}}, called via symlinks as either {{ic|pm-suspend}}, {{ic|pm-hibernate}} or {{ic|pm-suspend-hybrid}}) executes so-called "hooks", executable scripts, in the alphabetical sorted order with the parameter {{ic|suspend}} (suspend to RAM) or {{ic|hibernate}} (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 {{ic|resume}} (resume from RAM) or {{ic|thaw}} (resume from disk).<br />
The hooks perform various tasks, such as preparing the bootloader, stopping the Bluetooth subsystem, or unloading of critical modules.<br />
<br />
Both {{ic|pm-suspend}} and {{ic|pm-hibernate}} are usually called from [[Udev]], initiated by desktop applets like {{Pkg|gnome-power-manager}} or {{ic|kpowersave}}.<br />
<br />
{{Note|{{ic|suspend-hybrid}} 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 {{ic|pm-powersave}} is used with an additional parameter of {{ic|true}} or {{ic|false}}. It works basically the same as the suspend framework.<br />
<br />
The hooks for suspend are placed in<br />
;{{ic|/usr/lib/pm-utils/sleep.d}}: distribution / package provided hooks<br />
;{{ic|/etc/pm/sleep.d}}: hooks added by the system administrator<br />
<br />
The hooks for the power state are placed in <br />
;{{ic|/usr/lib/pm-utils/power.d}}: distribution / package provided hooks<br />
;{{ic|/etc/pm/power.d}}: hooks added by the system administrator<br />
<br />
Hooks in {{ic|/etc/pm/}} take precedence over those in {{ic|/usr/lib/pm-utils/}}, so the system administrator can override the defaults provided by the distribution.<br />
<br />
=== Pm-suspend internals ===<br />
<br />
This outlines the internal actions when {{ic|pm-suspend}} is run, describing how {{ic|pm-utils}} gracefully falls back onto the kernel method if the requirements of other methods are not met.<br />
<br />
$ pm-suspend<br />
<br />
The first step is set-up preliminary variables and source parent scripts:<br />
export STASHNAME=pm-suspend<br />
export METHOD="$(echo ${0##*pm-} |tr - _)"<br />
. "/usr/lib/pm-utils/pm-functions"<br />
<br />
The variable {{Ic|METHOD}} is extracted from the executable name, ''suspend'' from {{ic|pm-suspend}} and ''hibernate'' from {{ic|pm-hibernate}}.<br />
<br />
The location of runtime configuration parameters is defined in {{ic|/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 {{ic|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:<br />
{{hc|$ ls -lah /var/run/pm-utils/pm-suspend/storage/|<br />
-rw-r--r-- 1 root root 20 May 19 09:57 disable_hook:99video<br />
-rw-r--r-- 1 root root 0 May 19 02:59 parameters<br />
-rw-r--r-- 1 root root 247 May 19 02:59 parameters.rm<br />
-rw-r--r-- 1 root root 9 May 19 02:59 state:cpu0_governor<br />
-rw-r--r-- 1 root root 9 May 19 02:59 state:cpu1_governor<br />
}}<br />
<br />
Then {{Ic|pm-functions}} will source the files located in {{Ic|/etc/pm/config.d/}} in addition to {{ic|/usr/lib/pm-utils/defaults}}. Upon returning, {{Ic|pm-functions}} will proceed to source the files specified by '''$SLEEP_METHOD''' as {{Ic|/usr/lib/pm-utils/module.d/$SLEEP_METHOD[...]}} if they exist:<br />
for mod in $SLEEP_MODULE; do<br />
mod="${PM_UTILS_LIBDIR}/module.d/${mod}"<br />
[ -f "$mod" ] || continue<br />
. "$mod"<br />
done<br />
<br />
Otherwise, if '''$SLEEP_MODULE''' is empty, {{ic|do_suspend()}} will be set to the kernel backend as described above:<br />
if [ -z "$SUSPEND_MODULE" ]; then<br />
if grep -q mem /sys/power/state; then<br />
SUSPEND_MODULE="kernel"<br />
do_suspend() { echo -n "mem" >/sys/power/state; }<br />
elif [ -c /dev/pmu ] && pm-pmu --check; then<br />
SUSPEND_MODULE="kernel"<br />
do_suspend() { pm-pmu --suspend; }<br />
elif grep -q standby /sys/power/state; then<br />
SUSPEND_MODULE="kernel"<br />
do_suspend() { echo -n "standby" >/sys/power/state; }<br />
fi<br />
fi<br />
<br />
Assuming '''$SLEEP_MODULE''' is not empty and {{Ic|uswsusp}} is specified, {{Ic|/usr/lib/pm-utils/module.d/uswsusp}} is executed. This script checks several requirements (these are the requirements for being able to use uswsusp):<br />
* [ -z $SUSPEND_MODULE ]<br />
* command_exists s2ram<br />
* grep -q mem /sys/power/state || ( [ -c /dev/pmu ] && pm-pmu --check; );<br />
If these requirements are met, do_suspend() is defined as:<br />
do_suspend()<br />
{<br />
uswsusp_get_quirks<br />
s2ram --force $OPTS<br />
}<br />
Most importantly, the {{Ic|uswsusp}} module runs:<br />
add_before_hooks uswsusp_hooks<br />
add_module_help uswsusp_help<br />
The first function, ''add_before_hook'' disables the '''pm-utils''' hooks '''99video''' since this functionality is subsumed by '''s2ram'''.<br />
The second function, ''add_module_help'', adds uswsusp-module-specific help, which in essence replaces the help function provided by '''99video'''.<br />
<br />
Back to {{Ic|pm-suspend}}:<br />
command_exists "check_$METHOD" && command_exists "do_$METHOD"<br />
"check_$METHOD"<br />
This verifies that the ''check_suspend'' and ''do_suspend'' methods have been defined. The ''check_suspend'' method simply verifies that $SUSPEND_MODULE is not empty:<br />
<br />
check_suspend() { [ -n "$SUSPEND_MODULE" ]; }<br />
<br />
Lastly, {{Ic|pm-suspend}} must run all hooks that have not been disabled, sync file-system buffers, and run ''do_suspend'':<br />
if run_hooks sleep "$ACTION $METHOD"; then<br />
# Sleep only if we know how and if a hook did not inhibit us.<br />
log "$(date): performing $METHOD"<br />
sync<br />
"do_$METHOD" || r=128<br />
log "$(date): Awake."<br />
<br />
The method ''run_hooks'' is a wrapper for ''_run_hooks'', which the case of {{ic|pm-suspend}} is called as ''run_hooks sleep "suspend suspend"''. Given that:<br />
PARAMETERS="${STORAGEDIR}/parameters"<br />
PM_UTILS_LIBDIR="/usr/lib/pm-utils"<br />
PM_UTILS_ETCDIR="/etc/pm"<br />
<br />
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.<br />
<br />
== Troubleshooting ==<br />
<br />
If suspend or hibernate did not work correctly, you will probably find some information in the log file {{ic|/var/log/pm-suspend.log}}. For example, which hooks were run and what the output of them was should be in that log file.<br />
<br />
Also, check the output of the {{ic|pm-is-supported}} command. This command (with the {{ic|--hibernate}} or {{ic|--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.<br />
<br />
=== Segmentation faults ===<br />
<br />
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 {{ic|/boot/grub/menu.lst}} as explained [[#Hibernation (suspend2disk)|above]].<br />
<br />
=== Reboot instead of resume from suspend ===<br />
<br />
This problem started when saving NVS area during suspend was introduced (in 2.6.35-rc4) ([http://www.spinics.net/lists/linux-acpi/msg29521.html 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 {{ic|1=acpi_sleep=nonvs}} kernel command line option (see [[Kernel_parameters|kernel parameters]]).<br />
<br />
=== Resume from suspend shuts down instead of wake up ===<br />
<br />
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 {{ic|1=i8042.reset=1}} to your kernel. In [[GRUB]], the line in {{ic|/boot/grub/grub.cfg}} should be something like this:<br />
linux /vmlinuz-linux root=/dev/vg00/root resume=/dev/vg00/swap i8042.reset=1 ro<br />
<br />
Although I have not tested this, you could also set this parameter live without having to restart by doing:<br />
# sysctl -e -w i8042.reset=1<br />
<br />
=== Blank screen when waking from suspend ===<br />
<br />
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.<br />
<br />
You could also try, without disabling SpeedStep, creating a quirk in {{ic|/etc/pm/sleep.d/}} with this content (requires {{Pkg|vbetool}}):<br />
{{bc|<br />
#!/bin/sh<br />
#<br />
case "$1" in<br />
suspend)<br />
;;<br />
resume)<br />
sleep 5<br />
vbetool dpms off<br />
vbetool dpms on<br />
;;<br />
*) exit $NA<br />
;;<br />
esac<br />
}}<br />
save it as you want but with a {{ic|00}} in front of the name so this is called last when resuming; remember to {{ic|chmod +x}} the script.<br />
Try adjusting the {{ic|sleep}} time if the other commands are called too soon, or if it works well, you can also try removing that line.<br />
<br />
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".<br />
<br />
=== VirtualBox problems ===<br />
<br />
The VirtualBox kernel modules cause {{ic|pm-suspend}} and {{ic|pm-hibernate}} to fail on some laptops. (See [https://bbs.archlinux.org/viewtopic.php?id=123354 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 {{ic|pm-suspend}} and {{ic|pm-hibernate}} logs appear normal.<br />
<br />
The problem can be fixed by removing the modules before suspension or hibernation and reloading them afterwards. That can be accomplished through a script:<br />
{{bc|1=<br />
#!/bin/sh<br />
<br />
rmmod vboxdrv<br />
pm-hibernate<br />
modprobe vboxdrv<br />
}}<br />
<br />
{{Note|Some users reported that it is sufficient to rebuild the kernel module by running {{ic|vboxbuild}} as root.}}<br />
<br />
=== Hibernate with missing swap partition ===<br />
<br />
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 {{ic|blkid}} command should look e.g. like<br />
{{hc|# blkid|2=<br />
/dev/sda1: UUID="00000-000-000-0000000" TYPE="ext2" <br />
/dev/sda2: UUID="00000-000-000-0000000" TYPE="ext4"<br />
/dev/sda3: UUID="00000-000-000-0000000" TYPE="ext4"<br />
/dev/sda4: UUID="00000-000-000-0000000" TYPE="swap"<br />
}}<br />
with one of the lines having {{ic|"swap"}} as the type. If this is not the case, consult [[Swap#Swap partition]] for instructions on re-creating/activating the swap partition.<br />
<br />
=== Black screen with unblinking cursor when trying to suspend ===<br />
<br />
If you get a black screen with unblinking cursor when trying to do<br />
$ sudo pm-suspend<br />
have a look at {{ic|/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".<br />
<br />
Then as root create the file {{ic|/etc/pm/config.d/modules}} and include this code with the exact name of the ehci or xhci module you found. For example:<br />
SUSPEND_MODULES="ehci_hcd"<br />
Suspend should now be working.<br />
<br />
=== Blank screen issue ===<br />
<br />
Some users have reported having issues with their laptops not resuming after a suspend or hibernate. This is due to the {{ic|autodetect}} hook in "HOOKS" array of the {{ic|/etc/mkinitcpio.conf}} file. This can be disabled using the same method for adding the {{ic|resume}} hook. Just remove {{ic|autodetect}} from the list and follow the steps to build the new image. See [[Pm-utils#Mkinitcpio_Resume_Hook|Resume Hook]] for more details on building the new image.<br />
<br />
{{Note|If you are using [[Plymouth|plymouth]] it may be an other reason to this issue. Adding {{ic|resume}} before {{ic|plymouth}} in "HOOKS" array of the {{ic|/etc/mkinitcpio.conf}} file should fix this.}}<br />
<br />
=== Unable to resume with 64 bit OS ===<br />
<br />
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.<br />
<br />
=== Black screen when waking from hibernate with radeon driver ===<br />
<br />
When using the radeon driver and having {{ic|radeon}} in the {{ic|HOOKS}} array of the {{ic|/etc/mkinitcpio.conf}} resuming from hibernation results in the screen being black, however everything else working (testable by keeping a console open with a command to execute and starting the execution after resuming).<br />
This seems to be related to using {{ic|radeon.dpm<nowiki>=</nowiki>1}} (default since kernel 3.13) as the power management method in radeon.<br />
<br />
Removing {{ic|radeon}} from the HOOKS array (and rebuiling the initrd) fixes this problem.<br />
(See [https://bugs.freedesktop.org/show_bug.cgi?id=72716 here].) <br />
<br />
=== Computer does not turn off when hibernating ===<br />
<br />
It is possible that after Linux hibernates and has written the data to disk, the computer does not power off properly. If it is then forcefully powered off and later restarted, resuming will work fine.<br />
<br />
This can easily be fixed by making an executable file named {{ic|/etc/pm/config.d/hibernate_mode}} which contains the single line: {{ic| HIBERNATE_MODE<nowiki>=</nowiki>"shutdown" }}.<br />
After that pm-hibernate should properly shut down the computer.<br />
<br />
=== Display not powering on after suspension (radeon) ===<br />
<br />
If you get a blank display after suspension with radeon gpu, try to create {{ic|/etc/pm/config.d/radeon}}, and add the following:<br />
<br />
{{hc|/etc/pm/config.d/radeon|2=<br />
QUIRK_S3_BIOS="true"<br />
QUIRK_S3_MODE="true"<br />
}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Having the HD power management level automatically set again on resume ===<br />
<br />
Do it like this:<br />
{{hc|/etc/pm/sleep.d/50-hdparm_pm|<nowiki><br />
#!/bin/dash<br />
<br />
if [ -n "$1" ] && ([ "$1" = "resume" ] || [ "$1" = "thaw" ]); then<br />
hdparm -B 254 /dev/sda > /dev/null<br />
fi<br />
</nowiki>}}<br />
<br />
Then run:<br />
# chmod +x /etc/pm/sleep.d/50-hdparm_pm<br />
<br />
If the above [[Bash]] script fails the work, the following may work instead:<br />
{{hc|/etc/pm/sleep.d/50-hdparm_pm|<nowiki><br />
#!/bin/sh<br />
<br />
. "${PM_FUNCTIONS}"<br />
case "$1" in<br />
thaw|resume)<br />
sleep 6<br />
hdparm -B 254 /dev/sda<br />
;;<br />
*)<br />
;;<br />
esac<br />
exit $NA<br />
</nowiki>}}<br />
<br />
Lower {{ic|-B}} switch values may be effective. See [[hdparm]].<br />
<br />
=== Restarting the mouse ===<br />
<br />
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 {{ic|i8042}}) through a hook in {{ic|/etc/pm/hooks}} (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 />
=== Add sleep modes to Openbox menu ===<br />
<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 {{ic|~/.config/openbox/menu.xml}}, 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 />
=== Handling "sleep" and "power" buttons ===<br />
<br />
"Sleep" and "power" buttons are handled by {{ic|acpid}} in {{ic|/etc/acpi/handler.sh}} (see "button/power" and "power/sleep" entries). You may want to substitute the default actions with calls to {{ic|pm-suspend}} and {{ic|pm-hibernate}}.<br />
<br />
Please note that [[Systemd#ACPI_power_management|systemd]] handles power events on its own and does not use pm-utils or any scripts from {{ic|/etc/pm/*}}.<br />
<br />
=== Locking the screen saver on hibernate or suspend ===<br />
<br />
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 {{ic|/etc/pm/sleep.d}} folder. Make sure the script is executable (chmod 755) and owned by {{ic|root:root}}.<br />
<br />
A simple example script is:<br />
<br />
{{hc|/etc/pm/sleep.d/00screensaver-lock|<nowiki><br />
#!/bin/sh<br />
#<br />
# 00screensaver-lock: lock workstation on hibernate or suspend<br />
<br />
username= # add username here; i.e.: username=foobar<br />
userhome=/home/$username<br />
export XAUTHORITY="$userhome/.Xauthority"<br />
export DISPLAY=":0"<br />
<br />
case "$1" in<br />
hibernate|suspend)<br />
su $username -c "/usr/bin/slimlock" & # or any other such as /usr/bin/xscreensaver-command -lock<br />
;;<br />
thaw|resume)<br />
;;<br />
*) exit $NA<br />
;;<br />
esac</nowiki>}}<br />
<br />
Replace {{ic|/usr/bin/slimlock}} with the path to your screen locking utility of choice.<br />
<br />
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 [https://github.com/rephorm/xuserrun xuserrun] and the following sleep.d script (be sure to modify the path to xuserrun and your desired screen locker):<br />
<br />
{{hc|/etc/pm/sleep.d/00screensaver-lock|<nowiki><br />
#!/bin/sh<br />
#<br />
# 00screensaver-lock: lock workstation on hibernate or suspend<br />
<br />
case "$1" in<br />
hibernate|suspend)<br />
/path/to/xuserrun /usr/bin/slimlock & # or any other such as /usr/bin/xscreensaver-command -lock<br />
;;<br />
thaw|resume)<br />
;;<br />
*) exit $NA<br />
;;<br />
esac<br />
</nowiki>}}<br />
<br />
If you have problems using xuserrun, you can instead try having loginctl do this directly. This script will lock all active sessions before going into hibernation:<br />
<br />
{{hc|/etc/pm/sleep.d/00screensaver-lock|<nowiki><br />
#!/bin/sh<br />
#<br />
# 00screensaver-lock: lock workstation on hibernate or suspend<br />
<br />
case "$1" in<br />
hibernate|suspend)<br />
loginctl lock-sessions<br />
;;<br />
thaw|resume)<br />
;;<br />
*) exit $NA<br />
;;<br />
esac<br />
</nowiki>}}<br />
<br />
If you do not use systemd, the following script includes another method for determining the username and display. It is not robust, and thus includes a fallback to a hard-coded username.<br />
<br />
{{hc|/etc/pm/sleep.d/00screensaver-lock|<nowiki><br />
#!/bin/sh<br />
#<br />
# 00screensaver-lock: lock workstation on hibernate or suspend<br />
<br />
dbus=$(ps aux | grep 'dbus-launch' | grep -v root)<br />
if [[ ! -z $dbus ]]; then<br />
username=$(echo $dbus | awk '{print $1}')<br />
userhome=$(getent passwd $username | cut -d: -f6)<br />
export XAUTHORITY="$userhome/.Xauthority"<br />
for x in /tmp/.X11-unix/*; do<br />
displaynum=$(echo $x | sed s#/tmp/.X11-unix/X##)<br />
if [[ -f "$XAUTHORITY" ]]; then<br />
export DISPLAY=":$displaynum"<br />
fi<br />
done<br />
else<br />
username= # add username here; i.e.: username=foobar<br />
userhome=/home/$username <br />
export XAUTHORITY="$userhome/.Xauthority"<br />
export DISPLAY=":0"<br />
fi<br />
<br />
case "$1" in<br />
hibernate|suspend)<br />
su $USER -c "/usr/bin/slimlock" & # or any other such as /usr/bin/xscreensaver-command -lock<br />
;;<br />
thaw|resume)<br />
;;<br />
*) exit $NA<br />
;;<br />
esac<br />
</nowiki>}}<br />
<br />
{{Note|For the previous scripts to work, TTY lock must be disabled in slimlock. Be sure to set {{ic|tty_lock 0}} in {{ic|/etc/slimlock.conf}}. [https://github.com/joelburget/slimlock/issues/4 Source].}}<br />
<br />
=== Disabling hibernation via polkit ===<br />
<br />
In order to disable hibernation, create a new file in /etc/polkit-1/ called 99-disable-hibernate.rules. Then add the following lines:<br />
<br />
{{hc|99-disable-hibernate.rules|<nowiki><br />
polkit.addRule(function(action, subject) {<br />
if ((action.id == "org.freedesktop.login1.hibernate")) {<br />
return polkit.Result.NO;<br />
}<br />
});<br />
<br />
polkit.addRule(function(action, subject) {<br />
if ((action.id == "org.freedesktop.login1.hibernate-multiple-sessions")) {<br />
return polkit.Result.NO;<br />
}<br />
});<br />
</nowiki>}}<br />
<br />
If you're using KDE, log off once and the hibernation option should be gone.<br />
<br />
== See also ==<br />
<br />
* [http://en.opensuse.org/SDB:Pm-utils OpenSUSE Wiki] - The article from where this was originally sourced (Licensed under GPL)<br />
* [https://wiki.ubuntu.com/UnderstandingSuspend Understanding Suspend] - Ubuntu article explaining how suspending to RAM works<br />
* [http://www.mjmwired.net/kernel/Documentation/power/basic-pm-debugging.txt#178 PM Debugging] - Basic PM debugging<br />
*[[Cpufrequtils]] - CPU Frequency Scaling and CPU Power schemes<br />
*[[Acpid]] - daemon for delivering ACPI events<br />
* [http://superuser.com/questions/298672/linuxhow-to-hibernate-after-a-period-of-sleep Hibernate after sleep] - An example of a custom pm-utils hook where hibernation is triggered after a period of time in suspension</div>5hafflhttps://wiki.archlinux.org/index.php?title=Pm-utils&diff=328322Pm-utils2014-08-03T14:42:38Z<p>5haffl: /* Troubleshooting */</p>
<hr />
<div>{{DISPLAYTITLE:pm-utils}}<br />
[[Category:Power management]]<br />
[[it:Pm-utils]]<br />
[[ru:Pm-utils]]<br />
[[zh-CN:Pm-utils]]<br />
{{Related articles start}}<br />
{{Related|Uswsusp}}<br />
{{Related|TuxOnIce}}<br />
{{Related articles end}}<br />
{{Out of date| Need to address pm-utils relevance compared to systemd's suspend functions}}<br />
{{Warning|1=Hibernating with Pm-utils and then updating systemd is reported to corrupt files:<br />
https://bbs.archlinux.org/viewtopic.php?pid=1423442}}<br />
'''pm-utils''' is a suspend and powerstate setting framework. It is designed to replace such scripts as those provided by the {{ic|powersave}} package.<br />
<br />
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.<br />
<br />
A lesser known feature is one that mimics toggling done by [[Laptop Mode Tools]].<br />
<br />
Used in conjunction with the [[cpupower]] package, notebook (and desktop) owners are provided with a complete power management suite.<br />
<br />
== Installation ==<br />
<br />
[[pacman|Install]] the {{Pkg|pm-utils}} package which is available in the [[official repositories]].<br />
<br />
{{Note|<br />
* If you run into issues when resuming video, it might be necessary to also install {{Pkg|vbetool}} from the [[official repositories]].<br />
* If you are starting from a clean install, make sure that you have {{Pkg|acpi}} installed.<br />
}}<br />
<br />
Run {{ic|pm-suspend}}, {{ic|pm-suspend-hybrid}} or {{ic|pm-hibernate}} as root to trigger suspend manually. The suspend scripts write log to {{ic|/var/log/pm-suspend.log}}.<br />
<br />
=== Installing alternative suspend backend (optional) ===<br />
<br />
The Arch Linux package ships with support for the following backends: {{ic|kernel}}, {{ic|tuxonice}} and {{ic|uswsusp}} which can be seen from command:<br />
pacman -Ql pm-utils | grep module.d<br />
<br />
Suspend backend is specified by the {{ic|SLEEP_MODULE}} configuration variable in {{ic|/etc/pm/config.d}} and defaults to the {{ic|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]]:<br />
* uswsusp - {{AUR|uswsusp-git}}<br />
* tuxonice - {{AUR|linux-ice}} / [[linux-pf]]<br />
<br />
Furthermore, {{Pkg|pm-utils}} ships with its own video quirks database in {{ic|/usr/lib/pm-utils/video-quirks/}}.<br />
<br />
== Basic configuration ==<br />
<br />
=== Standby/suspend to RAM ===<br />
<br />
In the ideal case, running {{ic|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.<br />
<br />
{{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.}} <br />
<br />
In some cases, it is possible that running {{ic|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 {{ic|SUSPEND_MODULES}} config to {{ic|/etc/pm/config.d/modules}} of the form:<br />
SUSPEND_MODULES="uhci_hd button ehci_hd iwlwifi"<br />
should cause these modules to be specifically unloaded before suspend and reloaded after resume.<br />
<br />
To configure invoking {{ic|pm-suspend}} automatically on power events like laptop lid close, please refer to [[Acpid]].<br />
<br />
=== Hibernation (suspend2disk) ===<br />
<br />
You need to follow instructions in [[Suspend and Hibernate#Hibernation]] in order to set up hibernation.<br />
<br />
Alternatively, if you do not use the {{ic|kernel}} backend, see [[Uswsusp#Configuration]] or [[TuxOnIce#Setting up the bootloader]].<br />
<br />
=== Suspend/hibernate as regular user ===<br />
<br />
Three methods are available to suspend without the need for a root password: using [[Udev]], using UPower, and giving the user the appropriate permissions with [[sudo|visudo]].<br />
<br />
==== User permission method ====<br />
<br />
Because the {{Pkg|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 {{ic|/etc/sudoers}} file with {{ic|visudo}} as root. For more information, see [[sudo]].<br />
<br />
Add the following lines, replacing {{ic|''username''}} with your own user name, then save and exit {{ic|visudo}}:<br />
''username'' ALL = NOPASSWD: /usr/sbin/pm-hibernate<br />
''username'' ALL = NOPASSWD: /usr/sbin/pm-suspend<br />
<br />
Or you can enable it for a group, using the following lines, replacing {{ic|''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., {{ic|1=username ALL=(ALL) ALL}}, or they will not work.}}<br />
<br />
You can now run the scripts without a password by simply running:<br />
$ sudo pm-hibernate<br />
<br />
or:<br />
<br />
$ sudo pm-suspend<br />
<br />
Also, add yourself to the {{ic|power}} [[Users and groups|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 [[GNOME]]'s shutdown applet, your computer will just play a very annoying loud triple beep and lock the screen.<br />
# gpasswd -a ''username'' power<br />
<br />
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.<br />
<br />
=== Power saving ===<br />
<br />
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 {{ic|/etc/pm/power.d/}}. An example of such a script can be found in the [http://crunchbanglinux.org/forums/post/110148/#p110148 crunchbang forum]. Be aware that upower must be running in order to detect changing AC states [https://bbs.archlinux.org/viewtopic.php?id=132125 (see more information)].<br />
<br />
==== Change brightness depending on AC state ====<br />
<br />
One possible example looks as follows and changes brightness according to the AC state. Create a file called {{ic|/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.<br />
<br />
{{bc|<br />
#!/bin/bash<br />
<br />
case $1 in<br />
true)<br />
echo "Enable screen power saving"<br />
echo 5 > /sys/class/backlight/acpi_video0/device/backlight/acpi_video0/brightness<br />
;;<br />
false)<br />
echo "Disable screen power saving"<br />
echo 14 > /sys/class/backlight/acpi_video0/device/backlight/acpi_video0/brightness<br />
;;<br />
esac<br />
}}<br />
<br />
=== Suspend on idle/inactivity ===<br />
<br />
One method relies on xautolock program. Add following: {{ic|xautolock -time 30 -locker "sudo pm-suspend" -detectsleep &}} to {{ic|~/.xinitrc}}. This implies that {{ic|pm-suspend}} is called after 30 minutes of inactivity.<br />
<br />
=== Using Swap file instead of regular swap partition ===<br />
<br />
If you want use swap file instead of regular swap partition, see [[Swap#Swap file|Swap File]].<br />
<br />
== Advanced configuration ==<br />
<br />
The main configuration file is {{ic|/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 {{ic|/etc/pm/config.d/}} instead.<br />
You can just put a simple text file with<br />
SUSPEND_MODULES="button uhci_hcd"<br />
named {{ic|modules}} or {{ic|config}} into {{ic|/etc/pm/config.d}} and it will override the settings in the system-wide configuration file.<br />
<br />
=== Available variables for use in config files ===<br />
<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 shut down rather than reboot<br />
<br />
=== Disabling a hook ===<br />
<br />
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.<br />
You can however easily disable hooks by just creating an empty file corresponding to the hook in {{ic|/etc/pm/sleep.d/}}. Say you want to disable the hook {{ic|/usr/lib/pm-utils/sleep.d/45pcmcia}}, 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 />
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.<br />
<br />
==== Alternative method ====<br />
<br />
Create a file in {{ic|/etc/pm/config.d}} with the modules you want to blacklist in the {{ic|HOOK_BLACKLIST}} variable.<br />
For example, to manage power saving yourself, use:<br />
HOOK_BLACKLIST="hal-cd-polling intel-audio-powersave journal-commit laptop-mode pcie_aspm readahead sata_alpm sched-powersave xfs_buffer wireless"<br />
<br />
=== Creating your own hooks ===<br />
<br />
{{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 [[Systemd#Sleep_hooks|sleep hooks]] of systemd.}}<br />
If you want to do something specific to your setup during suspend or hibernate, then you can easily put your own hook into {{ic|/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:.<br />
;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.<br />
;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.<br />
;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.<br />
;90 - 99: Reserved for critical suspend hooks.<br />
<br />
I am showing a pretty useless demonstration hook here, that will just put some informative lines into your log file:<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 are 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 {{ic|/etc/pm/sleep.d/66dummy}}, do a {{ic|chmod +x /etc/pm/sleep.d/66dummy}} and it will spew some useless lines during suspend and resume.<br />
<br />
{{Warning|All the hooks run as root. This means that you need to be careful when creating temporary files, check that the {{ic|PATH}} environment variable is set correctly, etc. to avoid security problems.}}<br />
<br />
== How it works ==<br />
<br />
The concept is quite easy: the main script ({{ic|pm-action}}, called via symlinks as either {{ic|pm-suspend}}, {{ic|pm-hibernate}} or {{ic|pm-suspend-hybrid}}) executes so-called "hooks", executable scripts, in the alphabetical sorted order with the parameter {{ic|suspend}} (suspend to RAM) or {{ic|hibernate}} (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 {{ic|resume}} (resume from RAM) or {{ic|thaw}} (resume from disk).<br />
The hooks perform various tasks, such as preparing the bootloader, stopping the Bluetooth subsystem, or unloading of critical modules.<br />
<br />
Both {{ic|pm-suspend}} and {{ic|pm-hibernate}} are usually called from [[Udev]], initiated by desktop applets like {{Pkg|gnome-power-manager}} or {{ic|kpowersave}}.<br />
<br />
{{Note|{{ic|suspend-hybrid}} 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 {{ic|pm-powersave}} is used with an additional parameter of {{ic|true}} or {{ic|false}}. It works basically the same as the suspend framework.<br />
<br />
The hooks for suspend are placed in<br />
;{{ic|/usr/lib/pm-utils/sleep.d}}: distribution / package provided hooks<br />
;{{ic|/etc/pm/sleep.d}}: hooks added by the system administrator<br />
<br />
The hooks for the power state are placed in <br />
;{{ic|/usr/lib/pm-utils/power.d}}: distribution / package provided hooks<br />
;{{ic|/etc/pm/power.d}}: hooks added by the system administrator<br />
<br />
Hooks in {{ic|/etc/pm/}} take precedence over those in {{ic|/usr/lib/pm-utils/}}, so the system administrator can override the defaults provided by the distribution.<br />
<br />
=== Pm-suspend internals ===<br />
<br />
This outlines the internal actions when {{ic|pm-suspend}} is run, describing how {{ic|pm-utils}} gracefully falls back onto the kernel method if the requirements of other methods are not met.<br />
<br />
$ pm-suspend<br />
<br />
The first step is set-up preliminary variables and source parent scripts:<br />
export STASHNAME=pm-suspend<br />
export METHOD="$(echo ${0##*pm-} |tr - _)"<br />
. "/usr/lib/pm-utils/pm-functions"<br />
<br />
The variable {{Ic|METHOD}} is extracted from the executable name, ''suspend'' from {{ic|pm-suspend}} and ''hibernate'' from {{ic|pm-hibernate}}.<br />
<br />
The location of runtime configuration parameters is defined in {{ic|/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 {{ic|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:<br />
{{hc|$ ls -lah /var/run/pm-utils/pm-suspend/storage/|<br />
-rw-r--r-- 1 root root 20 May 19 09:57 disable_hook:99video<br />
-rw-r--r-- 1 root root 0 May 19 02:59 parameters<br />
-rw-r--r-- 1 root root 247 May 19 02:59 parameters.rm<br />
-rw-r--r-- 1 root root 9 May 19 02:59 state:cpu0_governor<br />
-rw-r--r-- 1 root root 9 May 19 02:59 state:cpu1_governor<br />
}}<br />
<br />
Then {{Ic|pm-functions}} will source the files located in {{Ic|/etc/pm/config.d/}} in addition to {{ic|/usr/lib/pm-utils/defaults}}. Upon returning, {{Ic|pm-functions}} will proceed to source the files specified by '''$SLEEP_METHOD''' as {{Ic|/usr/lib/pm-utils/module.d/$SLEEP_METHOD[...]}} if they exist:<br />
for mod in $SLEEP_MODULE; do<br />
mod="${PM_UTILS_LIBDIR}/module.d/${mod}"<br />
[ -f "$mod" ] || continue<br />
. "$mod"<br />
done<br />
<br />
Otherwise, if '''$SLEEP_MODULE''' is empty, {{ic|do_suspend()}} will be set to the kernel backend as described above:<br />
if [ -z "$SUSPEND_MODULE" ]; then<br />
if grep -q mem /sys/power/state; then<br />
SUSPEND_MODULE="kernel"<br />
do_suspend() { echo -n "mem" >/sys/power/state; }<br />
elif [ -c /dev/pmu ] && pm-pmu --check; then<br />
SUSPEND_MODULE="kernel"<br />
do_suspend() { pm-pmu --suspend; }<br />
elif grep -q standby /sys/power/state; then<br />
SUSPEND_MODULE="kernel"<br />
do_suspend() { echo -n "standby" >/sys/power/state; }<br />
fi<br />
fi<br />
<br />
Assuming '''$SLEEP_MODULE''' is not empty and {{Ic|uswsusp}} is specified, {{Ic|/usr/lib/pm-utils/module.d/uswsusp}} is executed. This script checks several requirements (these are the requirements for being able to use uswsusp):<br />
* [ -z $SUSPEND_MODULE ]<br />
* command_exists s2ram<br />
* grep -q mem /sys/power/state || ( [ -c /dev/pmu ] && pm-pmu --check; );<br />
If these requirements are met, do_suspend() is defined as:<br />
do_suspend()<br />
{<br />
uswsusp_get_quirks<br />
s2ram --force $OPTS<br />
}<br />
Most importantly, the {{Ic|uswsusp}} module runs:<br />
add_before_hooks uswsusp_hooks<br />
add_module_help uswsusp_help<br />
The first function, ''add_before_hook'' disables the '''pm-utils''' hooks '''99video''' since this functionality is subsumed by '''s2ram'''.<br />
The second function, ''add_module_help'', adds uswsusp-module-specific help, which in essence replaces the help function provided by '''99video'''.<br />
<br />
Back to {{Ic|pm-suspend}}:<br />
command_exists "check_$METHOD" && command_exists "do_$METHOD"<br />
"check_$METHOD"<br />
This verifies that the ''check_suspend'' and ''do_suspend'' methods have been defined. The ''check_suspend'' method simply verifies that $SUSPEND_MODULE is not empty:<br />
<br />
check_suspend() { [ -n "$SUSPEND_MODULE" ]; }<br />
<br />
Lastly, {{Ic|pm-suspend}} must run all hooks that have not been disabled, sync file-system buffers, and run ''do_suspend'':<br />
if run_hooks sleep "$ACTION $METHOD"; then<br />
# Sleep only if we know how and if a hook did not inhibit us.<br />
log "$(date): performing $METHOD"<br />
sync<br />
"do_$METHOD" || r=128<br />
log "$(date): Awake."<br />
<br />
The method ''run_hooks'' is a wrapper for ''_run_hooks'', which the case of {{ic|pm-suspend}} is called as ''run_hooks sleep "suspend suspend"''. Given that:<br />
PARAMETERS="${STORAGEDIR}/parameters"<br />
PM_UTILS_LIBDIR="/usr/lib/pm-utils"<br />
PM_UTILS_ETCDIR="/etc/pm"<br />
<br />
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.<br />
<br />
== Troubleshooting ==<br />
<br />
If suspend or hibernate did not work correctly, you will probably find some information in the log file {{ic|/var/log/pm-suspend.log}}. For example, which hooks were run and what the output of them was should be in that log file.<br />
<br />
Also, check the output of the {{ic|pm-is-supported}} command. This command (with the {{ic|--hibernate}} or {{ic|--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.<br />
<br />
=== Segmentation faults ===<br />
<br />
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 {{ic|/boot/grub/menu.lst}} as explained [[#Hibernation (suspend2disk)|above]].<br />
<br />
=== Reboot instead of resume from suspend ===<br />
<br />
This problem started when saving NVS area during suspend was introduced (in 2.6.35-rc4) ([http://www.spinics.net/lists/linux-acpi/msg29521.html 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 {{ic|1=acpi_sleep=nonvs}} kernel command line option (see [[Kernel_parameters|kernel parameters]]).<br />
<br />
=== Resume from suspend shuts down instead of wake up ===<br />
<br />
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 {{ic|1=i8042.reset=1}} to your kernel. In [[GRUB]], the line in {{ic|/boot/grub/grub.cfg}} should be something like this:<br />
linux /vmlinuz-linux root=/dev/vg00/root resume=/dev/vg00/swap i8042.reset=1 ro<br />
<br />
Although I have not tested this, you could also set this parameter live without having to restart by doing:<br />
# sysctl -e -w i8042.reset=1<br />
<br />
=== Blank screen when waking from suspend ===<br />
<br />
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.<br />
<br />
You could also try, without disabling SpeedStep, creating a quirk in {{ic|/etc/pm/sleep.d/}} with this content (requires {{Pkg|vbetool}}):<br />
{{bc|<br />
#!/bin/sh<br />
#<br />
case "$1" in<br />
suspend)<br />
;;<br />
resume)<br />
sleep 5<br />
vbetool dpms off<br />
vbetool dpms on<br />
;;<br />
*) exit $NA<br />
;;<br />
esac<br />
}}<br />
save it as you want but with a {{ic|00}} in front of the name so this is called last when resuming; remember to {{ic|chmod +x}} the script.<br />
Try adjusting the {{ic|sleep}} time if the other commands are called too soon, or if it works well, you can also try removing that line.<br />
<br />
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".<br />
<br />
=== VirtualBox problems ===<br />
<br />
The VirtualBox kernel modules cause {{ic|pm-suspend}} and {{ic|pm-hibernate}} to fail on some laptops. (See [https://bbs.archlinux.org/viewtopic.php?id=123354 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 {{ic|pm-suspend}} and {{ic|pm-hibernate}} logs appear normal.<br />
<br />
The problem can be fixed by removing the modules before suspension or hibernation and reloading them afterwards. That can be accomplished through a script:<br />
{{bc|1=<br />
#!/bin/sh<br />
<br />
rmmod vboxdrv<br />
pm-hibernate<br />
modprobe vboxdrv<br />
}}<br />
<br />
{{Note|Some users reported that it is sufficient to rebuild the kernel module by running {{ic|vboxbuild}} as root.}}<br />
<br />
=== Hibernate with missing swap partition ===<br />
<br />
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 {{ic|blkid}} command should look e.g. like<br />
{{hc|# blkid|2=<br />
/dev/sda1: UUID="00000-000-000-0000000" TYPE="ext2" <br />
/dev/sda2: UUID="00000-000-000-0000000" TYPE="ext4"<br />
/dev/sda3: UUID="00000-000-000-0000000" TYPE="ext4"<br />
/dev/sda4: UUID="00000-000-000-0000000" TYPE="swap"<br />
}}<br />
with one of the lines having {{ic|"swap"}} as the type. If this is not the case, consult [[Swap#Swap partition]] for instructions on re-creating/activating the swap partition.<br />
<br />
=== Black screen with unblinking cursor when trying to suspend ===<br />
<br />
If you get a black screen with unblinking cursor when trying to do<br />
$ sudo pm-suspend<br />
have a look at {{ic|/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".<br />
<br />
Then as root create the file {{ic|/etc/pm/config.d/modules}} and include this code with the exact name of the ehci or xhci module you found. For example:<br />
SUSPEND_MODULES="ehci_hcd"<br />
Suspend should now be working.<br />
<br />
=== Blank screen issue ===<br />
<br />
Some users have reported having issues with their laptops not resuming after a suspend or hibernate. This is due to the {{ic|autodetect}} hook in "HOOKS" array of the {{ic|/etc/mkinitcpio.conf}} file. This can be disabled using the same method for adding the {{ic|resume}} hook. Just remove {{ic|autodetect}} from the list and follow the steps to build the new image. See [[Pm-utils#Mkinitcpio_Resume_Hook|Resume Hook]] for more details on building the new image.<br />
<br />
{{Note|If you are using [[Plymouth|plymouth]] it may be an other reason to this issue. Adding {{ic|resume}} before {{ic|plymouth}} in "HOOKS" array of the {{ic|/etc/mkinitcpio.conf}} file should fix this.}}<br />
<br />
=== Unable to resume with 64 bit OS ===<br />
<br />
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.<br />
<br />
=== Black screen when waking from hibernate with radeon driver ===<br />
<br />
When using the radeon driver and having {{ic|radeon}} in the {{ic|HOOKS}} array of the {{ic|/etc/mkinitcpio.conf}} resuming from hibernation results in the screen being black, however everything else working (testable by keeping a console open with a command to execute and starting the execution after resuming).<br />
This seems to be related to using {{ic|radeon.dpm<nowiki>=</nowiki>1}} (default since kernel 3.13) as the power management method in radeon.<br />
<br />
Removing {{ic|radeon}} from the HOOKS array (and rebuiling the initrd) fixes this problem.<br />
(See [https://bugs.freedesktop.org/show_bug.cgi?id=72716 here].) <br />
<br />
=== Computer does not turn off when hibernating ===<br />
<br />
It is possible that after Linux hibernates and has written the data to disk, the computer does not power off properly. If it is then forcefully powered off and later restarted, resuming will work fine.<br />
<br />
This can easily be fixed by making an executable file named {{ic|/etc/pm/config.d/hibernate_mode}} which contains the single line: {{ic| HIBERNATE_MODE<nowiki>=</nowiki>"shutdown" }}.<br />
After that pm-hibernate should properly shut down the computer.<br />
<br />
=== Display not powering up on resume (radeon) ===<br />
<br />
If you get a blank display after suspension with radeon gpu, try to create {{ic|/etc/pm/config.d/radeon}}, and add the following:<br />
<br />
{{hc|/etc/pm/config.d/radeon|2=<br />
QUIRK_S3_BIOS="true"<br />
QUIRK_S3_MODE="true"<br />
}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Having the HD power management level automatically set again on resume ===<br />
<br />
Do it like this:<br />
{{hc|/etc/pm/sleep.d/50-hdparm_pm|<nowiki><br />
#!/bin/dash<br />
<br />
if [ -n "$1" ] && ([ "$1" = "resume" ] || [ "$1" = "thaw" ]); then<br />
hdparm -B 254 /dev/sda > /dev/null<br />
fi<br />
</nowiki>}}<br />
<br />
Then run:<br />
# chmod +x /etc/pm/sleep.d/50-hdparm_pm<br />
<br />
If the above [[Bash]] script fails the work, the following may work instead:<br />
{{hc|/etc/pm/sleep.d/50-hdparm_pm|<nowiki><br />
#!/bin/sh<br />
<br />
. "${PM_FUNCTIONS}"<br />
case "$1" in<br />
thaw|resume)<br />
sleep 6<br />
hdparm -B 254 /dev/sda<br />
;;<br />
*)<br />
;;<br />
esac<br />
exit $NA<br />
</nowiki>}}<br />
<br />
Lower {{ic|-B}} switch values may be effective. See [[hdparm]].<br />
<br />
=== Restarting the mouse ===<br />
<br />
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 {{ic|i8042}}) through a hook in {{ic|/etc/pm/hooks}} (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 />
=== Add sleep modes to Openbox menu ===<br />
<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 {{ic|~/.config/openbox/menu.xml}}, 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 />
=== Handling "sleep" and "power" buttons ===<br />
<br />
"Sleep" and "power" buttons are handled by {{ic|acpid}} in {{ic|/etc/acpi/handler.sh}} (see "button/power" and "power/sleep" entries). You may want to substitute the default actions with calls to {{ic|pm-suspend}} and {{ic|pm-hibernate}}.<br />
<br />
Please note that [[Systemd#ACPI_power_management|systemd]] handles power events on its own and does not use pm-utils or any scripts from {{ic|/etc/pm/*}}.<br />
<br />
=== Locking the screen saver on hibernate or suspend ===<br />
<br />
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 {{ic|/etc/pm/sleep.d}} folder. Make sure the script is executable (chmod 755) and owned by {{ic|root:root}}.<br />
<br />
A simple example script is:<br />
<br />
{{hc|/etc/pm/sleep.d/00screensaver-lock|<nowiki><br />
#!/bin/sh<br />
#<br />
# 00screensaver-lock: lock workstation on hibernate or suspend<br />
<br />
username= # add username here; i.e.: username=foobar<br />
userhome=/home/$username<br />
export XAUTHORITY="$userhome/.Xauthority"<br />
export DISPLAY=":0"<br />
<br />
case "$1" in<br />
hibernate|suspend)<br />
su $username -c "/usr/bin/slimlock" & # or any other such as /usr/bin/xscreensaver-command -lock<br />
;;<br />
thaw|resume)<br />
;;<br />
*) exit $NA<br />
;;<br />
esac</nowiki>}}<br />
<br />
Replace {{ic|/usr/bin/slimlock}} with the path to your screen locking utility of choice.<br />
<br />
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 [https://github.com/rephorm/xuserrun xuserrun] and the following sleep.d script (be sure to modify the path to xuserrun and your desired screen locker):<br />
<br />
{{hc|/etc/pm/sleep.d/00screensaver-lock|<nowiki><br />
#!/bin/sh<br />
#<br />
# 00screensaver-lock: lock workstation on hibernate or suspend<br />
<br />
case "$1" in<br />
hibernate|suspend)<br />
/path/to/xuserrun /usr/bin/slimlock & # or any other such as /usr/bin/xscreensaver-command -lock<br />
;;<br />
thaw|resume)<br />
;;<br />
*) exit $NA<br />
;;<br />
esac<br />
</nowiki>}}<br />
<br />
If you have problems using xuserrun, you can instead try having loginctl do this directly. This script will lock all active sessions before going into hibernation:<br />
<br />
{{hc|/etc/pm/sleep.d/00screensaver-lock|<nowiki><br />
#!/bin/sh<br />
#<br />
# 00screensaver-lock: lock workstation on hibernate or suspend<br />
<br />
case "$1" in<br />
hibernate|suspend)<br />
loginctl lock-sessions<br />
;;<br />
thaw|resume)<br />
;;<br />
*) exit $NA<br />
;;<br />
esac<br />
</nowiki>}}<br />
<br />
If you do not use systemd, the following script includes another method for determining the username and display. It is not robust, and thus includes a fallback to a hard-coded username.<br />
<br />
{{hc|/etc/pm/sleep.d/00screensaver-lock|<nowiki><br />
#!/bin/sh<br />
#<br />
# 00screensaver-lock: lock workstation on hibernate or suspend<br />
<br />
dbus=$(ps aux | grep 'dbus-launch' | grep -v root)<br />
if [[ ! -z $dbus ]]; then<br />
username=$(echo $dbus | awk '{print $1}')<br />
userhome=$(getent passwd $username | cut -d: -f6)<br />
export XAUTHORITY="$userhome/.Xauthority"<br />
for x in /tmp/.X11-unix/*; do<br />
displaynum=$(echo $x | sed s#/tmp/.X11-unix/X##)<br />
if [[ -f "$XAUTHORITY" ]]; then<br />
export DISPLAY=":$displaynum"<br />
fi<br />
done<br />
else<br />
username= # add username here; i.e.: username=foobar<br />
userhome=/home/$username <br />
export XAUTHORITY="$userhome/.Xauthority"<br />
export DISPLAY=":0"<br />
fi<br />
<br />
case "$1" in<br />
hibernate|suspend)<br />
su $USER -c "/usr/bin/slimlock" & # or any other such as /usr/bin/xscreensaver-command -lock<br />
;;<br />
thaw|resume)<br />
;;<br />
*) exit $NA<br />
;;<br />
esac<br />
</nowiki>}}<br />
<br />
{{Note|For the previous scripts to work, TTY lock must be disabled in slimlock. Be sure to set {{ic|tty_lock 0}} in {{ic|/etc/slimlock.conf}}. [https://github.com/joelburget/slimlock/issues/4 Source].}}<br />
<br />
=== Disabling hibernation via polkit ===<br />
<br />
In order to disable hibernation, create a new file in /etc/polkit-1/ called 99-disable-hibernate.rules. Then add the following lines:<br />
<br />
{{hc|99-disable-hibernate.rules|<nowiki><br />
polkit.addRule(function(action, subject) {<br />
if ((action.id == "org.freedesktop.login1.hibernate")) {<br />
return polkit.Result.NO;<br />
}<br />
});<br />
<br />
polkit.addRule(function(action, subject) {<br />
if ((action.id == "org.freedesktop.login1.hibernate-multiple-sessions")) {<br />
return polkit.Result.NO;<br />
}<br />
});<br />
</nowiki>}}<br />
<br />
If you're using KDE, log off once and the hibernation option should be gone.<br />
<br />
== See also ==<br />
<br />
* [http://en.opensuse.org/SDB:Pm-utils OpenSUSE Wiki] - The article from where this was originally sourced (Licensed under GPL)<br />
* [https://wiki.ubuntu.com/UnderstandingSuspend Understanding Suspend] - Ubuntu article explaining how suspending to RAM works<br />
* [http://www.mjmwired.net/kernel/Documentation/power/basic-pm-debugging.txt#178 PM Debugging] - Basic PM debugging<br />
*[[Cpufrequtils]] - CPU Frequency Scaling and CPU Power schemes<br />
*[[Acpid]] - daemon for delivering ACPI events<br />
* [http://superuser.com/questions/298672/linuxhow-to-hibernate-after-a-period-of-sleep Hibernate after sleep] - An example of a custom pm-utils hook where hibernation is triggered after a period of time in suspension</div>5hafflhttps://wiki.archlinux.org/index.php?title=Power_management/Suspend_and_hibernate&diff=328320Power management/Suspend and hibernate2014-08-03T14:39:40Z<p>5haffl: /* Display not powering up on resume (radeon) */</p>
<hr />
<div>[[Category:Power management]]<br />
[[ja:Suspend and Hibernate]]<br />
{{Related articles start}}<br />
{{Related|Uswsusp}}<br />
{{Related|TuxOnIce}}<br />
{{Related|systemd}}<br />
{{Related|pm-utils}}<br />
{{Related|Suspending to RAM with hibernate-script}}<br />
{{Related|Suspending to Disk with hibernate-script}}<br />
{{Related|Power management}}<br />
{{Related articles end}}<br />
Currently there are three methods of suspending available: '''suspend to RAM''' (usually called just '''suspend'''), '''suspend to disk''' (usually known as '''hibernate'''), and '''hybrid suspend''' (sometimes aptly called '''suspend to both'''):<br />
<br />
* '''Suspend to RAM''' method cuts power to most parts of the machine aside from the RAM, which is required to restore the machine's state. Because of the large power savings, it is advisable for laptops to automatically enter this mode when the computer is running on batteries and the lid is closed (or the user is inactive for some time).<br />
<br />
* '''Suspend to disk''' method saves the machine's state into [[Swap|swap space]] and completely powers off the machine. When the machine is powered on, the state is restored. Until then, there is zero power consumption.<br />
<br />
* '''Suspend to both''' method saves the machine's state into swap space, but does not power off the machine. Instead, it invokes usual suspend to RAM. Therefore, if the battery is not depleted, the system can resume from RAM. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine's state has not been lost.<br />
<br />
There are multiple low level interfaces (backends) providing basic functionality, and some high level interfaces providing tweaks to handle problematic hardware drivers/kernel modules (e.g. video card re-initialization).<br />
<br />
== Low level interfaces ==<br />
<br />
Though these interfaces can be used directly, it is advisable to use some of [[#High level interfaces|high level interfaces]] to suspend/hibernate. Using low level interfaces directly is significantly faster than using any high level interface, since running all the pre- and post-suspend hooks takes time, but hooks can properly set hardware clock, restore wireless etc.<br />
<br />
=== kernel (swsusp) ===<br />
<br />
The most straightforward approach is to directly inform the in-kernel software suspend code (swsusp) to enter a suspended state; the exact method and state depends on the level of hardware support. On modern kernels, writing appropriate strings to {{ic|/sys/power/state}} is the primary mechanism to trigger this suspend.<br />
<br />
See [https://www.kernel.org/doc/Documentation/power/states.txt kernel documentation] for details.<br />
<br />
=== uswsusp ===<br />
<br />
The uswsusp ('Userspace Software Suspend') is a wrapper around the kernel's suspend-to-RAM mechanism, which performs some graphics adapter manipulations from userspace before suspending and after resuming.<br />
<br />
See main article [[Uswsusp]].<br />
<br />
=== tuxonice ===<br />
<br />
TuxOnIce is a fork of the kernel implementation of suspend/hibernate that provides kernel patches to improve the default implementation. It requires a custom kernel to achieve this purpose.<br />
<br />
See main article [[TuxOnIce]].<br />
<br />
== High level interfaces ==<br />
<br />
{{Note|The end goal of these packages is to provide binaries/scripts that can be invoked to perform suspend/hibernate. Actually hooking them up to power buttons or menu clicks or laptop lid events is usually left to other tools. To automatically suspend/hibernate on certain power events, such as laptop lid close or battery depletion percentage, you may want to look into running [[Acpid]].}}<br />
<br />
=== systemd ===<br />
<br />
[[systemd]] provides native commands for suspend, hibernate and a hybrid suspend, see [[Power management#Power management with systemd]] for details.<br />
<br />
See [[Power management#Sleep hooks]] for additional information on configuring suspend/hibernate hooks. Also see {{ic|man systemctl}}, {{ic|man systemd-sleep}}, and {{ic|man systemd.special}}.<br />
<br />
=== pm-utils ===<br />
<br />
pm-utils is a set of shell scripts that encapsulate the backend's suspend/hibernate functionality. It comes with a set of pre- and post-suspend tweaks and various hooks to customize the process.<br />
<br />
See main article [[pm-utils]].<br />
<br />
== Suspend to RAM ==<br />
<br />
Suspend to RAM should work out of the box.<br />
<br />
== Hibernation ==<br />
<br />
In order to use hibernation, you need to create swap partition or swap file. See [[Swap]] for details.<br />
<br />
=== About swap partition/file size ===<br />
<br />
Even if your swap partition is smaller than RAM, you still have a big chance of hibernating successfully. According to [https://www.kernel.org/doc/Documentation/power/interface.txt kernel documentation]:<br />
<br />
: ''{{ic|/sys/power/image_size}} controls the size of the image created by the suspend-to-disk mechanism. It can be written a string representing a non-negative integer that will be used as an upper limit of the image size, in bytes. The suspend-to-disk mechanism will do its best to ensure the image size will not exceed that number. However, if this turns out to be impossible, it will try to suspend anyway using the smallest image possible. In particular, if "0" is written to this file, the suspend image will be as small as possible. Reading from this file will display the current image size limit, which is set to 2/5 of available RAM by default.''<br />
<br />
You may either decrease the value of {{ic|/sys/power/image_size}} to make the suspend image as small as possible (for small swap partitions), or increase it to possibly speed up the hibernation process.<br />
<br />
=== Required kernel parameters ===<br />
<br />
The kernel parameter {{ic|1=resume=''swap_partition''}} has to be used. The configuration depends on the used [[boot loader]], some examples are given below. According to the boot loader configuration, use either kernel name (for example {{ic|/dev/sda1}}), or [[UUID]] path.<br />
<br />
==== Example for GRUB ====<br />
<br />
The kernel name, e.g. {{ic|/dev/sda1}}, can only be used if [[GRUB#Persistent_block_device_naming|Persistent block device naming]] is opted out in GRUB2.<br />
<br />
For example, with [[GRUB]] you can use {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} variable:<br />
<br />
{{hc|/etc/default/grub|2=<br />
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/disk/by-uuid/4209c845-f495-4c43-8a03-5363dd433153"<br />
}}<br />
<br />
Don't forget to run {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} afterwards.<br />
<br />
{{Tip|As an alternative, for GRUB2 you may try this solution from [http://wiki.debian.org/Grub#Configuring_grub_v2 debian wiki], which automatically adds your first swap partition to {{ic|1=resume=}} parameter to all found linux entries.}}<br />
<br />
==== Example for gummiboot ====<br />
<br />
If [[gummiboot]] is used as boot manager, you have to add the {{ic|1=resume=''swap_partition''}} parameter in the options-list of the entry file. <br />
<br />
For example if your efi system partition is mounted in {{ic|/boot}}, then the option list should look like this:<br />
<br />
{{hc|/boot/loader/entries/arch.conf|2=<br />
options root=/dev/sda''X'' rw resume=''swap_partition'' <br />
}}<br />
<br />
==== Hibernation into swap file ====<br />
<br />
Using a swap file instead of a swap partition requires an additional kernel parameter {{ic|1=resume_offset=''swap_file_offset''}}.<br />
<br />
The value of {{ic|''swap_file_offset''}} can be obtained by running {{ic|filefrag -v ''swap_file''}}, the output is in a table format and the required value is located in the first row of the {{ic|physical_offset}} column. For example:<br />
<br />
{{hc|# filefrag -v /swapfile|<nowiki><br />
Filesystem type is: ef53<br />
File size of /swapfile is 4294967296 (1048576 blocks of 4096 bytes)<br />
ext: logical_offset: physical_offset: length: expected: flags:<br />
0: 0.. 0: 38912.. 38912: 1: <br />
1: 1.. 22527: 38913.. 61439: 22527: unwritten<br />
2: 22528.. 53247: 899072.. 929791: 30720: 61440: unwritten<br />
...<br />
</nowiki>}}<br />
<br />
In the example the value of {{ic|''swap_file_offset''}} is {{ic|38912}}.<br />
<br />
{{Tip|The value of {{ic|''swap_file_offset''}} can also be obtained by running {{ic|swap-offset ''swap_file''}}. The ''swap-offset'' binary is provided by package {{AUR|uswsusp-git}}.}}<br />
<br />
{{Note|<br />
* Please note that in the kernel parameter {{ic|resume}} you have to provide the device of the partition that contains the swap file, not swap file itself! The parameter {{ic|resume_offset}} informs the system where the swap file starts on the resume device.<br />
* If using [[uswsusp]], then these two parameters have to be provided in {{ic|/etc/suspend.conf}} via the keys {{ic|resume device}} and {{ic|resume offset}}.<br />
}}<br />
<br />
=== Recreate initial ramdisk ===<br />
<br />
If you use an initramfs (default Arch systems do), you must add the {{ic|resume}} hook into the HOOKS in the configuration of [[mkinitcpio]]:<br />
<br />
{{hc|/etc/mkinitcpio.conf|2=<br />
# resume must be placed after block and lvm2, but before filesystems<br />
HOOKS="... block lvm2 '''resume''' filesystems ..."<br />
}}<br />
<br />
{{Warning|You must not use the [[Mkinitcpio#Common_hooks|systemd hook]], because it does not support resuming from hibernation. See {{Bug|37028}} for details.}}<br />
<br />
Finally, you must rebuild the initrd image for these changes to take effect:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|If you use a custom kernel, then you might have to change the value of the {{ic|-p}} option.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== ACPI_OS_NAME ===<br />
<br />
You might want to tweak your '''DSDT table''' to make it work. See [[DSDT]] article<br />
<br />
=== VAIO Users ===<br />
<br />
Add acpi_sleep=nonvs kernel flag to your loader, and you are done!<br />
<br />
=== Suspend/hibernate doesn't work ===<br />
<br />
There have been many reports about the screen going black without easily viewable errors or the ability to do anything when going into and coming back from suspend and/or hibernate. These problems have been seen on both laptops and desktops. This is not an official solution, but switching to an older kernel, especially the LTS-kernel, will probably fix this.<br />
<br />
=== Display not powering up on resume (radeon) ===<br />
<br />
If you get a blank display after suspension with radeon gpu, try to create {{ic|/etc/pm/config.d/radeon}}, and add the following:<br />
<br />
{{hc|/etc/pm/config.d/radeon|2=<br />
QUIRK_S3_BIOS="true"<br />
QUIRK_S3_MODE="true"<br />
}}<br />
<br />
Of course, this (possible) fix only affects pm-utils (tested with xf86-video-ati and AMD HD 7640G+7470M).</div>5hafflhttps://wiki.archlinux.org/index.php?title=Power_management/Suspend_and_hibernate&diff=328319Power management/Suspend and hibernate2014-08-03T14:38:50Z<p>5haffl: /* Display not powering up on resume (radeon) */</p>
<hr />
<div>[[Category:Power management]]<br />
[[ja:Suspend and Hibernate]]<br />
{{Related articles start}}<br />
{{Related|Uswsusp}}<br />
{{Related|TuxOnIce}}<br />
{{Related|systemd}}<br />
{{Related|pm-utils}}<br />
{{Related|Suspending to RAM with hibernate-script}}<br />
{{Related|Suspending to Disk with hibernate-script}}<br />
{{Related|Power management}}<br />
{{Related articles end}}<br />
Currently there are three methods of suspending available: '''suspend to RAM''' (usually called just '''suspend'''), '''suspend to disk''' (usually known as '''hibernate'''), and '''hybrid suspend''' (sometimes aptly called '''suspend to both'''):<br />
<br />
* '''Suspend to RAM''' method cuts power to most parts of the machine aside from the RAM, which is required to restore the machine's state. Because of the large power savings, it is advisable for laptops to automatically enter this mode when the computer is running on batteries and the lid is closed (or the user is inactive for some time).<br />
<br />
* '''Suspend to disk''' method saves the machine's state into [[Swap|swap space]] and completely powers off the machine. When the machine is powered on, the state is restored. Until then, there is zero power consumption.<br />
<br />
* '''Suspend to both''' method saves the machine's state into swap space, but does not power off the machine. Instead, it invokes usual suspend to RAM. Therefore, if the battery is not depleted, the system can resume from RAM. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine's state has not been lost.<br />
<br />
There are multiple low level interfaces (backends) providing basic functionality, and some high level interfaces providing tweaks to handle problematic hardware drivers/kernel modules (e.g. video card re-initialization).<br />
<br />
== Low level interfaces ==<br />
<br />
Though these interfaces can be used directly, it is advisable to use some of [[#High level interfaces|high level interfaces]] to suspend/hibernate. Using low level interfaces directly is significantly faster than using any high level interface, since running all the pre- and post-suspend hooks takes time, but hooks can properly set hardware clock, restore wireless etc.<br />
<br />
=== kernel (swsusp) ===<br />
<br />
The most straightforward approach is to directly inform the in-kernel software suspend code (swsusp) to enter a suspended state; the exact method and state depends on the level of hardware support. On modern kernels, writing appropriate strings to {{ic|/sys/power/state}} is the primary mechanism to trigger this suspend.<br />
<br />
See [https://www.kernel.org/doc/Documentation/power/states.txt kernel documentation] for details.<br />
<br />
=== uswsusp ===<br />
<br />
The uswsusp ('Userspace Software Suspend') is a wrapper around the kernel's suspend-to-RAM mechanism, which performs some graphics adapter manipulations from userspace before suspending and after resuming.<br />
<br />
See main article [[Uswsusp]].<br />
<br />
=== tuxonice ===<br />
<br />
TuxOnIce is a fork of the kernel implementation of suspend/hibernate that provides kernel patches to improve the default implementation. It requires a custom kernel to achieve this purpose.<br />
<br />
See main article [[TuxOnIce]].<br />
<br />
== High level interfaces ==<br />
<br />
{{Note|The end goal of these packages is to provide binaries/scripts that can be invoked to perform suspend/hibernate. Actually hooking them up to power buttons or menu clicks or laptop lid events is usually left to other tools. To automatically suspend/hibernate on certain power events, such as laptop lid close or battery depletion percentage, you may want to look into running [[Acpid]].}}<br />
<br />
=== systemd ===<br />
<br />
[[systemd]] provides native commands for suspend, hibernate and a hybrid suspend, see [[Power management#Power management with systemd]] for details.<br />
<br />
See [[Power management#Sleep hooks]] for additional information on configuring suspend/hibernate hooks. Also see {{ic|man systemctl}}, {{ic|man systemd-sleep}}, and {{ic|man systemd.special}}.<br />
<br />
=== pm-utils ===<br />
<br />
pm-utils is a set of shell scripts that encapsulate the backend's suspend/hibernate functionality. It comes with a set of pre- and post-suspend tweaks and various hooks to customize the process.<br />
<br />
See main article [[pm-utils]].<br />
<br />
== Suspend to RAM ==<br />
<br />
Suspend to RAM should work out of the box.<br />
<br />
== Hibernation ==<br />
<br />
In order to use hibernation, you need to create swap partition or swap file. See [[Swap]] for details.<br />
<br />
=== About swap partition/file size ===<br />
<br />
Even if your swap partition is smaller than RAM, you still have a big chance of hibernating successfully. According to [https://www.kernel.org/doc/Documentation/power/interface.txt kernel documentation]:<br />
<br />
: ''{{ic|/sys/power/image_size}} controls the size of the image created by the suspend-to-disk mechanism. It can be written a string representing a non-negative integer that will be used as an upper limit of the image size, in bytes. The suspend-to-disk mechanism will do its best to ensure the image size will not exceed that number. However, if this turns out to be impossible, it will try to suspend anyway using the smallest image possible. In particular, if "0" is written to this file, the suspend image will be as small as possible. Reading from this file will display the current image size limit, which is set to 2/5 of available RAM by default.''<br />
<br />
You may either decrease the value of {{ic|/sys/power/image_size}} to make the suspend image as small as possible (for small swap partitions), or increase it to possibly speed up the hibernation process.<br />
<br />
=== Required kernel parameters ===<br />
<br />
The kernel parameter {{ic|1=resume=''swap_partition''}} has to be used. The configuration depends on the used [[boot loader]], some examples are given below. According to the boot loader configuration, use either kernel name (for example {{ic|/dev/sda1}}), or [[UUID]] path.<br />
<br />
==== Example for GRUB ====<br />
<br />
The kernel name, e.g. {{ic|/dev/sda1}}, can only be used if [[GRUB#Persistent_block_device_naming|Persistent block device naming]] is opted out in GRUB2.<br />
<br />
For example, with [[GRUB]] you can use {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} variable:<br />
<br />
{{hc|/etc/default/grub|2=<br />
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/disk/by-uuid/4209c845-f495-4c43-8a03-5363dd433153"<br />
}}<br />
<br />
Don't forget to run {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} afterwards.<br />
<br />
{{Tip|As an alternative, for GRUB2 you may try this solution from [http://wiki.debian.org/Grub#Configuring_grub_v2 debian wiki], which automatically adds your first swap partition to {{ic|1=resume=}} parameter to all found linux entries.}}<br />
<br />
==== Example for gummiboot ====<br />
<br />
If [[gummiboot]] is used as boot manager, you have to add the {{ic|1=resume=''swap_partition''}} parameter in the options-list of the entry file. <br />
<br />
For example if your efi system partition is mounted in {{ic|/boot}}, then the option list should look like this:<br />
<br />
{{hc|/boot/loader/entries/arch.conf|2=<br />
options root=/dev/sda''X'' rw resume=''swap_partition'' <br />
}}<br />
<br />
==== Hibernation into swap file ====<br />
<br />
Using a swap file instead of a swap partition requires an additional kernel parameter {{ic|1=resume_offset=''swap_file_offset''}}.<br />
<br />
The value of {{ic|''swap_file_offset''}} can be obtained by running {{ic|filefrag -v ''swap_file''}}, the output is in a table format and the required value is located in the first row of the {{ic|physical_offset}} column. For example:<br />
<br />
{{hc|# filefrag -v /swapfile|<nowiki><br />
Filesystem type is: ef53<br />
File size of /swapfile is 4294967296 (1048576 blocks of 4096 bytes)<br />
ext: logical_offset: physical_offset: length: expected: flags:<br />
0: 0.. 0: 38912.. 38912: 1: <br />
1: 1.. 22527: 38913.. 61439: 22527: unwritten<br />
2: 22528.. 53247: 899072.. 929791: 30720: 61440: unwritten<br />
...<br />
</nowiki>}}<br />
<br />
In the example the value of {{ic|''swap_file_offset''}} is {{ic|38912}}.<br />
<br />
{{Tip|The value of {{ic|''swap_file_offset''}} can also be obtained by running {{ic|swap-offset ''swap_file''}}. The ''swap-offset'' binary is provided by package {{AUR|uswsusp-git}}.}}<br />
<br />
{{Note|<br />
* Please note that in the kernel parameter {{ic|resume}} you have to provide the device of the partition that contains the swap file, not swap file itself! The parameter {{ic|resume_offset}} informs the system where the swap file starts on the resume device.<br />
* If using [[uswsusp]], then these two parameters have to be provided in {{ic|/etc/suspend.conf}} via the keys {{ic|resume device}} and {{ic|resume offset}}.<br />
}}<br />
<br />
=== Recreate initial ramdisk ===<br />
<br />
If you use an initramfs (default Arch systems do), you must add the {{ic|resume}} hook into the HOOKS in the configuration of [[mkinitcpio]]:<br />
<br />
{{hc|/etc/mkinitcpio.conf|2=<br />
# resume must be placed after block and lvm2, but before filesystems<br />
HOOKS="... block lvm2 '''resume''' filesystems ..."<br />
}}<br />
<br />
{{Warning|You must not use the [[Mkinitcpio#Common_hooks|systemd hook]], because it does not support resuming from hibernation. See {{Bug|37028}} for details.}}<br />
<br />
Finally, you must rebuild the initrd image for these changes to take effect:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|If you use a custom kernel, then you might have to change the value of the {{ic|-p}} option.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== ACPI_OS_NAME ===<br />
<br />
You might want to tweak your '''DSDT table''' to make it work. See [[DSDT]] article<br />
<br />
=== VAIO Users ===<br />
<br />
Add acpi_sleep=nonvs kernel flag to your loader, and you are done!<br />
<br />
=== Suspend/hibernate doesn't work ===<br />
<br />
There have been many reports about the screen going black without easily viewable errors or the ability to do anything when going into and coming back from suspend and/or hibernate. These problems have been seen on both laptops and desktops. This is not an official solution, but switching to an older kernel, especially the LTS-kernel, will probably fix this.<br />
<br />
=== Display not powering up on resume (radeon) ===<br />
<br />
If you get a blank display after suspension with radeon gpu, try to create {{ic|/etc/pm/config.d/radeon}}, and add the following:<br />
<br />
{{hc|/etc/pm/config.d/radeon|2=<br />
QUIRK_S3_BIOS="true"<br />
QUIRK_S3_MODE="true"<br />
}}<br />
<br />
Of course, this (possible) fix only affects pm-utils (tested with xf86-video-ati and AMD HD740G+7470M).</div>5hafflhttps://wiki.archlinux.org/index.php?title=Power_management/Suspend_and_hibernate&diff=328315Power management/Suspend and hibernate2014-08-03T14:34:16Z<p>5haffl: /* Display not powering up on resume (radeon) */</p>
<hr />
<div>[[Category:Power management]]<br />
[[ja:Suspend and Hibernate]]<br />
{{Related articles start}}<br />
{{Related|Uswsusp}}<br />
{{Related|TuxOnIce}}<br />
{{Related|systemd}}<br />
{{Related|pm-utils}}<br />
{{Related|Suspending to RAM with hibernate-script}}<br />
{{Related|Suspending to Disk with hibernate-script}}<br />
{{Related|Power management}}<br />
{{Related articles end}}<br />
Currently there are three methods of suspending available: '''suspend to RAM''' (usually called just '''suspend'''), '''suspend to disk''' (usually known as '''hibernate'''), and '''hybrid suspend''' (sometimes aptly called '''suspend to both'''):<br />
<br />
* '''Suspend to RAM''' method cuts power to most parts of the machine aside from the RAM, which is required to restore the machine's state. Because of the large power savings, it is advisable for laptops to automatically enter this mode when the computer is running on batteries and the lid is closed (or the user is inactive for some time).<br />
<br />
* '''Suspend to disk''' method saves the machine's state into [[Swap|swap space]] and completely powers off the machine. When the machine is powered on, the state is restored. Until then, there is zero power consumption.<br />
<br />
* '''Suspend to both''' method saves the machine's state into swap space, but does not power off the machine. Instead, it invokes usual suspend to RAM. Therefore, if the battery is not depleted, the system can resume from RAM. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine's state has not been lost.<br />
<br />
There are multiple low level interfaces (backends) providing basic functionality, and some high level interfaces providing tweaks to handle problematic hardware drivers/kernel modules (e.g. video card re-initialization).<br />
<br />
== Low level interfaces ==<br />
<br />
Though these interfaces can be used directly, it is advisable to use some of [[#High level interfaces|high level interfaces]] to suspend/hibernate. Using low level interfaces directly is significantly faster than using any high level interface, since running all the pre- and post-suspend hooks takes time, but hooks can properly set hardware clock, restore wireless etc.<br />
<br />
=== kernel (swsusp) ===<br />
<br />
The most straightforward approach is to directly inform the in-kernel software suspend code (swsusp) to enter a suspended state; the exact method and state depends on the level of hardware support. On modern kernels, writing appropriate strings to {{ic|/sys/power/state}} is the primary mechanism to trigger this suspend.<br />
<br />
See [https://www.kernel.org/doc/Documentation/power/states.txt kernel documentation] for details.<br />
<br />
=== uswsusp ===<br />
<br />
The uswsusp ('Userspace Software Suspend') is a wrapper around the kernel's suspend-to-RAM mechanism, which performs some graphics adapter manipulations from userspace before suspending and after resuming.<br />
<br />
See main article [[Uswsusp]].<br />
<br />
=== tuxonice ===<br />
<br />
TuxOnIce is a fork of the kernel implementation of suspend/hibernate that provides kernel patches to improve the default implementation. It requires a custom kernel to achieve this purpose.<br />
<br />
See main article [[TuxOnIce]].<br />
<br />
== High level interfaces ==<br />
<br />
{{Note|The end goal of these packages is to provide binaries/scripts that can be invoked to perform suspend/hibernate. Actually hooking them up to power buttons or menu clicks or laptop lid events is usually left to other tools. To automatically suspend/hibernate on certain power events, such as laptop lid close or battery depletion percentage, you may want to look into running [[Acpid]].}}<br />
<br />
=== systemd ===<br />
<br />
[[systemd]] provides native commands for suspend, hibernate and a hybrid suspend, see [[Power management#Power management with systemd]] for details.<br />
<br />
See [[Power management#Sleep hooks]] for additional information on configuring suspend/hibernate hooks. Also see {{ic|man systemctl}}, {{ic|man systemd-sleep}}, and {{ic|man systemd.special}}.<br />
<br />
=== pm-utils ===<br />
<br />
pm-utils is a set of shell scripts that encapsulate the backend's suspend/hibernate functionality. It comes with a set of pre- and post-suspend tweaks and various hooks to customize the process.<br />
<br />
See main article [[pm-utils]].<br />
<br />
== Suspend to RAM ==<br />
<br />
Suspend to RAM should work out of the box.<br />
<br />
== Hibernation ==<br />
<br />
In order to use hibernation, you need to create swap partition or swap file. See [[Swap]] for details.<br />
<br />
=== About swap partition/file size ===<br />
<br />
Even if your swap partition is smaller than RAM, you still have a big chance of hibernating successfully. According to [https://www.kernel.org/doc/Documentation/power/interface.txt kernel documentation]:<br />
<br />
: ''{{ic|/sys/power/image_size}} controls the size of the image created by the suspend-to-disk mechanism. It can be written a string representing a non-negative integer that will be used as an upper limit of the image size, in bytes. The suspend-to-disk mechanism will do its best to ensure the image size will not exceed that number. However, if this turns out to be impossible, it will try to suspend anyway using the smallest image possible. In particular, if "0" is written to this file, the suspend image will be as small as possible. Reading from this file will display the current image size limit, which is set to 2/5 of available RAM by default.''<br />
<br />
You may either decrease the value of {{ic|/sys/power/image_size}} to make the suspend image as small as possible (for small swap partitions), or increase it to possibly speed up the hibernation process.<br />
<br />
=== Required kernel parameters ===<br />
<br />
The kernel parameter {{ic|1=resume=''swap_partition''}} has to be used. The configuration depends on the used [[boot loader]], some examples are given below. According to the boot loader configuration, use either kernel name (for example {{ic|/dev/sda1}}), or [[UUID]] path.<br />
<br />
==== Example for GRUB ====<br />
<br />
The kernel name, e.g. {{ic|/dev/sda1}}, can only be used if [[GRUB#Persistent_block_device_naming|Persistent block device naming]] is opted out in GRUB2.<br />
<br />
For example, with [[GRUB]] you can use {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} variable:<br />
<br />
{{hc|/etc/default/grub|2=<br />
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/disk/by-uuid/4209c845-f495-4c43-8a03-5363dd433153"<br />
}}<br />
<br />
Don't forget to run {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} afterwards.<br />
<br />
{{Tip|As an alternative, for GRUB2 you may try this solution from [http://wiki.debian.org/Grub#Configuring_grub_v2 debian wiki], which automatically adds your first swap partition to {{ic|1=resume=}} parameter to all found linux entries.}}<br />
<br />
==== Example for gummiboot ====<br />
<br />
If [[gummiboot]] is used as boot manager, you have to add the {{ic|1=resume=''swap_partition''}} parameter in the options-list of the entry file. <br />
<br />
For example if your efi system partition is mounted in {{ic|/boot}}, then the option list should look like this:<br />
<br />
{{hc|/boot/loader/entries/arch.conf|2=<br />
options root=/dev/sda''X'' rw resume=''swap_partition'' <br />
}}<br />
<br />
==== Hibernation into swap file ====<br />
<br />
Using a swap file instead of a swap partition requires an additional kernel parameter {{ic|1=resume_offset=''swap_file_offset''}}.<br />
<br />
The value of {{ic|''swap_file_offset''}} can be obtained by running {{ic|filefrag -v ''swap_file''}}, the output is in a table format and the required value is located in the first row of the {{ic|physical_offset}} column. For example:<br />
<br />
{{hc|# filefrag -v /swapfile|<nowiki><br />
Filesystem type is: ef53<br />
File size of /swapfile is 4294967296 (1048576 blocks of 4096 bytes)<br />
ext: logical_offset: physical_offset: length: expected: flags:<br />
0: 0.. 0: 38912.. 38912: 1: <br />
1: 1.. 22527: 38913.. 61439: 22527: unwritten<br />
2: 22528.. 53247: 899072.. 929791: 30720: 61440: unwritten<br />
...<br />
</nowiki>}}<br />
<br />
In the example the value of {{ic|''swap_file_offset''}} is {{ic|38912}}.<br />
<br />
{{Tip|The value of {{ic|''swap_file_offset''}} can also be obtained by running {{ic|swap-offset ''swap_file''}}. The ''swap-offset'' binary is provided by package {{AUR|uswsusp-git}}.}}<br />
<br />
{{Note|<br />
* Please note that in the kernel parameter {{ic|resume}} you have to provide the device of the partition that contains the swap file, not swap file itself! The parameter {{ic|resume_offset}} informs the system where the swap file starts on the resume device.<br />
* If using [[uswsusp]], then these two parameters have to be provided in {{ic|/etc/suspend.conf}} via the keys {{ic|resume device}} and {{ic|resume offset}}.<br />
}}<br />
<br />
=== Recreate initial ramdisk ===<br />
<br />
If you use an initramfs (default Arch systems do), you must add the {{ic|resume}} hook into the HOOKS in the configuration of [[mkinitcpio]]:<br />
<br />
{{hc|/etc/mkinitcpio.conf|2=<br />
# resume must be placed after block and lvm2, but before filesystems<br />
HOOKS="... block lvm2 '''resume''' filesystems ..."<br />
}}<br />
<br />
{{Warning|You must not use the [[Mkinitcpio#Common_hooks|systemd hook]], because it does not support resuming from hibernation. See {{Bug|37028}} for details.}}<br />
<br />
Finally, you must rebuild the initrd image for these changes to take effect:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|If you use a custom kernel, then you might have to change the value of the {{ic|-p}} option.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== ACPI_OS_NAME ===<br />
<br />
You might want to tweak your '''DSDT table''' to make it work. See [[DSDT]] article<br />
<br />
=== VAIO Users ===<br />
<br />
Add acpi_sleep=nonvs kernel flag to your loader, and you are done!<br />
<br />
=== Suspend/hibernate doesn't work ===<br />
<br />
There have been many reports about the screen going black without easily viewable errors or the ability to do anything when going into and coming back from suspend and/or hibernate. These problems have been seen on both laptops and desktops. This is not an official solution, but switching to an older kernel, especially the LTS-kernel, will probably fix this.<br />
<br />
=== Display not powering up on resume (radeon) ===<br />
<br />
If you get a blank display after suspension with radeon gpu, try to create {{ic|/etc/pm/config.d/radeon}}, and add the following:<br />
<br />
{{hc|/etc/pm/config.d/radeon|2=<br />
QUIRK_S3_BIOS="true"<br />
QUIRK_S3_MODE="true"<br />
}}<br />
<br />
Of course, this (possible) fix only affects pm-utils, and has been tested with xf86-video-ati.</div>5hafflhttps://wiki.archlinux.org/index.php?title=Power_management/Suspend_and_hibernate&diff=328314Power management/Suspend and hibernate2014-08-03T14:32:26Z<p>5haffl: /* Display not powering up on resume (radeon) */</p>
<hr />
<div>[[Category:Power management]]<br />
[[ja:Suspend and Hibernate]]<br />
{{Related articles start}}<br />
{{Related|Uswsusp}}<br />
{{Related|TuxOnIce}}<br />
{{Related|systemd}}<br />
{{Related|pm-utils}}<br />
{{Related|Suspending to RAM with hibernate-script}}<br />
{{Related|Suspending to Disk with hibernate-script}}<br />
{{Related|Power management}}<br />
{{Related articles end}}<br />
Currently there are three methods of suspending available: '''suspend to RAM''' (usually called just '''suspend'''), '''suspend to disk''' (usually known as '''hibernate'''), and '''hybrid suspend''' (sometimes aptly called '''suspend to both'''):<br />
<br />
* '''Suspend to RAM''' method cuts power to most parts of the machine aside from the RAM, which is required to restore the machine's state. Because of the large power savings, it is advisable for laptops to automatically enter this mode when the computer is running on batteries and the lid is closed (or the user is inactive for some time).<br />
<br />
* '''Suspend to disk''' method saves the machine's state into [[Swap|swap space]] and completely powers off the machine. When the machine is powered on, the state is restored. Until then, there is zero power consumption.<br />
<br />
* '''Suspend to both''' method saves the machine's state into swap space, but does not power off the machine. Instead, it invokes usual suspend to RAM. Therefore, if the battery is not depleted, the system can resume from RAM. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine's state has not been lost.<br />
<br />
There are multiple low level interfaces (backends) providing basic functionality, and some high level interfaces providing tweaks to handle problematic hardware drivers/kernel modules (e.g. video card re-initialization).<br />
<br />
== Low level interfaces ==<br />
<br />
Though these interfaces can be used directly, it is advisable to use some of [[#High level interfaces|high level interfaces]] to suspend/hibernate. Using low level interfaces directly is significantly faster than using any high level interface, since running all the pre- and post-suspend hooks takes time, but hooks can properly set hardware clock, restore wireless etc.<br />
<br />
=== kernel (swsusp) ===<br />
<br />
The most straightforward approach is to directly inform the in-kernel software suspend code (swsusp) to enter a suspended state; the exact method and state depends on the level of hardware support. On modern kernels, writing appropriate strings to {{ic|/sys/power/state}} is the primary mechanism to trigger this suspend.<br />
<br />
See [https://www.kernel.org/doc/Documentation/power/states.txt kernel documentation] for details.<br />
<br />
=== uswsusp ===<br />
<br />
The uswsusp ('Userspace Software Suspend') is a wrapper around the kernel's suspend-to-RAM mechanism, which performs some graphics adapter manipulations from userspace before suspending and after resuming.<br />
<br />
See main article [[Uswsusp]].<br />
<br />
=== tuxonice ===<br />
<br />
TuxOnIce is a fork of the kernel implementation of suspend/hibernate that provides kernel patches to improve the default implementation. It requires a custom kernel to achieve this purpose.<br />
<br />
See main article [[TuxOnIce]].<br />
<br />
== High level interfaces ==<br />
<br />
{{Note|The end goal of these packages is to provide binaries/scripts that can be invoked to perform suspend/hibernate. Actually hooking them up to power buttons or menu clicks or laptop lid events is usually left to other tools. To automatically suspend/hibernate on certain power events, such as laptop lid close or battery depletion percentage, you may want to look into running [[Acpid]].}}<br />
<br />
=== systemd ===<br />
<br />
[[systemd]] provides native commands for suspend, hibernate and a hybrid suspend, see [[Power management#Power management with systemd]] for details.<br />
<br />
See [[Power management#Sleep hooks]] for additional information on configuring suspend/hibernate hooks. Also see {{ic|man systemctl}}, {{ic|man systemd-sleep}}, and {{ic|man systemd.special}}.<br />
<br />
=== pm-utils ===<br />
<br />
pm-utils is a set of shell scripts that encapsulate the backend's suspend/hibernate functionality. It comes with a set of pre- and post-suspend tweaks and various hooks to customize the process.<br />
<br />
See main article [[pm-utils]].<br />
<br />
== Suspend to RAM ==<br />
<br />
Suspend to RAM should work out of the box.<br />
<br />
== Hibernation ==<br />
<br />
In order to use hibernation, you need to create swap partition or swap file. See [[Swap]] for details.<br />
<br />
=== About swap partition/file size ===<br />
<br />
Even if your swap partition is smaller than RAM, you still have a big chance of hibernating successfully. According to [https://www.kernel.org/doc/Documentation/power/interface.txt kernel documentation]:<br />
<br />
: ''{{ic|/sys/power/image_size}} controls the size of the image created by the suspend-to-disk mechanism. It can be written a string representing a non-negative integer that will be used as an upper limit of the image size, in bytes. The suspend-to-disk mechanism will do its best to ensure the image size will not exceed that number. However, if this turns out to be impossible, it will try to suspend anyway using the smallest image possible. In particular, if "0" is written to this file, the suspend image will be as small as possible. Reading from this file will display the current image size limit, which is set to 2/5 of available RAM by default.''<br />
<br />
You may either decrease the value of {{ic|/sys/power/image_size}} to make the suspend image as small as possible (for small swap partitions), or increase it to possibly speed up the hibernation process.<br />
<br />
=== Required kernel parameters ===<br />
<br />
The kernel parameter {{ic|1=resume=''swap_partition''}} has to be used. The configuration depends on the used [[boot loader]], some examples are given below. According to the boot loader configuration, use either kernel name (for example {{ic|/dev/sda1}}), or [[UUID]] path.<br />
<br />
==== Example for GRUB ====<br />
<br />
The kernel name, e.g. {{ic|/dev/sda1}}, can only be used if [[GRUB#Persistent_block_device_naming|Persistent block device naming]] is opted out in GRUB2.<br />
<br />
For example, with [[GRUB]] you can use {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} variable:<br />
<br />
{{hc|/etc/default/grub|2=<br />
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/disk/by-uuid/4209c845-f495-4c43-8a03-5363dd433153"<br />
}}<br />
<br />
Don't forget to run {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} afterwards.<br />
<br />
{{Tip|As an alternative, for GRUB2 you may try this solution from [http://wiki.debian.org/Grub#Configuring_grub_v2 debian wiki], which automatically adds your first swap partition to {{ic|1=resume=}} parameter to all found linux entries.}}<br />
<br />
==== Example for gummiboot ====<br />
<br />
If [[gummiboot]] is used as boot manager, you have to add the {{ic|1=resume=''swap_partition''}} parameter in the options-list of the entry file. <br />
<br />
For example if your efi system partition is mounted in {{ic|/boot}}, then the option list should look like this:<br />
<br />
{{hc|/boot/loader/entries/arch.conf|2=<br />
options root=/dev/sda''X'' rw resume=''swap_partition'' <br />
}}<br />
<br />
==== Hibernation into swap file ====<br />
<br />
Using a swap file instead of a swap partition requires an additional kernel parameter {{ic|1=resume_offset=''swap_file_offset''}}.<br />
<br />
The value of {{ic|''swap_file_offset''}} can be obtained by running {{ic|filefrag -v ''swap_file''}}, the output is in a table format and the required value is located in the first row of the {{ic|physical_offset}} column. For example:<br />
<br />
{{hc|# filefrag -v /swapfile|<nowiki><br />
Filesystem type is: ef53<br />
File size of /swapfile is 4294967296 (1048576 blocks of 4096 bytes)<br />
ext: logical_offset: physical_offset: length: expected: flags:<br />
0: 0.. 0: 38912.. 38912: 1: <br />
1: 1.. 22527: 38913.. 61439: 22527: unwritten<br />
2: 22528.. 53247: 899072.. 929791: 30720: 61440: unwritten<br />
...<br />
</nowiki>}}<br />
<br />
In the example the value of {{ic|''swap_file_offset''}} is {{ic|38912}}.<br />
<br />
{{Tip|The value of {{ic|''swap_file_offset''}} can also be obtained by running {{ic|swap-offset ''swap_file''}}. The ''swap-offset'' binary is provided by package {{AUR|uswsusp-git}}.}}<br />
<br />
{{Note|<br />
* Please note that in the kernel parameter {{ic|resume}} you have to provide the device of the partition that contains the swap file, not swap file itself! The parameter {{ic|resume_offset}} informs the system where the swap file starts on the resume device.<br />
* If using [[uswsusp]], then these two parameters have to be provided in {{ic|/etc/suspend.conf}} via the keys {{ic|resume device}} and {{ic|resume offset}}.<br />
}}<br />
<br />
=== Recreate initial ramdisk ===<br />
<br />
If you use an initramfs (default Arch systems do), you must add the {{ic|resume}} hook into the HOOKS in the configuration of [[mkinitcpio]]:<br />
<br />
{{hc|/etc/mkinitcpio.conf|2=<br />
# resume must be placed after block and lvm2, but before filesystems<br />
HOOKS="... block lvm2 '''resume''' filesystems ..."<br />
}}<br />
<br />
{{Warning|You must not use the [[Mkinitcpio#Common_hooks|systemd hook]], because it does not support resuming from hibernation. See {{Bug|37028}} for details.}}<br />
<br />
Finally, you must rebuild the initrd image for these changes to take effect:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|If you use a custom kernel, then you might have to change the value of the {{ic|-p}} option.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== ACPI_OS_NAME ===<br />
<br />
You might want to tweak your '''DSDT table''' to make it work. See [[DSDT]] article<br />
<br />
=== VAIO Users ===<br />
<br />
Add acpi_sleep=nonvs kernel flag to your loader, and you are done!<br />
<br />
=== Suspend/hibernate doesn't work ===<br />
<br />
There have been many reports about the screen going black without easily viewable errors or the ability to do anything when going into and coming back from suspend and/or hibernate. These problems have been seen on both laptops and desktops. This is not an official solution, but switching to an older kernel, especially the LTS-kernel, will probably fix this.<br />
<br />
=== Display not powering up on resume (radeon) ===<br />
<br />
If you get a blank display after suspension with radeon gpu, try to create {{ic|/etc/pm/config.d/radeon}}, and add the following:<br />
<br />
{{bc|<br />
QUIRK_S3_BIOS="true"<br />
QUIRK_S3_MODE="true"}}<br />
<br />
Of course, this (possible) fix only affects pm-utils, and has been tested with xf86-video-ati.</div>5hafflhttps://wiki.archlinux.org/index.php?title=Power_management/Suspend_and_hibernate&diff=328313Power management/Suspend and hibernate2014-08-03T14:30:42Z<p>5haffl: /* Display not powering up on resume (radeon) */</p>
<hr />
<div>[[Category:Power management]]<br />
[[ja:Suspend and Hibernate]]<br />
{{Related articles start}}<br />
{{Related|Uswsusp}}<br />
{{Related|TuxOnIce}}<br />
{{Related|systemd}}<br />
{{Related|pm-utils}}<br />
{{Related|Suspending to RAM with hibernate-script}}<br />
{{Related|Suspending to Disk with hibernate-script}}<br />
{{Related|Power management}}<br />
{{Related articles end}}<br />
Currently there are three methods of suspending available: '''suspend to RAM''' (usually called just '''suspend'''), '''suspend to disk''' (usually known as '''hibernate'''), and '''hybrid suspend''' (sometimes aptly called '''suspend to both'''):<br />
<br />
* '''Suspend to RAM''' method cuts power to most parts of the machine aside from the RAM, which is required to restore the machine's state. Because of the large power savings, it is advisable for laptops to automatically enter this mode when the computer is running on batteries and the lid is closed (or the user is inactive for some time).<br />
<br />
* '''Suspend to disk''' method saves the machine's state into [[Swap|swap space]] and completely powers off the machine. When the machine is powered on, the state is restored. Until then, there is zero power consumption.<br />
<br />
* '''Suspend to both''' method saves the machine's state into swap space, but does not power off the machine. Instead, it invokes usual suspend to RAM. Therefore, if the battery is not depleted, the system can resume from RAM. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine's state has not been lost.<br />
<br />
There are multiple low level interfaces (backends) providing basic functionality, and some high level interfaces providing tweaks to handle problematic hardware drivers/kernel modules (e.g. video card re-initialization).<br />
<br />
== Low level interfaces ==<br />
<br />
Though these interfaces can be used directly, it is advisable to use some of [[#High level interfaces|high level interfaces]] to suspend/hibernate. Using low level interfaces directly is significantly faster than using any high level interface, since running all the pre- and post-suspend hooks takes time, but hooks can properly set hardware clock, restore wireless etc.<br />
<br />
=== kernel (swsusp) ===<br />
<br />
The most straightforward approach is to directly inform the in-kernel software suspend code (swsusp) to enter a suspended state; the exact method and state depends on the level of hardware support. On modern kernels, writing appropriate strings to {{ic|/sys/power/state}} is the primary mechanism to trigger this suspend.<br />
<br />
See [https://www.kernel.org/doc/Documentation/power/states.txt kernel documentation] for details.<br />
<br />
=== uswsusp ===<br />
<br />
The uswsusp ('Userspace Software Suspend') is a wrapper around the kernel's suspend-to-RAM mechanism, which performs some graphics adapter manipulations from userspace before suspending and after resuming.<br />
<br />
See main article [[Uswsusp]].<br />
<br />
=== tuxonice ===<br />
<br />
TuxOnIce is a fork of the kernel implementation of suspend/hibernate that provides kernel patches to improve the default implementation. It requires a custom kernel to achieve this purpose.<br />
<br />
See main article [[TuxOnIce]].<br />
<br />
== High level interfaces ==<br />
<br />
{{Note|The end goal of these packages is to provide binaries/scripts that can be invoked to perform suspend/hibernate. Actually hooking them up to power buttons or menu clicks or laptop lid events is usually left to other tools. To automatically suspend/hibernate on certain power events, such as laptop lid close or battery depletion percentage, you may want to look into running [[Acpid]].}}<br />
<br />
=== systemd ===<br />
<br />
[[systemd]] provides native commands for suspend, hibernate and a hybrid suspend, see [[Power management#Power management with systemd]] for details.<br />
<br />
See [[Power management#Sleep hooks]] for additional information on configuring suspend/hibernate hooks. Also see {{ic|man systemctl}}, {{ic|man systemd-sleep}}, and {{ic|man systemd.special}}.<br />
<br />
=== pm-utils ===<br />
<br />
pm-utils is a set of shell scripts that encapsulate the backend's suspend/hibernate functionality. It comes with a set of pre- and post-suspend tweaks and various hooks to customize the process.<br />
<br />
See main article [[pm-utils]].<br />
<br />
== Suspend to RAM ==<br />
<br />
Suspend to RAM should work out of the box.<br />
<br />
== Hibernation ==<br />
<br />
In order to use hibernation, you need to create swap partition or swap file. See [[Swap]] for details.<br />
<br />
=== About swap partition/file size ===<br />
<br />
Even if your swap partition is smaller than RAM, you still have a big chance of hibernating successfully. According to [https://www.kernel.org/doc/Documentation/power/interface.txt kernel documentation]:<br />
<br />
: ''{{ic|/sys/power/image_size}} controls the size of the image created by the suspend-to-disk mechanism. It can be written a string representing a non-negative integer that will be used as an upper limit of the image size, in bytes. The suspend-to-disk mechanism will do its best to ensure the image size will not exceed that number. However, if this turns out to be impossible, it will try to suspend anyway using the smallest image possible. In particular, if "0" is written to this file, the suspend image will be as small as possible. Reading from this file will display the current image size limit, which is set to 2/5 of available RAM by default.''<br />
<br />
You may either decrease the value of {{ic|/sys/power/image_size}} to make the suspend image as small as possible (for small swap partitions), or increase it to possibly speed up the hibernation process.<br />
<br />
=== Required kernel parameters ===<br />
<br />
The kernel parameter {{ic|1=resume=''swap_partition''}} has to be used. The configuration depends on the used [[boot loader]], some examples are given below. According to the boot loader configuration, use either kernel name (for example {{ic|/dev/sda1}}), or [[UUID]] path.<br />
<br />
==== Example for GRUB ====<br />
<br />
The kernel name, e.g. {{ic|/dev/sda1}}, can only be used if [[GRUB#Persistent_block_device_naming|Persistent block device naming]] is opted out in GRUB2.<br />
<br />
For example, with [[GRUB]] you can use {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} variable:<br />
<br />
{{hc|/etc/default/grub|2=<br />
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/disk/by-uuid/4209c845-f495-4c43-8a03-5363dd433153"<br />
}}<br />
<br />
Don't forget to run {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} afterwards.<br />
<br />
{{Tip|As an alternative, for GRUB2 you may try this solution from [http://wiki.debian.org/Grub#Configuring_grub_v2 debian wiki], which automatically adds your first swap partition to {{ic|1=resume=}} parameter to all found linux entries.}}<br />
<br />
==== Example for gummiboot ====<br />
<br />
If [[gummiboot]] is used as boot manager, you have to add the {{ic|1=resume=''swap_partition''}} parameter in the options-list of the entry file. <br />
<br />
For example if your efi system partition is mounted in {{ic|/boot}}, then the option list should look like this:<br />
<br />
{{hc|/boot/loader/entries/arch.conf|2=<br />
options root=/dev/sda''X'' rw resume=''swap_partition'' <br />
}}<br />
<br />
==== Hibernation into swap file ====<br />
<br />
Using a swap file instead of a swap partition requires an additional kernel parameter {{ic|1=resume_offset=''swap_file_offset''}}.<br />
<br />
The value of {{ic|''swap_file_offset''}} can be obtained by running {{ic|filefrag -v ''swap_file''}}, the output is in a table format and the required value is located in the first row of the {{ic|physical_offset}} column. For example:<br />
<br />
{{hc|# filefrag -v /swapfile|<nowiki><br />
Filesystem type is: ef53<br />
File size of /swapfile is 4294967296 (1048576 blocks of 4096 bytes)<br />
ext: logical_offset: physical_offset: length: expected: flags:<br />
0: 0.. 0: 38912.. 38912: 1: <br />
1: 1.. 22527: 38913.. 61439: 22527: unwritten<br />
2: 22528.. 53247: 899072.. 929791: 30720: 61440: unwritten<br />
...<br />
</nowiki>}}<br />
<br />
In the example the value of {{ic|''swap_file_offset''}} is {{ic|38912}}.<br />
<br />
{{Tip|The value of {{ic|''swap_file_offset''}} can also be obtained by running {{ic|swap-offset ''swap_file''}}. The ''swap-offset'' binary is provided by package {{AUR|uswsusp-git}}.}}<br />
<br />
{{Note|<br />
* Please note that in the kernel parameter {{ic|resume}} you have to provide the device of the partition that contains the swap file, not swap file itself! The parameter {{ic|resume_offset}} informs the system where the swap file starts on the resume device.<br />
* If using [[uswsusp]], then these two parameters have to be provided in {{ic|/etc/suspend.conf}} via the keys {{ic|resume device}} and {{ic|resume offset}}.<br />
}}<br />
<br />
=== Recreate initial ramdisk ===<br />
<br />
If you use an initramfs (default Arch systems do), you must add the {{ic|resume}} hook into the HOOKS in the configuration of [[mkinitcpio]]:<br />
<br />
{{hc|/etc/mkinitcpio.conf|2=<br />
# resume must be placed after block and lvm2, but before filesystems<br />
HOOKS="... block lvm2 '''resume''' filesystems ..."<br />
}}<br />
<br />
{{Warning|You must not use the [[Mkinitcpio#Common_hooks|systemd hook]], because it does not support resuming from hibernation. See {{Bug|37028}} for details.}}<br />
<br />
Finally, you must rebuild the initrd image for these changes to take effect:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|If you use a custom kernel, then you might have to change the value of the {{ic|-p}} option.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== ACPI_OS_NAME ===<br />
<br />
You might want to tweak your '''DSDT table''' to make it work. See [[DSDT]] article<br />
<br />
=== VAIO Users ===<br />
<br />
Add acpi_sleep=nonvs kernel flag to your loader, and you are done!<br />
<br />
=== Suspend/hibernate doesn't work ===<br />
<br />
There have been many reports about the screen going black without easily viewable errors or the ability to do anything when going into and coming back from suspend and/or hibernate. These problems have been seen on both laptops and desktops. This is not an official solution, but switching to an older kernel, especially the LTS-kernel, will probably fix this.<br />
<br />
=== Display not powering up on resume (radeon) ===<br />
<br />
If you get a blank display after suspension with radeon gpu, try to create {{ic|/etc/pm/config.d/radeon}}, and add the following:<br />
<br />
QUIRK_S3_BIOS="true"<br />
QUIRK_S3_MODE="true"<br />
<br />
Of course, this (possible) fix only affects pm-utils, and has been tested with xf86-video-ati.</div>5hafflhttps://wiki.archlinux.org/index.php?title=Power_management/Suspend_and_hibernate&diff=328312Power management/Suspend and hibernate2014-08-03T14:29:20Z<p>5haffl: /* Troubleshooting */</p>
<hr />
<div>[[Category:Power management]]<br />
[[ja:Suspend and Hibernate]]<br />
{{Related articles start}}<br />
{{Related|Uswsusp}}<br />
{{Related|TuxOnIce}}<br />
{{Related|systemd}}<br />
{{Related|pm-utils}}<br />
{{Related|Suspending to RAM with hibernate-script}}<br />
{{Related|Suspending to Disk with hibernate-script}}<br />
{{Related|Power management}}<br />
{{Related articles end}}<br />
Currently there are three methods of suspending available: '''suspend to RAM''' (usually called just '''suspend'''), '''suspend to disk''' (usually known as '''hibernate'''), and '''hybrid suspend''' (sometimes aptly called '''suspend to both'''):<br />
<br />
* '''Suspend to RAM''' method cuts power to most parts of the machine aside from the RAM, which is required to restore the machine's state. Because of the large power savings, it is advisable for laptops to automatically enter this mode when the computer is running on batteries and the lid is closed (or the user is inactive for some time).<br />
<br />
* '''Suspend to disk''' method saves the machine's state into [[Swap|swap space]] and completely powers off the machine. When the machine is powered on, the state is restored. Until then, there is zero power consumption.<br />
<br />
* '''Suspend to both''' method saves the machine's state into swap space, but does not power off the machine. Instead, it invokes usual suspend to RAM. Therefore, if the battery is not depleted, the system can resume from RAM. If the battery is depleted, the system can be resumed from disk, which is much slower than resuming from RAM, but the machine's state has not been lost.<br />
<br />
There are multiple low level interfaces (backends) providing basic functionality, and some high level interfaces providing tweaks to handle problematic hardware drivers/kernel modules (e.g. video card re-initialization).<br />
<br />
== Low level interfaces ==<br />
<br />
Though these interfaces can be used directly, it is advisable to use some of [[#High level interfaces|high level interfaces]] to suspend/hibernate. Using low level interfaces directly is significantly faster than using any high level interface, since running all the pre- and post-suspend hooks takes time, but hooks can properly set hardware clock, restore wireless etc.<br />
<br />
=== kernel (swsusp) ===<br />
<br />
The most straightforward approach is to directly inform the in-kernel software suspend code (swsusp) to enter a suspended state; the exact method and state depends on the level of hardware support. On modern kernels, writing appropriate strings to {{ic|/sys/power/state}} is the primary mechanism to trigger this suspend.<br />
<br />
See [https://www.kernel.org/doc/Documentation/power/states.txt kernel documentation] for details.<br />
<br />
=== uswsusp ===<br />
<br />
The uswsusp ('Userspace Software Suspend') is a wrapper around the kernel's suspend-to-RAM mechanism, which performs some graphics adapter manipulations from userspace before suspending and after resuming.<br />
<br />
See main article [[Uswsusp]].<br />
<br />
=== tuxonice ===<br />
<br />
TuxOnIce is a fork of the kernel implementation of suspend/hibernate that provides kernel patches to improve the default implementation. It requires a custom kernel to achieve this purpose.<br />
<br />
See main article [[TuxOnIce]].<br />
<br />
== High level interfaces ==<br />
<br />
{{Note|The end goal of these packages is to provide binaries/scripts that can be invoked to perform suspend/hibernate. Actually hooking them up to power buttons or menu clicks or laptop lid events is usually left to other tools. To automatically suspend/hibernate on certain power events, such as laptop lid close or battery depletion percentage, you may want to look into running [[Acpid]].}}<br />
<br />
=== systemd ===<br />
<br />
[[systemd]] provides native commands for suspend, hibernate and a hybrid suspend, see [[Power management#Power management with systemd]] for details.<br />
<br />
See [[Power management#Sleep hooks]] for additional information on configuring suspend/hibernate hooks. Also see {{ic|man systemctl}}, {{ic|man systemd-sleep}}, and {{ic|man systemd.special}}.<br />
<br />
=== pm-utils ===<br />
<br />
pm-utils is a set of shell scripts that encapsulate the backend's suspend/hibernate functionality. It comes with a set of pre- and post-suspend tweaks and various hooks to customize the process.<br />
<br />
See main article [[pm-utils]].<br />
<br />
== Suspend to RAM ==<br />
<br />
Suspend to RAM should work out of the box.<br />
<br />
== Hibernation ==<br />
<br />
In order to use hibernation, you need to create swap partition or swap file. See [[Swap]] for details.<br />
<br />
=== About swap partition/file size ===<br />
<br />
Even if your swap partition is smaller than RAM, you still have a big chance of hibernating successfully. According to [https://www.kernel.org/doc/Documentation/power/interface.txt kernel documentation]:<br />
<br />
: ''{{ic|/sys/power/image_size}} controls the size of the image created by the suspend-to-disk mechanism. It can be written a string representing a non-negative integer that will be used as an upper limit of the image size, in bytes. The suspend-to-disk mechanism will do its best to ensure the image size will not exceed that number. However, if this turns out to be impossible, it will try to suspend anyway using the smallest image possible. In particular, if "0" is written to this file, the suspend image will be as small as possible. Reading from this file will display the current image size limit, which is set to 2/5 of available RAM by default.''<br />
<br />
You may either decrease the value of {{ic|/sys/power/image_size}} to make the suspend image as small as possible (for small swap partitions), or increase it to possibly speed up the hibernation process.<br />
<br />
=== Required kernel parameters ===<br />
<br />
The kernel parameter {{ic|1=resume=''swap_partition''}} has to be used. The configuration depends on the used [[boot loader]], some examples are given below. According to the boot loader configuration, use either kernel name (for example {{ic|/dev/sda1}}), or [[UUID]] path.<br />
<br />
==== Example for GRUB ====<br />
<br />
The kernel name, e.g. {{ic|/dev/sda1}}, can only be used if [[GRUB#Persistent_block_device_naming|Persistent block device naming]] is opted out in GRUB2.<br />
<br />
For example, with [[GRUB]] you can use {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} variable:<br />
<br />
{{hc|/etc/default/grub|2=<br />
GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/disk/by-uuid/4209c845-f495-4c43-8a03-5363dd433153"<br />
}}<br />
<br />
Don't forget to run {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} afterwards.<br />
<br />
{{Tip|As an alternative, for GRUB2 you may try this solution from [http://wiki.debian.org/Grub#Configuring_grub_v2 debian wiki], which automatically adds your first swap partition to {{ic|1=resume=}} parameter to all found linux entries.}}<br />
<br />
==== Example for gummiboot ====<br />
<br />
If [[gummiboot]] is used as boot manager, you have to add the {{ic|1=resume=''swap_partition''}} parameter in the options-list of the entry file. <br />
<br />
For example if your efi system partition is mounted in {{ic|/boot}}, then the option list should look like this:<br />
<br />
{{hc|/boot/loader/entries/arch.conf|2=<br />
options root=/dev/sda''X'' rw resume=''swap_partition'' <br />
}}<br />
<br />
==== Hibernation into swap file ====<br />
<br />
Using a swap file instead of a swap partition requires an additional kernel parameter {{ic|1=resume_offset=''swap_file_offset''}}.<br />
<br />
The value of {{ic|''swap_file_offset''}} can be obtained by running {{ic|filefrag -v ''swap_file''}}, the output is in a table format and the required value is located in the first row of the {{ic|physical_offset}} column. For example:<br />
<br />
{{hc|# filefrag -v /swapfile|<nowiki><br />
Filesystem type is: ef53<br />
File size of /swapfile is 4294967296 (1048576 blocks of 4096 bytes)<br />
ext: logical_offset: physical_offset: length: expected: flags:<br />
0: 0.. 0: 38912.. 38912: 1: <br />
1: 1.. 22527: 38913.. 61439: 22527: unwritten<br />
2: 22528.. 53247: 899072.. 929791: 30720: 61440: unwritten<br />
...<br />
</nowiki>}}<br />
<br />
In the example the value of {{ic|''swap_file_offset''}} is {{ic|38912}}.<br />
<br />
{{Tip|The value of {{ic|''swap_file_offset''}} can also be obtained by running {{ic|swap-offset ''swap_file''}}. The ''swap-offset'' binary is provided by package {{AUR|uswsusp-git}}.}}<br />
<br />
{{Note|<br />
* Please note that in the kernel parameter {{ic|resume}} you have to provide the device of the partition that contains the swap file, not swap file itself! The parameter {{ic|resume_offset}} informs the system where the swap file starts on the resume device.<br />
* If using [[uswsusp]], then these two parameters have to be provided in {{ic|/etc/suspend.conf}} via the keys {{ic|resume device}} and {{ic|resume offset}}.<br />
}}<br />
<br />
=== Recreate initial ramdisk ===<br />
<br />
If you use an initramfs (default Arch systems do), you must add the {{ic|resume}} hook into the HOOKS in the configuration of [[mkinitcpio]]:<br />
<br />
{{hc|/etc/mkinitcpio.conf|2=<br />
# resume must be placed after block and lvm2, but before filesystems<br />
HOOKS="... block lvm2 '''resume''' filesystems ..."<br />
}}<br />
<br />
{{Warning|You must not use the [[Mkinitcpio#Common_hooks|systemd hook]], because it does not support resuming from hibernation. See {{Bug|37028}} for details.}}<br />
<br />
Finally, you must rebuild the initrd image for these changes to take effect:<br />
<br />
# mkinitcpio -p linux<br />
<br />
{{Note|If you use a custom kernel, then you might have to change the value of the {{ic|-p}} option.}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== ACPI_OS_NAME ===<br />
<br />
You might want to tweak your '''DSDT table''' to make it work. See [[DSDT]] article<br />
<br />
=== VAIO Users ===<br />
<br />
Add acpi_sleep=nonvs kernel flag to your loader, and you are done!<br />
<br />
=== Suspend/hibernate doesn't work ===<br />
<br />
There have been many reports about the screen going black without easily viewable errors or the ability to do anything when going into and coming back from suspend and/or hibernate. These problems have been seen on both laptops and desktops. This is not an official solution, but switching to an older kernel, especially the LTS-kernel, will probably fix this.<br />
<br />
=== Display not powering up on resume (radeon) ===<br />
<br />
If you get a blank display after suspension with radeon gpu, try to create {{/etc/pm/config.d/radeon}}, and add the following:<br />
<br />
QUIRK_S3_BIOS="true"<br />
QUIRK_S3_MODE="true"<br />
<br />
Of course, this (possible) fix only affects pm-utils, and has been tested with xf86-video-ati.</div>5haffl