====== 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 [[http://forum.tinycorelinux.net/index.php/topic,16220.msg96173.html#msg96173|forum]] forum to get an idea). See also below for some quirks provided by the PM-tools.
===== PM-utils =====
[[http://manpages.ubuntu.com/manpages/trusty/man8/pm-action.8.html|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 [[http://manpages.ubuntu.com/manpages/bionic/en/man8/pm-suspend.8.html|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 [[https://www.kernel.org/doc/Documentation/kernel-parameters.txt|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='' or ''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 '' to '/opt/bootsync.sh'. Options for specifying the partition are listed by ''swapoff -h''.
==== X-tweaks ====
Start-up scripts under '~/.X.d.' risk not being executed upon wake-up or resume. To have them triggered anew, they need to be executed by pm-utils via a hook. For this purpose, create an executable file '/usr/lib/pm-utils/sleep.d/10XdC' with the following content adapted to your needs:
#!/bin/sh
case "$1" in
hibernate|suspend)
;;
thaw|resume)
~/.X.d/