This is an old revision of the document!
Table of Contents
Suspending to RAM or disk
Suspending or hibernating a system is essentially handled by the kernel; some care must be taken, however, with respect to the un- and re-loading of kernel modules.
Manually suspending to RAM
'/sys/power/state' contains values for the possible suspension mechanisms supported by the kernel. If it contains “mem” then the machine supports suspending to RAM. It can be triggered by echoing “mem” into the file. This can only be done with root permission, so issue
echo mem | sudo tee /sys/power/state
If this command should fail then one may need to un-load some kernel modules beforehand. Check dmesg
as well as the system log to find out more (cf. the forum forum to get an idea). See also below for some quirks provided by the PM-tools.
PM-utils
PM-utils is a suite of commands that handle kernel modules in the context of suspending to RAM or disk. The following code prints out the supported methods.
for i in --suspend --hibernate --suspend-hybrid; do pm-is-supported $i && echo "$(echo $i | tr [:lower:] [:upper:] | tr -d -) is supported"; done
Suspending
Suspending to RAM is issued through
sudo pm-suspend
Quirks
pm-suspend
as well as pm-suspend-hybrid
come with some quirks available through –quirk-*
options. See the man-page for details.
Hibernation
PM-utils does hibernation, i.e. suspending to disk, as well and should put the computer safely to sleep. A swap partition must exist, of course, and dCore will detect and use it on its own (unless the NOSWAP boot-code was set).
Boot-Code
In order for the system to know at boot where it should look for hibernation data, the kernel parameter resume=
must be included in the boot stanza. It takes a device file name as parameter. (Contrary to what the above linked docs say, I have been unable to successfully use PARTUUID=<uuid>
or UUID=<uuid>
.)
Selection of swap partition
When several different installations are present on a machine, one single swap partition will not suffice for holding the various hibernation images. Usually, Linux installations use a static '/etc/fstab' where the swap partitions are specified. dCore, however, dynamically generates that file upon system boot and lists any detected swap partition. The list of swap spaces can been read from '/proc/swaps'.
Upon hibernating, dCore risks to over-write the hibernation image of a different installation. To overcome this issue, one can create a separate swap partition for dCore and selectively disable the other swap partitions by adding sudo swapoff <PARTITION>
to '/opt/bootsync.sh'. Options for specifying the partition are listed by swapoff -h
.
Adding menu entries to Openbox for suspending
The commands for suspending and hibernating can be made available through the Openbox menu in a similar fashion to the menu tweaks applied to LXDE. For LXDE itself, a more elaborate outline is available.
First create '~/.config/openbox/pm-utils.xml' with the following content.
<?xml version="1.0" encoding="UTF-8"?> <openbox_menu xmlns="http://openbox.org/3.5/menu"> <menu id="pm-utils-menu" label="PM-Utils"> <item label="Suspend"> <action name="Execute"><command>sudo pm-suspend</command> </action> </item> <item label="Hibernate"> <action name="Execute"> <command>sudo pm-hibernate</command> </action> </item> </menu> </openbox_menu>
Then add a reference to this file in '~/.config/openbox/rc.xml' (or '~/.config/openbox/lxde-rc.xml' when using LXDE). That is, add <file>pm-utils.xml</file>
somewhere to the <menu>
-section (around line 601 in 'rc.xml', line 541 in 'lxde-rc.xml').
Finally, make the menu available by adding the following to the section <menu id=“root-menu” label=“Openbox 3”>
of '~/.config/openbox/menu.xml' at the desired location.
<menu id="pm-utils-menu"/>
After selecting “Reconfigure Openbox” from “System” in the Openbox menu (right-click on the desktop), the new sub-menu is available.