5

I use Debian Jessie and want to use uswsusp for stanby/Hibernation. Installing and configuring is no problem and it also works when you execute s2disk manually. However with systemd the system seem to have changed drastically. Older explanations replacing pm-* files or similar do not work.
Also the official wiki does not help as the documentation there is way to less to be helpful.

How to hibernate in Debian Jessie is strongly related to this question, but there - however - only a fix is shown for the particular problem the user has without explaining how to use uswsusp. However in one answer the sleep.conf is mentioned (I just doubt "shutdown" is the right entry to set there as we ... well... don't want to shutdown, but to hibernate).

So this file seems to be a good thing where you might change the hibernation system, but the man file is confusing and I don't get what I have to put in there.

Extra: Also explain how to use it first hybrid-sleep (or "Suspend Sedation" or how you'll call it) too.

  • I just installed it on my old notebook with ubuntu 16.04 (that has no replacement battery), I didnt even command it to suspend/hybernate... when I tried to boot it again (after shutdown), the only way I managed workaround the endless boot (that shows not log on pressing ESC) to be able to login was to: reboot in recovery; wait a huge lot until a message appeared, pressed ENTER and asked for a terminal, and apt uswsusp remove. :(, that problem didnt happen on my desktop ubuntu 14.04 – Aquarius Power Apr 6 '17 at 21:36
7

In order to use s2disk with systemd in Debian, you must:

  • Edit the hibernation service, with

    sudo systemctl edit systemd-hibernate.service
    
  • Paste the following code

    [Service]
    ExecStart=
    ExecStartPre=-/bin/run-parts -v -a pre /usr/lib/systemd/system-sleep
    ExecStart=/usr/sbin/s2disk
    ExecStartPost=-/bin/run-parts -v --reverse -a post /usr/lib/systemd/system-sleep
    
  • Update systemd

    $ sudo systemctl daemon-reload
    
  • Nown run

    $ sudo systemctl hibernate
    
  • 2
    On some systems (Ubuntu 18.04 upgraded from Ubuntu 16.04, and maybe other distributions), the pre/post scripts are in /lib/systemd/system-sleep, not /usr/lib/systemd/system-sleep. Setting this path incorrectly in the hibernation service causes run-parts to fail silently. – ysalmon Aug 18 '18 at 7:16
  • One should also add -a hibernate after -a pre resp. -a post because some scripts check their second argument and behave differently eg. on suspend and hibernation. – ysalmon Aug 18 '18 at 11:37
  • @ysalmon you're so right! that path doesn't exist in my 18.04LTS. – Willian Paixao Nov 15 '18 at 10:55
  • Hi, I am trying to use your solution to run pm-hibernate command instead of s2disk, since that's the only one that successfully puts my machine into hibernation without blank screens etc. But it doesn't work. I just changed the ExecStart=/usr/sbin/s2disk line to ExecStart=/usr/sbin/pm-hibernate, but when I run systemctl hibernate I see a different behavior from just launching pm-hibernate from the terminal. Why does that happen? – Francesco Boccardo Mar 3 at 16:06
0

Read: https://www.kernel.org/doc/Documentation/power/basic-pm-debugging.txt

And: https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html

So 'shutdown' is a good solution for desktops which don't have lids you can lift to trigger a resume. It basically means when the hibernate image is written to disk, shutdown. Then when you hit power the kernel looks for a hibernate image and tries to use it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.