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!

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?

3 Answers
3

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).

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.

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