wiki.debian.org Open in urlscan Pro
2001:41b8:202:deb:6564:a62:52c3:4b70  Public Scan

URL: https://wiki.debian.org/SystemdSuspendSedation
Submission: On June 14 via api from RU — Scanned from DE

Form analysis 2 forms found in the DOM

GET /SystemdSuspendSedation

<form id="searchform" method="get" action="/SystemdSuspendSedation">
  <div>
    <input type="hidden" name="action" value="fullsearch">
    <input type="hidden" name="context" value="180">
    <label for="searchinput" style="display: none;">Suchen:</label>
    <input id="searchinput" type="text" name="value" value="" size="20" onfocus="searchFocus(this)" onblur="searchBlur(this)" onkeyup="searchChange(this)" onchange="searchChange(this)" alt="Search" class="disabled">
    <input id="titlesearch" name="titlesearch" type="submit" value="Titel" alt="Search Titles" disabled="">
    <input id="fullsearch" name="fullsearch" type="submit" value="Text" alt="Search Full Text" disabled="">
  </div>
</form>

GET /SystemdSuspendSedation

<form class="actionsmenu" method="GET" action="/SystemdSuspendSedation">
  <div>
    <select name="action" onchange="if ((this.selectedIndex != 0) &amp;&amp;
                      (this.options[this.selectedIndex].disabled == false)) {
                this.form.submit();
            }
            this.selectedIndex = 0;">
      <option value="show">Weitere Aktionen:</option>
      <option value="raw">Rohform</option>
      <option value="print">Druckansicht</option>
      <option value="RenderAsDocbook">Als Docbook ausgeben</option>
      <option value="refresh">Cache löschen</option>
      <option value="show" disabled="" class="disabled">-----------------------------------</option>
      <option value="SpellCheck">Rechtschreibung prüfen</option>
      <option value="LikePages">Ähnliche Seiten</option>
      <option value="LocalSiteMap">ÜbersichtsKarte</option>
      <option value="show" disabled="" class="disabled">-----------------------------------</option>
      <option value="RenamePage" disabled="" class="disabled">Seite umbenennen</option>
      <option value="DeletePage" disabled="" class="disabled">Seite löschen</option>
      <option value="show" disabled="" class="disabled">-----------------------------------</option>
      <option value="show" disabled="" class="disabled">Abo für Benutzer</option>
      <option value="show" disabled="" class="disabled">-----------------------------------</option>
      <option value="show" disabled="" class="disabled">Spam entfernen</option>
      <option value="show" disabled="" class="disabled">Diese Revision restaurieren</option>
      <option value="PackagePages">Seiten einpacken</option>
      <option value="show" disabled="" class="disabled">-----------------------------------</option>
      <option value="Load">Laden</option>
      <option value="Save">Speichern</option>
      <option value="SlideShow">SlideShow</option>
    </select>
  </div>
  <script type="text/javascript">
    <!--// Init menu
    actionsMenuInit('Weitere Aktionen:');
    //
    -->
  </script>
</form>

Text Content

Wiki

Anmelden
 * StartSeite
 * AktuelleÄnderungen
 * SeiteFinden
 * HilfeInhalt
 * SystemdSuspendSedation

Suchen:

Wiki/
 * Anmelden
 * Kommentare
 * Info
 * Dateianhänge
 * Weitere Aktionen:Rohform Druckansicht Als Docbook ausgeben Cache löschen
   ----------------------------------- Rechtschreibung prüfen Ähnliche Seiten
   ÜbersichtsKarte ----------------------------------- Seite umbenennen Seite
   löschen ----------------------------------- Abo für Benutzer
   ----------------------------------- Spam entfernen Diese Revision
   restaurieren Seiten einpacken ----------------------------------- Laden
   Speichern SlideShow

 * SYSTEMDSUSPENDSEDATION

Note: This might be outdated, systemd supports "suspend-then-hibernate" at least
since bookworm. See systemctl(1).

This page explains how to have a laptop first Suspend to RAM then after a some
time save state to disk and power off completely. Inhibiting a system from
suspending/hibernating is explained at Suspend.




SUSPEND ON LID CLOSE

In order to trigger suspend on closing the lid, make sure that there is a line
in /etc/systemd/logind.conf that reads HandleLidSwitch=suspend, and that it is
not commented out (prefixed with #).

The default values are :

 * HandleLidSwitch=suspend

 * HandleLidSwitchDocked=ignore

Example logind.conf:



# /etc/systemd/logind.conf
[Login]
HandleLidSwitch=suspend
HandleLidSwitchDocked=suspend
# All default lines with comments removed for clarity.

After making the change to logind.conf, run
systemctl restart systemd-logind.service. After doing so closing the laptop's
lid should cause the laptop to suspend..

If you are running a simple xsession, and want to make sure your screen locks on
suspend, you can install the xscreensaver and xss-lock packages, and add the
lines:



xscreensaver &
xss-lock -- xscreensaver-command --lock &

to your .xsession-file




FROM SUSPEND TO HIBERNATE

When the laptop suspends to ram, it uses very little power, but the current
session is not persisted to disk, so if the battery runs out, the system will be
forced to do a full boot on resume. There are two ways around this: the
classical way is hybrid-sleep: when suspending the machine also writes current
state to disk, as with hibernate — so if power runs out no data is lost, and the
session can be resumed.

Unfortunately hibernate, even with an solid-state drive, takes longer than
entering suspend — and this can be inconvenient at times.

We can use the real-time wake timer to allow the system to wake up from sleep
and go straight back to hibernation — if the system has been suspended for a
given amount of time. With systemd, we can do this via a service unit; create
the file /etc/systemd/system/suspend-sedation.service consisting of the
following:



# /etc/systemd/system/suspend-sedation.service
[Unit]
Description=Hibernate after suspend
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1574125#p1574125
Documentation=https://wiki.archlinux.org/index.php/Power_management
Documentation=http://forums.debian.net/viewtopic.php?f=5&t=129088
Documentation=https://wiki.debian.org/SystemdSuspendSedation
Conflicts=hibernate.target hybrid-sleep.target
Before=sleep.target
StopWhenUnneeded=true

[Service]
Type=oneshot
RemainAfterExit=yes
Environment="ALARM_SEC=300"
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"

ExecStart=/usr/sbin/rtcwake --seconds $ALARM_SEC --auto --mode no
ExecStop=/bin/sh -c '\
ALARM=$(cat $WAKEALARM); \
NOW=$(date +%%s); \
if [ -z "$ALARM" ] || [ "$NOW" -ge "$ALARM" ]; then \
  echo "suspend-sedation: Woke up - no alarm set. Hibernating..."; \
  systemctl hibernate; \
else \
  echo "suspend-sedation: Woke up before alarm - normal wakeup."; \
  /usr/sbin/rtcwake --auto --mode disable; \
fi \
'

[Install]
WantedBy=sleep.target

After creating this file, enable it: sudo systemctl enable suspend-sedation. Now
you should be able to enter suspend-mode, either by closing the lid, or via
systemctl suspend, and have the system suspend immediately, and be ready to wake
up quickly for 5 minutes (300 seconds). After that time, the system should
briefly wake up on its own, and immediately hibernate.

In order to see the messages logged by this unit, either use
journalctl -u suspend-sedation, or look in /var/log/daemon.log for lines
containing "suspend-sedation".

This solution is inspired by:
https://bbs.archlinux.org/viewtopic.php?pid=1256340, but uses the rtcwake
command from the util-linux package (an essential package, it should be
installed on all Debian systems by default). The --auto flag adjusts for the
situation where the real-time clock might *not* be set to UTC — this is commonly
the case on systems that dual-boot Microsoft Windows, for example.



SystemdSuspendSedation (zuletzt geändert 2023-08-30 06:50:53)

 * Debian privacy policy, Wiki team, bugs and config.
 * Powered by MoinMoin and Python, with hosting provided by Metropolitan Area
   Network Darmstadt.