0

I would like hybrid suspend to act a certain way.

If I add the code

# Always use suspend_hybrid instead of suspend
if [ "$METHOD" = "suspend" ]; then
METHOD=suspend_hybrid
fi
PM_HIBERNATE_DELAY=XX

to

/etc/pm/config.d/00-use-suspend-hybrid

where XX is the number of seconds until the computer hibernates, does XX indicate the number of seconds until the computer writes the state of the RAM to the disk, or until the computer actually goes into hibernation mode, or both?

I would like to use a hybrid suspend in which when I close the lid of my laptop, the state of the RAM is both written to the disk and kept in the RAM at the time that I close the lid of the laptop, and then after the XX seconds the computer actually goes into hibernate (drops the contents of the RAM from the RAM). If this is not what the above code does, can someone give me the code that will do this? Thanks!

Code taken from this question: How do I use pm-suspend-hybrid by default instead of pm-suspend?

UPDATE: I tested this for myself by simply taking out the battery of my laptop about thirty seconds after using hybrid suspend by closing the lid. When I started back up, the system booted as it would normally. This also occurred when I omitted the

PM_HIBERNATE_DELAY=XX

line and when I ran

sudo pm-suspend-hybrid

from the terminal. Therefore, It can be concluded that the system does NOT write the state of the RAM to the disk as soon as it suspends.

Am I correct in this assumption?

If I am, I would like to know how to make hybrid suspend write the state of the RAM to the disk when the computer suspends, not after the timer expires.

I know that this question is out of vanity more than anything, but it has been posted for a month with not even a comment. Is there someplace anybody knows of that I can go where I might be able to come up with a solution for myself?

Josh
  • 708

3 Answers3

1

I've found than on my device (ASUS 1215b), the resume failed cause the suspen NetworkManager Failed...

After some debbuging, I've found that the dbus_set command on file /usr/lib/pm-utils/sleep.d/55NetworkManager failed. Then, Ive replaced the content of the two functions on that file (suspend_nm() and resume_nm()), with:

#!/bin/sh
# If we are running NetworkManager, tell it we are going to sleep.
# TODO: Make NetworkManager smarter about how to handle sleep/resume
#       If we are asleep for less time than it takes for TCP to reset a
#       connection, and we are assigned the same IP on resume, we should
#       not break established connections.  Apple can do this, and it is
#       rather nifty.

. "${PM_FUNCTIONS}"

suspend_nm()
{
    # Tell NetworkManager to shut down networking
        printf "Having NetworkManager put all interaces to sleep... The AixMaN Way..."
    service network-manager stop && echo Done. || echo Failed.
}

resume_nm()
{
    # Wake up NetworkManager and make it do a new connection
    printf "Having NetworkManager wake interfaces back up... The AixMaN Way..."
    service network-manager start && echo Done. || echo Failed.
}

case "$1" in
    hibernate|suspend)
        suspend_nm
        ;;
    thaw|resume)
        resume_nm
        ;;
    *) exit $NA
        ;;
esac
BuZZ-dEE
  • 14,223
1

From http://www.webupd8.org/2012/11/how-to-use-hybrid-suspend-in-ubuntu.html (paraphrased) there appears to be two different versions of hybrid sleep. One that suspends to RAM and disk at the same time; and another that first suspends to RAM, then wakes the computer up after PM_HIBERNATE_DELAY to then suspend to disk and (seemingly) switch off the computer. The former seems to be dependent on Kernel version, and only supported on 3.6+. I understand Ubuntu 12.10 uses Linux kernel 3.5, so the latter seems to be your only option sans upgrading (which I suppose may have already been done).

You don't state what you set PM_HIBERNATE_DELAY to in your tests, per the page referenced in your question, but I believe, according to the pm-suspend/pm-hiberate/pm-suspend-hybrid man page, removing an explicit definition of it, would set the wake-to-hibernate-then-switch-off sequence delay to be 15 minutes (900 seconds):

PM_HIBERNATE_DELAY [=900]
       If you are using kernel suspend/resume and invoke
       pm-suspend-hybrid, this environment variable controls how many
       seconds the system will wait after going into suspend _before waking
       back up and hibernating_. By default, this is set to 900 seconds (15
       minutes).

You also don't mention if you have, so would also suggest it would be prudent to check, from the page referenced in your question, that hybrid suspend is supported by your hardware, by establishing the result of sudo pm-is-supported --suspend-hybrid ; echo $? is 0

Also, perhaps of note, apparently there is a bug in KDE 4.3 where if Hybrid suspend isn't available, standard suspend to RAM is used (not sure if this is without explicit notice)... http://www.informit.com/articles/article.aspx?p=1565701&seqNum=3. This article also has some other useful info related to sleep/hybrid sleep/the like.

P.S A different implementation of Dlego Callejo's answer, is at http://www.cyberciti.biz/faq/linux-command-to-suspend-hibernate-laptop-netbook-pc

user66001
  • 125
0

I have added the answer to your question about enabling hybrid suspend here: https://askubuntu.com/a/344879/70266