There used to be a time when Linux on the laptop meant putting up with cooling fans whirring away at full speed, while your machine was sucking its battery empty in record time. If you wanted proper support for all the fancy advanced power management that mobile processors had to offer, you were stuck with Windows.
Those days have been over for a while now though, particularly when you own a reasonably well supported machine. In which case Linux can and will actually outperform Windows quite noticeably in terms of battery endurance, and sustained compute performance when plugged into AC power.
Please read our disclaimer carefully before considering to proceed with this guide.
Most of the suggestions we provide should work with other current generation Intel laptops, but some are ThinkPad specific. We shall try to point that out where applicable. This guide assumes you are running a recent version of Ubuntu, either 18.04 or 20.04 desktop, on your machine, but then again, most things can be made to work with other distributions too. We shall split this one into two sections:
1) Making your ThinkPad run longer and preserving battery health:
TLP combines the manipulation of all modern power management functions of laptop hardware into one application and config file. It significantly improves run time. Particularly if you are willing to de-tune your system and under clock it while running on battery. Given the performance reserves most modern CPUs have this is entirely reasonable for normal office and web browsing workloads.
On most ThinkPad laptops TLP will also allow you to set battery charge thresholds. Under Windows the Lenovo Vantage tool provides similar functionality. What’s the benefit of not charging the battery to full capacity every time? Charging only to e.g. 85% and then stopping the charging process, even if the machine remains plugged into AC power, significantly prolongs the useful life of a battery pack, particular on machines that spend most their life as desktop replacements plugged into a charger 24/7. Electric vehicles use the same technique to prolong the service life of their battery packs. You can always temporarily raise or remove the charge threshold and charge to 100% if you need every last mWh of power for that extra long flight or road trip.
Setting it up, use the project PPA to get the most recent version:
sudo add-apt-repository ppa:linrunner/tlp sudo apt-get update
Install the following packages:
- tlp (PPA or universe) – Power saving
- tlp-rdw (PPA or universe) – optional, Radio Device Wizard
The above works for most laptops, the following is ThinkPad specific and enables some valuable extra functionality. Quoting from the project website:
“Depending on your model and kernel version external kernel module(s) are required to provide battery charge thresholds and recalibration.
The output of tlp-stat -b (version 1.2.2 or higher recommended) will guide you which package to install:
- acpi-call-dkms (universe) – optional – External kernel module providing battery charge thresholds and recalibration for newer ThinkPads (X220/T420 and later)
- tp-smapi-dkms (PPA or universe) – optional – External kernel module providing battery charge thresholds, recalibration and specific tlp-stat -b output for older ThinkPads
Install them either with your favorite package manager or the command:“
sudo apt-get install tlp tlp-rdw # ThinkPads require an additional: sudo apt install acpi-call-dkms tp-smapi-dkms # on (much) older kernels like 3.4 you'll also need this: sudo vi /etc/pm/sleep.d/thinkpad_acpi SUSPEND_MODULES="thinkpad_acpi"
I am including the TLP config file for my daily driver below. With average workloads this one gets me several hours of extra battery life. As you can see this config throttles back the CPU quite aggressively when running on battery.
TLP_ENABLE=1 TLP_DEFAULT_MODE=BAT TLP_PERSISTENT_DEFAULT=0 DISK_IDLE_SECS_ON_AC=0 DISK_IDLE_SECS_ON_BAT=5 MAX_LOST_WORK_SECS_ON_AC=15 MAX_LOST_WORK_SECS_ON_BAT=60 CPU_HWP_ON_AC=balance_performance CPU_HWP_ON_BAT=power CPU_MIN_PERF_ON_AC=15 CPU_MAX_PERF_ON_AC=100 CPU_MIN_PERF_ON_BAT=5 CPU_MAX_PERF_ON_BAT=50 CPU_BOOST_ON_AC=1 CPU_BOOST_ON_BAT=0 SCHED_POWERSAVE_ON_AC=0 SCHED_POWERSAVE_ON_BAT=1 NMI_WATCHDOG=0 ENERGY_PERF_POLICY_ON_AC=performance ENERGY_PERF_POLICY_ON_BAT=power DISK_DEVICES="nvme0n1 sda" DISK_APM_LEVEL_ON_AC="254 254" DISK_APM_LEVEL_ON_BAT="128 128" SATA_LINKPWR_ON_AC="med_power_with_dipm max_performance" SATA_LINKPWR_ON_BAT="med_power_with_dipm min_power" AHCI_RUNTIME_PM_TIMEOUT=15 PCIE_ASPM_ON_AC=performance PCIE_ASPM_ON_BAT=powersave INTEL_GPU_MIN_FREQ_ON_AC=300 INTEL_GPU_MIN_FREQ_ON_BAT=300 INTEL_GPU_MAX_FREQ_ON_AC=1000 INTEL_GPU_MAX_FREQ_ON_BAT=600 INTEL_GPU_BOOST_FREQ_ON_AC=1000 INTEL_GPU_BOOST_FREQ_ON_BAT=700 RADEON_POWER_PROFILE_ON_AC=default RADEON_POWER_PROFILE_ON_BAT=default RADEON_DPM_STATE_ON_AC=performance RADEON_DPM_STATE_ON_BAT=battery RADEON_DPM_PERF_LEVEL_ON_AC=auto RADEON_DPM_PERF_LEVEL_ON_BAT=auto WIFI_PWR_ON_AC=off WIFI_PWR_ON_BAT=on WOL_DISABLE=Y SOUND_POWER_SAVE_ON_AC=0 SOUND_POWER_SAVE_ON_BAT=1 SOUND_POWER_SAVE_CONTROLLER=Y BAY_POWEROFF_ON_AC=0 BAY_POWEROFF_ON_BAT=0 BAY_DEVICE="sr0" RUNTIME_PM_ON_AC=on RUNTIME_PM_ON_BAT=auto USB_AUTOSUSPEND=1 USB_BLACKLIST_BTUSB=0 USB_BLACKLIST_PHONE=0 USB_BLACKLIST_PRINTER=1 USB_BLACKLIST_WWAN=0 RESTORE_DEVICE_STATE_ON_STARTUP=1 START_CHARGE_THRESH_BAT0=85 STOP_CHARGE_THRESH_BAT0=90 START_CHARGE_THRESH_BAT1=85 STOP_CHARGE_THRESH_BAT1=90 RESTORE_THRESHOLDS_ON_BAT=1 NATACPI_ENABLE=1 TPACPI_ENABLE=1 TPSMAPI_ENABLE=1
Note, this machine has two batteries, which is reflected in the config.
2) Making your ThinkPad run faster:
While most people think of raising the core voltage for over-clocking and big elaborate cooling systems when trying to increase the speed of their CPU, Intel laptop CPUs actually offer another approach. Provided you have a CPU generation later than Haswell you should be able to apply a fixed voltage offset to the different voltage planes and thereby undervolt the CPU.
The undervolt tool by georgewhewell is one of the most convenient ways of achieving this under Linux. His github repo below provides excellent instructions on how to install and configure the undervolt tool, so I won’t repeat them here and just provide the link:
While this might seem at first counter intuitive for achieving performance gains, this works based on the fact that most dies sold to OEMs are of a sufficiently high quality that they will still run stably with their core voltage dropped between 75 and 100 mV. The offset you can achieve depends on your individual CPU. Some samples are can tolerate a little more others less.
Undervolting the CPU’s voltage planes results in less heat under load, which in turn avoids the automatic thermal throttle kicking in when running with automatically boosted clock speeds under Intel turbo boost. Most laptop CPUs are only able to sustain turbo boost frequencies for a minute or two before their cooling systems get overwhelmed and they throttle back. A high quality CPU sample undervolted in the same machine can sustain turbo boot for hours at a time. Thus your machine essentially runs natively overclocked while producing less heat under normal operation, leading to quieter fans.
Once you have mastered the instructions form the readme of the undervolt repo, you need to find the right settings that work for your specific machine.
So you need to test your machine under full load until it crashes, then reduce the offset by e.g. 5 mV and test again until you achieve a stable system that will run without crashing. Ideally you should let it run under load for an hour or more.
To test stability, try system stability tester. Get the latest generic built from: http://systester.sourceforge.net
Yes, this 8 year old code but still does the job just fine.
tar zxvf systester-1.5.0-linux-amd64.tar.gz cd systester-1.5.0-linux-amd64 sudo cp systester /usr/local/bin
Make executable if needed.
To run the application, you can simply run this command: