You are not logged in.
Pages: 1
Hello,
I am a new laptop owner (and new Archlinux user).
On its original operating system, my laptop has a feature which basically does:
1- suspend to RAM
2- after 1 hour in this suspend mode, it wakes up briefly and suspend to disk
I found many wiki pages about suspending either to disk or to RAM or even both, like https://wiki.archlinux.org/index.php/Su … _Hibernate and that works fine with my laptop.
But none gave me a solution with this kind of behavior.
Note that this is different from "hybrid-sleep" which suspend to RAM and disk at the same time and use disk save in case the battery if emptied.
I see many benefits from what I look for:
- very fast suspend (on lid close for instance);
- if I re-open the lid within the hour, very quick restore;
- if I let the laptop as it is, I know it will automatically suspend to disk and thus I do not worry about battery usage;
- compared to hybrid-sleep, if I forget my laptop in sleep mode, the battery state will be about the same as when I stopped working, whereas hybrid-sleep needs a recharge.
So, do you know if it is possible to suspend to RAM and later to disk on Archlinux?
Any pointers on how to do so?
Thanks!
Last edited by cjlano (2013-04-08 20:53:38)
Offline
Recently https://bbs.archlinux.org/viewtopic.php?id=160895 was posted - it links to a pm-utils script.
Last edited by lucke (2013-04-08 21:28:14)
Offline
Thanks for the link, I did not see it.
However, no answers for him yet about a systemd way to deal with "suspend sedation".
Does anybody made a systemd "script" to make that very function?
Offline
Hello,
Here is my solution for a Archlinux / systemd "suspend sedation" based on http://askubuntu.com/questions/12383/ho … -hibernate
The following script is a Systemd sleep hook. It uses a RTC wake up event (rtcwake) to get out of suspend state and go to hibernate state. If the system leaves suspend state before the RTC event, the RTC wake is cancelled.
Save the following code in /usr/lib/systemd/system-sleep/suspend-sedation.sh, and make it executable.
#!/bin/bash
# Purpose: Auto hibernates after a period of sleep
# Edit the "autohibernate" variable below to set the number of seconds to sleep.
lockfile=/var/run/systemd/rtchibernate.lock
curtime=$(date +%s)
# 30 min
autohibernate=1800
case $1/$2 in
pre/suspend)
# Suspending. Record current time, and set a wake up timer.
echo "Suspending until" `date -d "$autohibernate seconds"`
echo "$curtime" > $lockfile
rtcwake -m no -s $autohibernate
;;
post/suspend)
# Coming out of sleep
sustime=$(cat $lockfile)
echo -n "Back from suspend... "
rm $lockfile
# Did we wake up due to the rtc timer above?
if [ $(($curtime - $sustime)) -ge $autohibernate ]
then
# Then hibernate
echo "hibernate"
/usr/bin/systemctl hibernate
else
echo "wake-up"
# Otherwise cancel the rtc timer and wake up normally.
rtcwake -m disable
fi
;;
esac
This script outputs some log you can view using
journalctl -b -u systemd-suspend
Any improvements welcome!
Offline
Thanks, cjlano! The script works really great!
Offline
I copied the script and made it executable but it is not working, should I add it as a service at startup or what?
Offline
For anyone else following along, I did the same thing, but in a systemd unit, and without rtcwake:
[Unit]
Description=delayed hibernation trigger
Before=suspend.target
StopWhenUnneeded=true
[Service]
Type=oneshot
RemainAfterExit=yes
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"
ExecStart=-/bin/sh -c 'echo -n "alarm set for "; date +%%s -d+1hour | tee $WAKEALARM'
ExecStop=-/bin/sh -c '\
alarm=$(cat $WAKEALARM); \
now=$(date +%%s); \
if [ -z "$alarm" ] || [ "$now" -ge "$alarm" ]; then \
echo "hibernate triggered"; \
systemctl hibernate; \
else \
echo "normal wakeup"; \
fi; \
echo 0 > $WAKEALARM; \
'
[Install]
WantedBy=sleep.target
Drop that into '/etc/systemd/system/suspend-to-hibernate.service' and then 'systemctl enable suspend-to-hibernate'.
It's been working well for me.
Offline
I had some issues with getting this to work without rtcwake, probably beacuse my system dualboots windows (and Debian Jessie) - and so the real-time clock isn't in UTC. I documented a solution that works for me, here: https://wiki.debian.org/SystemdSuspendSedation.
Offline
Hi!
First of all this is a necrobump but no one posted the right answer to the original question, so here it is, maybe someone will find it useful after stumbling on this thread.
What cjlano was interested in is called Intel Rapid Start and this is how you enable it on Linux:
Offline
Thank you for the link to Rapid Start. As pointed out in that link, it doesn't work (in a sane/safe) way with full disk encryption. While the drive is "at risk" for as long as the laptop is in "suspend", and for a while after (cold boot attack) with either solution -- after having been powered off for a while with classic hibernation (assuming swap is on an encrypted volume, like lvm on top of luks) -- the solution with systemd is better.
I really do appreciate the link - but personally I consider not using full disk encryption to be deprecated. It can be convenient on servers, but as personal computers of all sizes increasingly have SSDs, which (depending on internal details) can be hard or impossible to erase with confidence -- not using encryption simply isn't a very sound idea.
Offline
I'd been using the rtcwake technique for a while, but in October 2015, after updating my system, it stopped working. My other scripts in /usr/lib/systemd/system-sleep run fine, so I'm wondering if something changed with rtcwake. If anyone has made this approach work with an up-to-date version of arch, please share what you had to do. Thanks.
Offline
The rctwake version (the version from the wiki) workes fine for me on an up to date arch.
Nov 04 23:20:56 hostname systemd[1]: Starting Delayed hibernation trigger...
Nov 04 23:20:56 hostname systemd[1]: Reached target Sleep.
Nov 04 23:20:56 hostname systemd[1]: Starting Suspend...
Nov 04 23:20:56 hostname sh[4429]: alarm set for 1446677456
Nov 04 23:20:56 hostname systemd[1]: Started Delayed hibernation trigger.
Nov 04 23:20:56 hostname systemd-sleep[4430]: rmmod: ERROR: Module i915 is in use
Nov 04 23:20:56 hostname systemd-sleep[4431]: /usr/lib/systemd/system-sleep/suspend-modules failed with error code 1.
Nov 04 23:20:56 hostname systemd-sleep[4430]: Suspending until Mit Nov 4 23:50:56 CET 2015
Nov 04 23:20:56 hostname systemd-sleep[4430]: rtcwake: assuming RTC uses UTC ...
Nov 04 23:20:56 hostname systemd-sleep[4430]: rtcwake: wakeup using /dev/rtc0 at Wed Nov 4 22:50:58 2015
Nov 04 23:20:56 hostname systemd-sleep[4430]: Suspending system...
Offline
I have another problem with the script. It seems it executes right, but after the wakeup it doesn't hibernate due to a already running sleep operation.
# systemctl status -l suspend-to-hibernate.service
Nov 21 12:38:19 kabbonenote systemd[1]: Starting Delayed hibernation trigger...
Nov 21 12:38:19 kabbonenote sh[1279]: alarm set for 1448106019
Nov 21 12:38:19 kabbonenote systemd[1]: Started Delayed hibernation trigger.
Nov 21 12:40:19 kabbonenote systemd[1]: suspend-to-hibernate.service: Unit not needed anymore. Stopping.
Nov 21 12:40:19 kabbonenote systemd[1]: Stopping Delayed hibernation trigger...
Nov 21 12:40:19 kabbonenote sh[1390]: hibernate triggered
Nov 21 12:40:29 kabbonenote sh[1390]: Failed to hibernate system via logind: There's already a shutdown or sleep operation in progress
Nov 21 12:40:29 kabbonenote systemd[1]: Stopped Delayed hibernation trigger.
Any ideas?
EDIT: I already tried a 10 sec sleep before the execution of hibernate, but also didn't work.
Last edited by Kabbone (2015-11-21 14:42:22)
Offline
I have another problem with the script. It seems it executes right, but after the wakeup it doesn't hibernate due to a already running sleep operation.
# systemctl status -l suspend-to-hibernate.service Nov 21 12:38:19 kabbonenote systemd[1]: Starting Delayed hibernation trigger... Nov 21 12:38:19 kabbonenote sh[1279]: alarm set for 1448106019 Nov 21 12:38:19 kabbonenote systemd[1]: Started Delayed hibernation trigger. Nov 21 12:40:19 kabbonenote systemd[1]: suspend-to-hibernate.service: Unit not needed anymore. Stopping. Nov 21 12:40:19 kabbonenote systemd[1]: Stopping Delayed hibernation trigger... Nov 21 12:40:19 kabbonenote sh[1390]: hibernate triggered Nov 21 12:40:29 kabbonenote sh[1390]: Failed to hibernate system via logind: There's already a shutdown or sleep operation in progress Nov 21 12:40:29 kabbonenote systemd[1]: Stopped Delayed hibernation trigger.
Any ideas?
EDIT: I already tried a 10 sec sleep before the execution of hibernate, but also didn't work.
The problem you mentioned had been introduced in Systemd 227 (still broken in 228).
As this topic comes quite high on google, I thought I post the answers here.
Arch wiki been updated: https://bbs.archlinux.org/viewtopic.php?id=204346
Full description and solution is here: https://bbs.archlinux.org/viewtopic.php?id=204346
TL;DR for those busy people out there:
# cp -p /usr/lib/systemd/system/suspend.target /etc/systemd/system/
# echo 'Requires=suspend-to-hibernate.service' >> /etc/systemd/system/suspend.target
# systemctl daemon-reload
be sure you use the latest suspend-to-hibernate.service from wiki. The one with:
Conflicts=hibernate.target hybrid-suspend.target
Offline
Thanks, it worked . Actually I saw the other thread and I don't know why I haven't tried it :-/
Offline
for anyone wondering (and since this thread is given as the 'official' url for this service): systemd 229 which has been in [core] since yesterday breaks the unit, because the '%%' specifier is currently broken. the issue has been fixed upstream and will likely be in the next release. in the meanwhile, downgrading seems to be the only workaround (putting this into a separate script might work as well?).
Offline
for anyone wondering (and since this thread is given as the 'official' url for this service): systemd 229 which has been in [core] since yesterday breaks the unit, because the '%%' specifier is currently broken. the issue has been fixed upstream and will likely be in the next release. in the meanwhile, downgrading seems to be the only workaround (putting this into a separate script might work as well?).
Thank you so much for this. I've been pulling my hair out trying to fix hibernation on my laptop.
Seems like every update to systemd introduces new quirks to my system. Almost brings out the debian-user in me.
Offline
Hi,
is this still an issue with the current systemd (229-3)? Should I keep ignoring the update until 230?
Thanks
Offline
Hi,
is this still an issue with the current systemd (229-3)? Should I keep ignoring the update until 230?
Thanks
I answer myself. The script seems to be working again with systemd-229-3
Offline
Pages: 1