Set charging thresholds on Linux laptops to extend battery lifespans

Last edited on 2024-07-24 Tagged under  #linux   #laptop   #server 

In the course of setting up my new(ish) Linux laptop home server, I started poking around for information on charging thresholds for laptop batteries.

Current wisdom holds that for a laptop connected to AC power 100% of the time, its a good idea to set the battery charge "ceiling" to less than 100% in order to extend the health and lifespan of the battery.

Information about my laptop's battery are found in various files inside /sys/class/power_supply/BAT0, which can be read with a simple cat $FILENAME.

Kernel docs for sys-class-power indicate two files of interest:

  • charge_control_start_threshold represents a battery percentage level, below which charging will begin
  • charge_control_end_threshold represents a battery percentage level, above which charging will stop

Note: Not mentioned are two other files - charge_start_threshold and charge_stop_threshold - which I believe are left over from the legacy API (and I'm guessing are preserved for backward compatibility). Regardless, changing the settings in charge_control_* are reflected in charge_* and vice-versa.

For my Thinkpad X230 which is connected full-time to AC power, I set a range between 40-50 percent:

echo '40' | sudo tee /sys/class/power_supply/BAT0/charge_control_start_threshold
echo '50' | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold

For my Thinkpad T480s which alternates between AC and battery power, I set a range between 70-80 percent:

echo '70' | sudo tee /sys/class/power_supply/BAT0/charge_control_start_threshold
echo '80' | sudo tee /sys/class/power_supply/BAT0/charge_control_end_threshold

I confirmed that these modifications survived a reboot, so there wasn't a need to setup a script to run at boot.

Helpful links:

You can like, share, or comment on this post on Mastodon 💬

Thanks for reading! Read other posts?

» Next: New life for an old laptop as a Linux home server

« Previous: Create a USB stick with multiple Linux install images using Ventoy