How do I use pm-suspend-hybrid by default instead of pm-suspend?
Indirect hybrid sleep
This is the older method: first suspend and then wake up to hibernate after a delay (15 minutes by default). Use this with a Linux kernel before 3.6, or if you like that it does not use any power after 15 minutes any more.
Add the file /etc/pm/config.d/00-use-suspend-hybrid
:
# Always use suspend_hybrid instead of suspend
if [ "$METHOD" = "suspend" ]; then
METHOD=suspend_hybrid
fi
# The delay after which hibernation gets triggered (default: 900 seconds, 15 minutes):
PM_HIBERNATE_DELAY=900
You might want to make sure that the hybrid method is supported on your system via the following code. If it says "0" it should work:
sudo pm-is-supported --suspend-hybrid && echo $?
Real hybrid suspending with Linux 3.6+
If you have a Linux 3.6 kernel, you can use the following, which will suspend to both disk and RAM from the beginning.
Add the file /etc/pm/config.d/00-use-suspend-hybrid
:
# WORKAROUND: always set the default hibernate mode first (normal mode)
# (not required if you have the patch mentioned by Rohan below (http://askubuntu.com/a/344879/169))
HIBERNATE_MODE=platform
# Always use hibernate instead of suspend, but with "suspend to both"
if [ "$METHOD" = "suspend" ]; then
METHOD=hibernate
HIBERNATE_MODE=suspend
fi
# Make sure to use the kernel's method, in case uswsusp is installed etc.
SLEEP_MODULE=kernel
This will always write the image to disk and then suspend to RAM, having the benefits that resuming will always be fast (as long as the battery does not run out) and that the machine will not wake up for a short time (after PM_HIBERNATE_DELAY) to hibernate for real.
The drawback is that the process takes longer (because it always hibernates to disk), and that your battery might run out in the long run (e.g. after 12 hours).
- Corresponding blog post (not updated)
Ubuntu 18.04 a timed option
In Ubuntu 18.04 has has a new timed option. In systemd
is availiable a new mode suspend-then-hibernate
. This will start with the sleep mode and then transition to the hibernate mode after a fixed time.
In the hybrid-sleep
mode, the hibernate part gets effective only when the battery is critically low and the system shuts down.
To start using this function you need to create a file /etc/systemd/sleep.conf
with the next content:
[Sleep]
HibernateDelaySec=3600
This will go from sleep to hibernate after 1 hour of sleep. You can edit HibernateDelaySec
to change the delay to hibernate.
First, test if suspend-then-hibernate works using systemd
Open a terminal by pressing Ctrl+Alt+T and enter:
sudo systemctl suspend-then-hibernate
If it works make it permanent.
- The following works when I close the lid.
Open the file /etc/systemd/logind.conf
using your preferred editor. You will need to invoke your administrative power by sudo
, gksudo
or pkexec
to edit this file.
Find the two lines:
#HandleSuspendKey=suspend
#HandleLidSwitch=suspend
Note, These lines are commented out with #
in front of them. The suspend
is the default action. Remove the #
and change suspend
to suspend-then-hibernate
in these two lines so that they look like this:
HandleSuspendKey=suspend-then-hibernate
HandleLidSwitch=suspend-then-hibernate
Save the file. Log out and log back in or restart logind
service by the command:
systemctl restart systemd-logind.service
warning! your user session will be restarted
Source: Lid Closed Suspend then Hibernate
Ubuntu 16.04 and above
The solution by blueyed for Real hybrid suspending with Linux 3.6+ did not work for me. I suspect this is because Ubuntu 16.04 uses systemd
and does not use the file /etc/pm/config.d/00-use-suspend-hybrid
.
First, test if hibernate and hybrid-sleep works using systemd
Open a terminal by pressing Ctrl+Alt+T and enter:
sudo systemctl hibernate
This should get your computer to hibernate. To try hybrid-sleep, enter:
sudo systemctl hybrid-sleep
If it works make it permanent.
- The following works when I close the lid.
Open the file /etc/systemd/logind.conf
using your preferred editor. You will need to invoke your administrative power by sudo
, gksudo
or pkexec
to edit this file.
Find the two lines:
#HandleSuspendKey=suspend
#HandleLidSwitch=suspend
Note, These lines are commented out with #
in front of them. The suspend
is the default action. Remove the #
and change suspend
to hybrid-sleep
in these two lines so that they look like this:
HandleSuspendKey=hybrid-sleep
HandleLidSwitch=hybrid-sleep
Save the file. Log out and log back in.
Note:
- Other than
suspend
orhybrid-sleep
there is a third option,hibernate
. - My laptop does not have a physical sleep button. So I could not test it.
- Clicking on the
Suspend
from the cog menu puts the computer to normal suspend not hybrid-sleep.
Source: https://superuser.com/questions/719447/how-to-use-systemd-hybrid-sleep-instead-of-suspend-under-gnome-in-linux
I hope this helps
In 12.04 I noticed that when hibernation is triggered (using PM_HIBERNATE_DELAY=XX
), the resume/thaw the shell scripts do not unset the grub recordfail variable. Therefore grub does not autoboot.
Timeout is set to -1 and it awaits user selection. I am guessing this requires some editing of scripts in /etc/pm/sleep.d/10_grub-common
. Am a novice so I haven't dabbled to figure out the exact change unfortunately.