LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices

Reply
 
Search this Thread
Old 06-29-2013, 01:59 PM   #1
andreas-r
Member
 
Registered: Jan 2013
Location: Denmark
Distribution: Ubuntu 12.10 & Slackware 14, 64bit
Posts: 46

Rep: Reputation: 0
From suspend to hibernate when battery is low


I'm running Crunchbang (Debian Wheezy + OpenBox, basically) on a Lenovo Thinkpad Edge 13. I don't have a power manager, instead I'm using apcid, pm-utils and xautolock to get my computer to suspend when lid is closed or it has been idle for some time, and to hibernate when battery is critically low. It's fine, only problem is:

When my computer is in suspend mode and I leave until the battery is dead, it shuts down.

I would like it to stay on suspend as long as possible and go into hibernation if the battery level gets critically low.

I do not want it to:
- change from suspend to hibernate after a predetermined amount of time as can be done like this ...
- nor do I want it to go into hybrid mode (saving both to ram and drive and resuming from the latter if battery dies) as can be done with the s2both feature of uswsusp.

In suspend mode I would like my computer to detect when the battery level gets critical and then hibernate.

How could this be done?

Thanks

Last edited by andreas-r; 06-29-2013 at 02:22 PM.
 
Old 06-29-2013, 02:52 PM   #2
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,508

Rep: Reputation: 571Reputation: 571Reputation: 571Reputation: 571Reputation: 571Reputation: 571
Didn't know about s2both, etc. but what you want can not universally be done, AFAICT.

Suspend - cpu goes into S3 power saving state = is dead. It needs an interrupt to wake it.
ACPI stuff won't do it - Catch 22. It needs a cpu. If the battery critical signal can be mapped to a hardware interrupt, just maybe. With the sys interface, the battery critical signal is extremely difficult to find as it comes too late to use for a big wake up then compress & disk write.
 
Old 06-29-2013, 05:33 PM   #3
andreas-r
Member
 
Registered: Jan 2013
Location: Denmark
Distribution: Ubuntu 12.10 & Slackware 14, 64bit
Posts: 46

Original Poster
Rep: Reputation: 0
But some conventional power managers like the one in Unity manages going from suspend to hibernate when the computer runs out of battery though I don't know how ...
 
Old 06-30-2013, 08:14 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,598
Blog Entries: 2

Rep: Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060
You don't need s2both to have mixed suspend/hibernate, you can use pm-tools for that, the command is pm-suspend.hybrid. That would be the only option that I think would work, for the reasons business_kid already pointed out. I would suspect that Unity's power-manager just uses hybrid suspend by default.
 
Old 06-30-2013, 09:30 AM   #5
andreas-r
Member
 
Registered: Jan 2013
Location: Denmark
Distribution: Ubuntu 12.10 & Slackware 14, 64bit
Posts: 46

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by TobiSGD View Post
You don't need s2both to have mixed suspend/hibernate, you can use pm-tools for that, the command is pm-suspend.hybrid.
You mean pm-suspend-hybrid? Tried that before installing uswsusp and thereby s2both. It works but seems to do exactly the same as pm-suspend. I tried taking the battery out after executing the command and it just started up again like after normal power-down (eg. the swap image wasn't restored ...)

The man page says that: "s2both(8) is an hybrid-suspend implementation." I take that do mean that is the only implementation. Am I wrong?

OK, I think I got it now:
- the default pm-suspend-hybrid command suspends and after a given time wakes up and hibernates. Can be set like this.
- s2both offer another implementation in which the computer both suspend to disk and ram, and resumes from disk only if it can't resume from ram (that is, if the computer has been powered down in the meantime).

So they are to different methods of combining suspension and hibernation. Am I right?

Last edited by andreas-r; 06-30-2013 at 11:21 AM.
 
Old 06-30-2013, 11:14 AM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,598
Blog Entries: 2

Rep: Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060
Quote:
Originally Posted by andreas-r View Post
- the default pm-suspend-hybrid command suspends and after a given time wakes up and hibernates.
Nope. From the pm-utils manpage:
Quote:
pm-suspend-hybrid
Hybrid-suspend is the process where the system does everything it needs to hibernate, but suspends instead of
shutting down. This means that your computer can wake up quicker than for normal hibernation if you do not run
out of power, and you can resume even if you run out of power.
Regarding this:
Quote:
Can be set like this.
I don't know, that link seems to be broken.
Quote:
Tried that before installing uswsusp and thereby s2both. It works but seems to do exactly the same as pm-suspend. I tried taking the battery out after executing the command and it just started up again like after normal power-down (eg. the swap image wasn't restored ...)
Have you added the needed resume= parameter to your kernel command line in the boot-loader?
 
Old 06-30-2013, 11:23 AM   #7
andreas-r
Member
 
Registered: Jan 2013
Location: Denmark
Distribution: Ubuntu 12.10 & Slackware 14, 64bit
Posts: 46

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by TobiSGD View Post
I don't know, that link seems to be broken.
Fixed it.

Quote:
Originally Posted by TobiSGD View Post
Have you added the needed resume= parameter to your kernel command line in the boot-loader?
No, how do I do that?
 
Old 06-30-2013, 12:07 PM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,598
Blog Entries: 2

Rep: Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060Reputation: 4060
Quote:
Originally Posted by andreas-r View Post
No, how do I do that?
Assuming you use the Grub 2 bootloader (default on Ubuntu):
- Open the file /etc/default/grub as root in a text editor
- You should find a line
Code:
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
in there, maybe with other options than "quiet". Add the resume= parameter to it, so that it looks for example like
Code:
GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=/dev/sdXY"
where /dev/sdXY is your swap partition (note that your swap partition should be at least as large as your physical RAM to get hibernate working).
- Save the file and run
Code:
sudo update-grub
Now your bootloader is configured correctly and waking up from hibernation should work.
 
Old 06-30-2013, 01:25 PM   #9
andreas-r
Member
 
Registered: Jan 2013
Location: Denmark
Distribution: Ubuntu 12.10 & Slackware 14, 64bit
Posts: 46

Original Poster
Rep: Reputation: 0
Thanks for the guide TobiSGD, but I think we misunderstood each other. My computer hibernates with pm-hibernate and wakes up just fine both before and after installing the package needed to s2both. pm-suspend-hybrid, though, does the exact same as pm-suspend, unless I use s2both. This is the full description of pm-suspend-hybrid from the man page:

Hybrid-suspend is the process where the system does everything it needs to hibernate, suspends instead of shutting down. This means that your computer can wake up quicker than for normal hibernation if you do not run out of power, and you can resume even if you run out of power. s2both(8) is an hybrid-suspend implementation.

I take that to mean that s2both is a way of making pm-suspend-hybrid work. The only other implementation I've found is the one in the aforementioned link that uses:
Code:
PM_HIBERNATE_DELAY=900
... to set a time after which suspend switches to hibernate. s2both does something else, it suspends to disk and ram, and resumes from disk only if it can't resume from ram, that is, the behavior described in the quotation from the man page.

My claim is that the only way to get this behavior is by way of s2both.

Last edited by andreas-r; 06-30-2013 at 01:28 PM.
 
Old 07-01-2013, 04:35 AM   #10
business_kid
Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 6,508

Rep: Reputation: 571Reputation: 571Reputation: 571Reputation: 571Reputation: 571Reputation: 571
Yeah, just tried pm-suspend-hybrid right now, as follows: Ran pm-suspend-hybrid, removed psu, removed battery, replaced power & powered on.It did a fresh start, not a resume from hibernation. I really don't think it wrote the disk image (But I've an ssd, so it's hard to be sure).

pm-suspend-hybrid might works for folks having video issues or something with suspend, as it pretends to hibernate, but suspends instead.
 
  


Reply

Tags
hibernate, power management, suspend


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Automatically Resume from Suspend to Ram and Suspend to Disk to Save Battery in Linux LXer Syndicated Linux News 0 05-10-2013 02:40 AM
[SOLVED] Suspend and hibernate linuxbird Slackware 6 12-19-2012 06:53 AM
Fedora : hibernate on battery low jonaskellens Linux - Newbie 4 07-26-2011 07:56 AM
hibernate, suspend, is it safe to unplug mains power when battery in? lugoteehalt Linux - Laptop and Netbook 8 03-08-2007 07:58 AM
laptop battery and hibernate paulr1984 Linux - Hardware 7 11-15-2004 05:32 AM


All times are GMT -5. The time now is 02:14 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration