Debian – How to use uswsusp for standby/hibernation with systemd? (Debian)

debianhibernateshutdownsystemd

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.

Best Answer

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
    
Related Question