Linux distributions like Fedora Linux and Ubuntu will suspend a battery-powered system when the battery level drops to a critically low charge. They do this using the UPower subsystem. However, UPower’s default configuration isn’t great for battery longevity and it doesn’t always reserve enough charge to enter hibernation. Here’s how to prolong your laptop’s battery life and make sure it can handle low battery situations.
You’re probably reading this article because your laptop is powering down when its battery charge level is low. So, first thing first: does hibernation work on your laptop? Make sure that both the commands systemctl hybrid-sleep
and systemctl hibernate
powers down your laptop, and that you can resume your session when you power it back on again. You should use your normal user account, and not the root user.
If hibernation doesn’t work, the system will just power down instead, and you’ll lose your session. Some Linux distributions, like Fedora Linux 32, isn’t configured for hibernation by default. The link will help you set it up on Fedora Linux and should be helpful in troubleshooting other distributions.
Next, check to make sure that your system is managed by UPower. You can check on the UPower service by executing systemctl status upower.service
. If the service isn’t available or isn’t running, your system may not be configured with a power management subsystem. Or it could be managed by another power manager. Check the documentation for your distribution, or ask on its forums or mailing lists.
UPower’s default configuration will put your laptop into hybrid sleep when there’s two percent charge left on your battery. Hybrid sleep (suspend to memory) suspends your laptop to a low-power state, but keeps it powered on. Two hours later, if there’s enough power left, it’s suspended to disk and powered down completely (hibernation). UPower will fallback to hibernating your system right away if it doesn’t support hybrid sleep. If your battery runs out of charge in that two-hour window, your laptop will power down without first entering hibernation. The time delay is governed by the HibernateDelaySec
option in /etc/systemd/sleep.conf
.
In my opinion, when you’ve already reached a critically low battery charge; the remaining battery power is better spent entering into hibernation right away. You can change this behavior by setting CriticalPowerAction=Hibernate
in /etc/UPower/UPower.conf
.
Two percent remaining battery charge may not be enough to complete the hibernation process. A small, aging, stressed, or warm battery will discharge quickly. I recommend that you reconfigure UPower to begin the hibernation process at 5–8 percent remaining instead. The earlier it acts, the more likely it is to have enough battery charge left to successfully enter hibernation. This will also extend the longevity of a lithium-ion battery. Deep discharges lead to irreversible loss of capacity in lithium-ion batteries, according to Battery University.
The battery charge percentage can be configured in /etc/UPower/UPower.conf
. You can configure the low and critical battery level reminders by changing the PercentageLow
and PercentageCritical
options. I recommend setting these to 15 and 10 percent. PercentageLow
option controls when the HibernateDelaySec
is executed. I recommend setting this to no lower than 5 percent, and ideally higher to prolong battery life.
If you want something other than hibernation to happen in low battery situations, you can check out Batsignal and it’s -D command
argument. You can also use Batsignal to issue the hibernation command if you’re on a minimal system without a power manager. It can run as a background daemon and execute an arbitrary command or script in response to lower power states. (Remember to configure it to act before UPower does!)