You are not logged in.
Pages: 1
Topic closed
Hi,
I'm following these instructions:
https://wiki.archlinux.org/index.php/Po … rvice_file
in order to enable hibernation after a period of being in suspend mode.
My problem is that the hibernate 'decision' seems to be one step behind, ie after a period longer than the alarm's SLEEPLENGTH, my laptop wakes, only to instantly hibernate in front of my eyes.
Obviously this is sub-optimal..
How should I go about identifying what is causing the problem?
Editing the wiki article will be a piece of cake in comparison.
Offline
[...], my laptop wakes, only to instantly hibernate in front of my eyes.
If I understand you correctly, then this is what's described in the wiki:
[...] but sets a timer to wake up later to perform hibernation. [...]
What you seem to want would be a combination of "hybrid-sleep" and "delayed hibernation". While this would be a really neat and desirable feature I'm not sure, whether it's possible currently. At least I think it's not what is in the wiki.
What you could do is use hybrid-sleep and after a period of time cut the power manually... Maybe there are other/better ways. I didn't know hybrid-sleep at all until I saw it in the wiki just now.
Personal website: reboot.li
GitHub: github.com/rebootl
Offline
No, what I mean is that before I return to the laptop, it should have already gone into hibernation, as the time is well beyond the SLEEPLENGTH.
When I turn it back on, it shouldn't instantly hibernate again. I presumed that the script is checking whether woken because of an alarm (please hibernate) or not (please don't).
It appears that something is not right.
Last edited by alasdairc (2014-09-16 20:14:55)
Offline
So to be clear, the point of the script is to wake up the machine after N minutes, automatically, and hibernate in order to save power and protect against data loss.
Offline
Ok. I can't look at that in depth right now, but I can see that:
(from the service file in the wiki, executing in a terminal)
(setting SLEEPLENGHT first)
$ SLEEPLENGTH=+2hour
$ echo -n "alarm set for "; date +%%s -d$SLEEPLENGTH | tee $WAKEALARM
(outputs:)
alarm set for %s
(whereas)
$ echo -n "alarm set for "; date +%s -d$SLEEPLENGTH | tee $WAKEALARM
(outputs:)
alarm set for 1410909035maybe the additional % is the problem.
Continue debugging like this e.g. setting $WAKEALARM manually, test whether this works etc.
Personal website: reboot.li
GitHub: github.com/rebootl
Offline
The extra "%" is an escape symbol for the following "%", since systemd uses its own variables set:
┌──────────┬─────────────────────────────────┬─────────────────────────────────┐
│Specifier │ Meaning │ Details │
├──────────┼─────────────────────────────────┼─────────────────────────────────┤
│"%n" │ Full unit name │
│"%%" │ Single percent sign │ Use "%%" in place of "%" to │
│ │ │ specify a single percent sign.
See the specifiers section.
Side note: I am not bothering correcting that format.
Last edited by emeres (2014-09-16 22:31:18)
Offline
Ah, well. Sorry, I missed that.
Thanks
Edit: Still this line somehow fails to write to /sys/class/rtc/rtc0/wakealarm correctly on my system. Edit: Wrong again, I made a mistake, should go to sleep...
Whereas e.g. echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm
(as root) does work...
(Checking by 'cat /sys/class/rtc/rtc0/wakealarm' , use 'echo 0 > /sys/class/rtc/rtc0/wakealarm' to reset.)
Also found this: http://www.mythtv.org/wiki/ACPI_Wakeup# … Fwakealarm
Seems to include useful info, also about disabling hwclock on shutdown (in case it would be enabled) in order for this feature to work.
Good Luck
Last edited by rebootl (2014-09-16 23:16:56)
Personal website: reboot.li
GitHub: github.com/rebootl
Offline
I'll have a look through the mythtv article. Thanks for the help.
Yep the wakealarm is waking the machine after the specified time, however much later on, when I turn it back on manually, the laptop hibernates immediately too.
Offline
Reminds me of the discussion that we had here: https://bbs.archlinux.org/viewtopic.php … 1#p1430561
This feature would be great to be integrated into systemd directly.
Offline
Great link - I'd missed that. will give it a wee read through
Offline
Yep the wakealarm is waking the machine after the specified time, however much later on, when I turn it back on manually, the laptop hibernates immediately too.
I skimmed through the first service, but this indicates some of the timers/variables are not reset unless I misunderstood your "when I turn it back on" phrase. I see no gain in putting the script inside the service file. It can be done, but adds unnecessary risk of format errors. Put [another|the] 'echo 0 > $WAKEALARM;' line before 'systemctl hibernate;' to make sure the alarm is cleared or double check before suspending next time. Maybe you want to take a look at rtcwake.
Offline
Can someone help me?
I created the following file:
~ cat /etc/systemd/system/suspend-to-hibernate.service
[Unit]
Description=Delayed hibernation trigger
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279
Documentation=https://wiki.archlinux.org/index.php/Power_management
Before=suspend.target
Conflicts=hibernate.target hybrid-suspend.target
StopWhenUnneeded=true
[Service]
Type=oneshot
RemainAfterExit=yes
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"
Environment="SLEEPLENGTH=+15mins"
ExecStart=-/usr/bin/sh -c 'echo -n "alarm set for "; date +%%s -d$SLEEPLENGTH | tee $WAKEALARM'
ExecStop=-/usr/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.targetHowever, running it does not trigger any action, nor any error:
~ sudo systemctl start suspend-to-hibernateRunning without sudo obviously fails for privilige reasons:
~ systemctl start suspend-to-hibernate
Failed to start suspend-to-hibernate.service: Access deniedOffline
You don't start it your self, you just enable it. And then it's started/stopped in conjunction with the sleep service.
I'm very slowly debugging my own problem
Offline
I noticed I didn't have NTP enabled, weirdly the computer hadn't drifted a huge amount (few seconds). Have now enabled systemd-timesyncd.
But more relevant - I just saw that my laptop refuses to start from sleep with the lid closed. It's a lenovo X200. The battery light flashes on for a few seconds, then off again after the alarm period. The machine stays in suspend mode, hibernating only after I open the lid manually. So this must be what is causing the issue. The alarm wakes the machine fine if the lid is open.
Offline
I discovered an option in the BIOS which stopped the laptop turning on from RTC alarm while on battery. DIsabling this seems to have improved the situation. The laptop is now going into hibernation mode correctly even with lid closed.
However a couple of times this has failed, leaving the suspend LED indicator (crescent moon) flashing continiously. When this happens I have to hold the power button down to force a power off.
Seems like this is as far as I can get with this so am going to move on and accept what I have.
Offline
X200, no T
Offline
@orschiro - do you have suspend to hibernate working? Are you doing anything differently to the service on the wiki article?
Offline
@alasdairc
Yes, it worked for me. I used exactly the service from the Wiki article.
But it did not provide what I precisely wanted. It put my machine into hibernation on every standby. However, I would like to manually trigger it selectively.
Unfortunately I cannot help you with your issue.
Last edited by orschiro (2014-10-04 18:26:06)
Offline
All,
With the new systemd structure and options, was anyone able to get suspend-then-hibernate working using only settings in
/etc/systemd/sleep.conf?
Using the following options in that file leads to the system not being able to suspend at all:
AllowSuspendThenHibernate=yes
SuspendMode=suspend-then-hibernateEither with SuspendState=suspend-then-hibernate suspension is not enabled.
Being curious I tried SuspendState=mem standby freeze suspend-then-hibernate, but it only leads to suspension in memory and never trying hibernation.
Although the man page
man systemd-sleep.confmentions
SuspendMode=, HibernateMode=, HybridSleepMode=
The string to be written to /sys/power/disk by, respectively, systemd-
suspend.service(8), systemd-hibernate.service(8), systemd-hybrid-
sleep.service(8), or systemd-suspend-then-hibernate.service(8). More
than one value can be specified by separating multiple values with
whitespace. They will be tried in turn, until one is written without
error. If neither succeeds, the operation will be aborted.SuspendState=, HibernateState=, HybridSleepState=
The string to be written to /sys/power/state by, respectively, systemd-
suspend.service(8), systemd-hibernate.service(8), systemd-hybrid-
sleep.service(8), or systemd-suspend-then-hibernate.service(8). More
than one value can be specified by separating multiple values with
whitespace. They will be tried in turn, until one is written without
error. If neither succeeds, the operation will be aborted.
it seems that suspend-then-hibernate is not a valid value neither for /sys/power/disk nor /sys/power/state
This issue shows an effective solution by symlinking the services:
ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.serviceThe same forum mentions that KDE should show a new option for Suspend then hibernate for PowerDevil 5.17, but as of 9-Nov-19 and v5.17.2, it is still not available.
Offline
Please don't necrobump a 5 year old thread make your own thread if you have a question regarding this and link back here if you feel it to be relevant.
Closing.
Offline
Pages: 1
Topic closed