UbuntuUbuntu Based

How to Improve Battery Life on Ubuntu

Improve Battery Life on Ubuntu

In this tutorial, we will show you how to improve battery life on Ubuntu. Ubuntu offers a robust and versatile computing experience, but laptop users often face a common challenge: battery life typically falls short compared to Windows or macOS. This discrepancy stems from several factors, including default configurations that prioritize performance over power efficiency and less optimized hardware drivers. Fortunately, with the right tools and tweaks, you can significantly extend your Ubuntu laptop’s battery life without compromising functionality.

This comprehensive guide explores various optimization techniques that can help you maximize every minute of battery power on your Ubuntu system. From simple adjustments anyone can make to advanced configurations for power users, you’ll discover how to transform your laptop’s energy efficiency.

Understanding Battery Drain in Ubuntu

Battery performance on Ubuntu laptops typically lags behind Windows counterparts due to several key factors. Unlike Windows, which benefits from manufacturer-specific power optimizations, Ubuntu’s generic drivers often don’t fully leverage hardware-specific power-saving features. Additionally, default Ubuntu configurations tend to prioritize performance over power efficiency.

Common causes of excessive battery drain include:

  • Unoptimized graphics drivers, especially for hybrid GPU setups
  • Background processes and services running unnecessarily
  • Suboptimal CPU frequency scaling
  • High screen brightness settings
  • Inefficient power management during idle states

Before implementing any optimization techniques, it’s important to establish a baseline for your current battery performance. This allows you to measure the effectiveness of your adjustments.

Measuring Your Current Battery Performance:

To check your battery’s discharge rate, install and run PowerTOP with:

sudo apt install powertop
sudo powertop

Look for the “Discharge rate” value, which shows power consumption in watts. A higher number indicates faster battery drain. For most laptops, an idle discharge rate above 10W suggests room for improvement.

Essential Battery Optimization Tools

Several specialized tools can help you maximize battery life on Ubuntu. Each offers unique features and approaches to power management.

TLP: Comprehensive Power Management

TLP is a powerful command-line utility that automatically applies optimized power settings based on whether your laptop is plugged in or running on battery. Its main advantages include:

  • Works out of the box with sensible defaults
  • Runs as a background service with minimal user intervention
  • Covers comprehensive system-wide optimizations
  • Supports battery charge thresholds to extend battery lifespan

PowerTOP: Diagnosis and Fine-Tuning

PowerTOP, developed by Intel, helps identify power-hungry processes and components while offering suggestions for reducing consumption. Key features include:

  • Detailed power consumption analysis
  • “Tunables” page with specific optimization recommendations
  • Real-time monitoring of power usage by processes and devices
  • Calibration functionality for accurate measurements

Auto-cpufreq: Automated CPU Management

Auto-cpufreq focuses specifically on processor power management, automatically adjusting CPU frequency based on system load. Benefits include:

  • Simple installation and setup
  • Automatic switching between performance and power-saving modes
  • Monitoring tools for CPU frequency, temperature, and power usage
  • Minimal configuration required

Slimbook Battery: User-Friendly GUI Approach

For those who prefer graphical interfaces, Slimbook Battery provides a tray applet with pre-configured power profiles. Its strengths include:

  • Easy-to-use interface with simple mode switching
  • Advanced configuration panel for fine-tuning
  • No command-line knowledge required
  • Battery health monitoring

Installing and Configuring TLP

TLP is often considered the foundation of power management on Linux laptops. Its comprehensive approach makes it an excellent starting point for battery optimization.

Installation Process

Installing TLP on Ubuntu is straightforward using the following terminal commands:

sudo apt update
sudo apt install tlp tlp-rdw

The tlp-rdw package provides radio device wizard functionality for managing wireless connections.

After installation, start and enable the TLP service:

sudo systemctl enable tlp.service
sudo systemctl start tlp.service

To ensure TLP has exclusive control over power management, disable conflicting services:

sudo systemctl mask systemd-rfkill.service
sudo systemctl mask systemd-rfkill.socket

Basic Configuration

TLP works with sensible defaults immediately after installation, but you can customize its behavior by editing the configuration file:

sudo nano /etc/tlp.conf

Key settings to consider modifying include:

CPU Frequency Scaling:

CPU_SCALING_GOVERNOR_ON_AC=performance
CPU_SCALING_GOVERNOR_ON_BAT=powersave

Disk Power Management:

DISK_IOSCHED="mq-deadline"
DISK_APM_LEVEL_ON_AC="254 254"
DISK_APM_LEVEL_ON_BAT="128 128"

USB Autosuspend:

USB_AUTOSUSPEND=1

After making changes, restart TLP to apply them:

sudo systemctl restart tlp.service

Battery Charge Thresholds

One of TLP’s most valuable features is the ability to set battery charge thresholds, which can significantly extend overall battery lifespan. Keeping your battery between 20% and 80% charged, rather than constantly at 100%, reduces chemical stress and slows capacity degradation.

Add these lines to your TLP configuration file:

START_CHARGE_THRESH_BAT0=50
STOP_CHARGE_THRESH_BAT0=80

This configuration starts charging when battery level drops below 50% and stops at 80%. For different usage scenarios, consider these alternatives:

For frequent travelers:

START_CHARGE_THRESH_BAT0=75
STOP_CHARGE_THRESH_BAT0=80

For mostly stationary use:

START_CHARGE_THRESH_BAT0=50
STOP_CHARGE_THRESH_BAT0=80

Balanced approach:

START_CHARGE_THRESH_BAT0=65
STOP_CHARGE_THRESH_BAT0=80

To verify your TLP configuration and check battery status:

sudo tlp-stat -b
sudo tlp-stat -s

PowerTOP Setup and Usage

PowerTOP provides valuable insights into power consumption and offers specific recommendations for reducing battery drain.

Installation and Basic Usage

Install PowerTOP using:

sudo apt install powertop

For the most accurate readings, calibrate PowerTOP first:

sudo powertop --calibrate

Note that calibration temporarily turns off various components and may take several minutes to complete.

To launch PowerTOP in interactive mode:

sudo powertop

Navigate between tabs using the Tab key to explore different aspects of power usage.

Identifying Power-Hungry Processes

The “Overview” tab shows processes consuming the most power. Look for unexpected applications with high power usage and consider closing them when running on battery.

The “Device Stats” tab identifies hardware components drawing significant power. USB devices, wireless adapters, and storage devices often appear here.

Implementing PowerTOP Recommendations

The “Tunables” tab provides specific power-saving suggestions. Each item can be toggled between “Good” and “Bad” by pressing Enter while the item is selected.

To automatically apply all PowerTOP recommendations at startup:

sudo powertop --auto-tune

To make these changes persistent across reboots, create a startup service:

sudo nano /etc/systemd/system/powertop.service

Add the following content:

[Unit]
Description=PowerTOP auto tune

[Service]
Type=oneshot
ExecStart=/usr/sbin/powertop --auto-tune

[Install]
WantedBy=multi-user.target

Enable the service:

sudo systemctl enable powertop.service

CPU Power Management with Auto-cpufreq

The CPU is often one of the largest power consumers in a laptop. Auto-cpufreq provides an automated approach to managing processor power states.

Installation Process

Install Auto-cpufreq using:

sudo apt install auto-cpufreq

If not available in the default repositories, install from GitHub:

git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq
sudo ./auto-cpufreq-installer

Configuring Performance Modes

Auto-cpufreq offers two primary modes:

Monitor mode – observes system behavior without making changes:

sudo auto-cpufreq --monitor

Install daemon – runs continuously in the background:

sudo auto-cpufreq --install

The daemon automatically switches between:

  • “Performance” mode when plugged in, maximizing CPU frequency
  • “Powersave” mode on battery, reducing CPU frequency when possible

Monitoring CPU Performance

To check the current status and operation:

sudo auto-cpufreq --stats

This displays real-time information about:

  • Current CPU frequency
  • System temperature
  • Battery status
  • Power consumption estimates

Display and Graphics Optimization

The display typically consumes the most power in a laptop, making it a prime target for optimization.

Managing Screen Brightness

Reducing screen brightness is one of the most effective ways to extend battery life. Set brightness manually using function keys or through the Settings app.

For automatic brightness adjustment based on ambient light (if supported by your hardware):

  1. Open Settings
  2. Navigate to Power
  3. Enable “Automatic Brightness” option

Power-Efficient Display Settings

Adjust these settings for better battery life:

  1. Reduce screen timeout:
    • Go to Settings > Power
    • Set “Blank Screen” to a shorter duration (1-2 minutes)
  2. Use native resolution:
    • Lower resolutions may reduce GPU load
    • Settings > Displays > Resolution

Graphics Configuration for Hybrid Systems

For laptops with dual graphics (Intel/AMD + NVIDIA):

  1. Install the appropriate drivers:
    sudo apt install nvidia-prime
  2. Switch to power-saving mode when on battery:
    sudo prime-select intel
  3. Configure automatic switching with TLP by adding to your TLP configuration:
    RUNTIME_PM_ON_BAT=auto
    RUNTIME_PM_ON_AC=on

Managing Hardware Components and Peripherals

Unused hardware components continue to draw power unless properly managed.

Wireless Connections

Disable Wi-Fi and Bluetooth when not in use:

Command line method:

nmcli radio wifi off
rfkill block bluetooth

GUI method:

  1. Click on the system menu in the top-right corner
  2. Toggle off Wi-Fi and Bluetooth switches

USB Power Management

USB devices can drain power even when idle. Enable USB autosuspend through TLP by ensuring this setting in your TLP configuration:

USB_AUTOSUSPEND=1

For immediate effect without editing TLP config:

echo 1 | sudo tee /sys/module/usbcore/parameters/autosuspend

Audio System Optimization

The audio subsystem can be optimized by enabling power saving mode:

echo 1 | sudo tee /sys/module/snd_hda_intel/parameters/power_save

Add this to your TLP configuration for persistence:

SOUND_POWER_SAVE_ON_AC=1
SOUND_POWER_SAVE_ON_BAT=1

System-Level Optimizations

Beyond specific components, system-wide adjustments can yield significant battery improvements.

Lightweight Desktop Alternatives

GNOME (Ubuntu’s default desktop) offers excellent features but consumes more power than lighter alternatives. Consider installing one of these lightweight desktop environments:

sudo apt install xfce4               # For XFCE
sudo apt install lubuntu-desktop     # For LXDE/LXQt
sudo apt install mate-desktop        # For MATE

Log out and select your preferred environment from the login screen to try it.

Reducing Visual Effects

Disable animations in GNOME to reduce GPU workload:

  1. Open Settings
  2. Go to “Accessibility”
  3. Enable “Reduce Animations”

Background Services Management

Identify and disable unnecessary startup applications:

  1. Open “Startup Applications”
  2. Uncheck items you don’t need at startup

For a more detailed view of running processes:

top

Or use the GUI System Monitor:

gnome-system-monitor

To terminate power-hungry applications:

killall application_name

Advanced Tweaks

These advanced optimizations require more technical knowledge but can deliver additional power savings.

Kernel Parameters

Add these power-saving parameters to your kernel boot line:

  1. Edit GRUB configuration:
    sudo nano /etc/default/grub
  2. Add these parameters to GRUB_CMDLINE_LINUX_DEFAULT:
    quiet splash pcie_aspm=force intel_idle.max_cstate=1 i915.enable_rc6=1 i915.enable_fbc=1 i915.semaphores=1
  3. Update GRUB:
    sudo update-grub

Fix Battery Drain During Suspend

Ubuntu’s default suspend mode (s2idle) can drain significant battery power. Switch to deep sleep mode for better efficiency:

echo deep | sudo tee /sys/power/mem_sleep

For a permanent solution, add this to GRUB:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem_sleep_default=deep"

Then update GRUB:

sudo update-grub

I/O Scheduler Optimization

For SSDs, use the deadline scheduler for better power efficiency:

echo mq-deadline | sudo tee /sys/block/sda/queue/scheduler

Include in your TLP configuration for persistence:

DISK_IOSCHED="mq-deadline"

Best Practices for Daily Use

Adopting these habits can further extend your battery life.

Optimal Charging Habits

  1. Avoid keeping your laptop plugged in at 100% continuously
  2. Aim to keep battery level between 20% and 80% when possible
  3. Perform a full discharge/charge cycle once every 1-2 months
  4. Consider using TLP’s charge threshold feature as discussed earlier

Power-Efficient Applications

Some applications are more power-efficient than others:

  • Use Firefox with uBlock Origin instead of Chrome
  • Choose VLC over web-based video players
  • Prefer native applications over Electron-based apps
  • Consider lightweight text editors (like Gedit) instead of VS Code when appropriate

Regular System Updates

Keep your system updated to benefit from power management improvements:

sudo apt update && sudo apt upgrade

Troubleshooting Common Battery Issues

Even with optimizations in place, you might encounter these common battery-related problems.

Sudden Battery Drain

If you experience unexpected rapid battery drain:

  1. Check for recent software changes or updates
  2. Examine running processes:
    top -o %CPU
  3. Look for stuck processes consuming excessive resources
  4. Restart problematic services or reboot if necessary

Battery Indicator Issues

If your battery indicator shows incorrect information:

  1. Reset the power statistics:
    rm -f ~/.local/share/gnome-power-statistics/*
  2. Recalibrate the battery by fully discharging and then charging to 100%
  3. If problems persist, try disconnecting the battery (if possible) and reconnecting

Conflicts Between Power Management Tools

Multiple power management tools may conflict with each other. If you’ve installed several:

  1. Decide on a primary tool (usually TLP)
  2. Disable or uninstall others:
    sudo systemctl disable powertop.service
  3. If using TLP with auto-cpufreq, add this to TLP config:
    CPU_SCALING_GOVERNOR_ON_AC=performance
    CPU_SCALING_GOVERNOR_ON_BAT=powersave
    CPU_ENERGY_PERF_POLICY_ON_BAT=power
    CPU_ENERGY_PERF_POLICY_ON_AC=performance

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button