Won't Hibernate when Battery Critical
Ubuntu 12.04 64bit refuses to hibernate when battery is critically low. Instead it does a complete shutdown which is unnecessary and can cause loss of data.
I have enabled Hibernate (pm-hibernate) on following the common instructions I tested pm-hibernate it is works fine when run manually.
I have set my power options to hibernate "When Power is Critically Low". This has also been verified by using dconf Editor. Under org > gnome > settings-daemon > plugins > power > critical-battery-action it is set to "hibernate". Under the same schema, time-action is set to "120".
I would like to see what is happening just prior to this shutdown. I would like to know what logs to search to see if pm-hibernate is actually failing, or if it is being ignored entirely.
Barring figuring this out on my own, is there a suggested work around?
I found another solution for my Ubuntu 14.04 system. Maybe it works for you.
First, install laptop-mode-tools
sudo apt-get install laptop-mode-tools
Then, you must enable the auto-hibernate function. You must edit a text file:
sudo gedit /etc/laptop-mode/conf.d/auto-hibernate.conf
There, look for ENABLE_AUTO_HIBERNATION parameter and replace the 0 with a 1:
ENABLE_AUTO_HIBERNATION=1
In the same file, you also want to adjust the battery charge percentage when the computer hibernates. For example:
AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT=3
Save the file and test the configuration letting your battery discharge. If it works, you must set laptop-mode-tools as default, by creating a script:
sudo touch /etc/pm/sleep.d/10-laptop-mode-tools
sudo chmod a+x /etc/pm/sleep.d/10-laptop-mode-tools
sudo gedit /etc/pm/sleep.d/10-laptop-mode-tools
Then, in gedit, copy and paste this:
case $1 in
hibernate)
/etc/init.d/laptop-mode stop
;;
suspend)
/etc/init.d/laptop-mode stop
;;
thaw)
/etc/init.d/laptop-mode start
;;
resume)
/etc/init.d/laptop-mode start
;;
*)
echo Something is not right.
;;
esac
Save the file, then restart the system and test again. I hope that it works for you.
In my opinion, it looks like something is interfering with the the gnome-power-manager. If someone else reproduces the problem, then we can report a bug.
References:
Tips for save power by Penalvch https://help.ubuntu.com/community/PowerManagement/ReducedPower#Using_less_power_with_laptop-mode-tools
Re: Getting Ubuntu to automatically suspend on battery low (command-line) by Isamu715 http://ubuntuforums.org/showthread.php?t=2092327&p=12394451#post12394451
I have/had the same problem with 12.04 non-precise power monitoring, some possibilities:
(to cut to the chase and avoid the rhetoric read the final point - it is irritating that a "fix" is needed to restore such mundane and ordinary functionality)
Unity and 12.04 do not provide the functionality of 10.04 that has more robust reliability, especially power management, so regression is the option I use. The sophisticated maturation of a computing system environment (Debian, GNU, Linux, ...) requires a high degree of comparable rigorous discipline to retain and modify functionality consistently. Consequently, several well established software paradigms have degraded and been compromised including power management.
reference:
Bug #993440 “No suspend option for critical battery state in pow...” : Bugs : “gnome-control-center” package : Ubuntu:
solution: (manually labour intensive)
lp:~jlangvand/ubuntu/quantal/gnome-control-center/fix-for-993440-
Write a script (more manually labour intensive) using
pm-hibernate
(pm-suspend
),watch
,upower
,grep
etc. to monitor the battery state and take action when required.pseudo code outline:
Usewatch
, every few minutes, to periodically comparegrep
upower -d
battery stats togsettings get org.gnome.settings-daemon.plugins.power percentage-critical
, and when threshold is exceededsudo pm-hibernate
crude (as in prototyping only, non-executable) draft: (suspend for any battery % < 10%)
upower --monitor-detail | grep "percentage[^\d]+\d\.\d*\%" | bash pm-suspend
an elegant solution
- aborts further
watch
ing on suspend - checks all transient power supplies: UPS's, tertiary batteries, solar panels (power diminishes at dusk and by clouds), etc.
- allows for non-privileged suspension (/ hibernation) for restricted users
- aborts further
refs:
-
Netbook performs hard shutdown without warning on low battery power
- especially this comment
- Suspend when critically low power 11.10
- Checking laptop's battery state in a terminal
- How to check battery status using terminal?
- Modify actions when battery is critically low?
- https://askubuntu.com/questions/129093/laptop-powered-off-instead-hibernate
- ( self ref. Won't Hibernate when Battery Critical )
-
684186 - gnome-settings-daemon: fails to execute action on low battery condition - Debian Bug report logs at:
bugs.debian.org/cgi-bin/bugreport.cgi?bug=684186 - ... + more at:
www.google.ca/search?q=org.gnome.settings-daemon.plugins.power%20critical-battery-action%20%27suspend%27&num=50
Battery performance can be examined with:
-
upower
watch -d upower -i /org/freedesktop/UPower/devices/battery_BAT0
upower --monitor-detail | grep percentage
-
gnome-power-statistics
How to check battery status using terminal?
How can I find the discharge rate of the battery?