Thursday, October 21, 2010

How to Maximize the Battery Life on Your Linux Laptop :: Productive Geek

Photo by Sighthound

Power saving is a hot topic for laptop users who need to get things done when they are on the move and running on limited battery energy. Here is a list of smart Linux tricks to save battery power.

According to Less Watts.org, the leading source for power saving tips on Linux, the following components of our computer consumes most of our battery life and we can lengthen our battery life by tweaking them:

1. Ethernet Network Controller
2. WiFi/Wireless
3. Graphic and Display
4. Processor
5. Disks and File System
6. Software

We will show you some basic battery energy saving tips and some advanced hardware tweaks in Ubuntu.

Basic Battery Energy Saving Tips

Photo By acercanto

Ubuntu comes with a power management module that gives us basic control to save our battery life, to open it just go to ‘System’ > ‘Preferences’ > ‘Power Management’.

We can extend our battery life by selecting these options from the power management screen:

1. Putting our computer to sleep when it is inactive.
2. Setting our computer to hibernate mode when battery power is low.
3. Slowing down the hard disk spin.
4. Putting display to sleep when it is inactive.
5. Reducing the back light brightness.
6. Dimming display when the computer is idle.

Wifi/Wireless

Photo By Juicelog

Our Wifi/Wireless Radio consumes power when it receives and sends data over the network and we should turn it off when we’re not using it. We can turn off our wifi if our network card supports the enable and disable power control mechanism by using the ‘iwconfig’ command that we can execute in Ubuntu console:

sudo iwconfig wlan0 txpower off

Use the following command to turn our Wifi/Wireless on back again

sudo iwconfig wlan0 txpower on

Note: Replace ‘wlan0′ with your wireless card name displayed in ‘System’ > ‘Administration’ > ‘Network Tools’ under the ‘Network Device’ Drop Down List

Processor

Photo by chigmaroff
Linux provides a simple tuning mechanism to save energy consumption in our processor by distributing the processing load among the available processors. If you’re laptop comes with multi-processor, we can use take advantage of Linux’s processor balancing feature to save energy consumption by executing this command through the console:

echo 1 > /sys/devices/system/cpu/sched_mc_power_savings

Disk System

Photo By fr3d.org
Linux maintain a set of files system date meta data including ‘atime’ that shows the last time a file was used. Although this feature is very useful to system administrator, keeping track of ‘atime’ forces our laptop to a write to the disk every time a file is accessed increasing energy consumption from the battery.

Setting Relatime

We can disable the ‘atime’ to reduce disk write at the cost of breaking software that relies on ‘atime’. An alternative is to enable the ‘relatime’ option where Linux will update files access times only if they are earlier than the modification time. This change allows utilities to see if the current version of a file has been read, but still cuts down significantly on atime updates. Linux Kernel 2.6.20 and above should support the ‘relatime’ option

Execute the following command in your console to enable the ‘relatime’ option.

mount -o remount,relatime /

Hard Disk Power Saving Options

Some hard disk manufacturer build power saving options into their hardware so that we can reduce the energy that our hard disk consume. We can only turn on this power saving option when we see AdvancedPM=yes after executing the following command in the console:

hdparm -i /dev/sda

This is an example from hdparm:


Model=FUJITSU, FwRev=000000A0, SerialNo=NS9BT742705B
Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs }
RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
BuffType=DualPortCache, BuffSize=8192kB, MaxMultSect=16, MultSect=16
CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=234441648
IORDY=yes, tPIO={min:240,w/IORDY:120}, tDMA={min:120,rec:120}
PIO modes: pio0 pio1 pio2 pio3 pio4
DMA modes: mdma0 mdma1 mdma2
UDMA modes: udma0 udma1 udma2 udma3 udma4 *udma5
AdvancedPM=yes: mode=0x80 (128) WriteCache=enabled
Drive conforms to: unknown: ATA/ATAPI-2,3,4,5,6,7

* signifies the current active mode

We can enable power saving mode using the hdparm command, for example:

hdparm -B 1 -S 12 /dev/sda

Enable Laptop Mode

We can save our battery energy life by turning on Linux’s laptop mode so that Linux reduce I/O operation when our laptop is under low power. Not every hardware comes with a laptop mode so we need to check whether our hardware supports laptop mode by executing the following command:

sudo gedit /proc/sys/vm/laptop_mode

If you find that the value in the laptop_mode text file is 0 it means that the laptop mode is disabled. Just set it to 5 from gedit and save the file to enable the laptop mode.

Software

Intel introduce PowerTOP, a software that analyzes software’s power consumption. According to Intel PowerTOP work best with Linux kernel with the tickless idle (NO_HZ) feature enabled (version 2.6.21 or later). Currently, only 32-bit kernels have support for tickless idle; 64-bit kernels are expected to gain this feature in version 2.6.23.

You can install PowerTop through the Ubuntu Software Centre and run it by typing the following command from your console.

sudo powertop

“Wakeups per second” is a good indicator for our laptop energy consumption effeciency. Our laptop saves the most energy when the “Wakeups per second” shows a low number. According to Intel the lowest number of wakeups in a Gnome Desktop environment is 3 and we should be able to achieve this by tweaking our laptop hardware configuration or by closing some of the active software in our system.

Below is a sample of PowerTOP analysis on my laptop energy consumption.

According to PowerTOP analysis the main cause of wake up in my laptop is ‘Rescheduling Interrupt’ that is often invoked when my laptop tries to spread the processor activity across my dual Intel Centrino core. Rescheduling Interrupt happens when the kernel IPI “message” is sent to a sleeping core to wake it up from a low power sleep to make it start running a process when the scheduler decides to offload work from one core to another sleeping core.

One solution to minimize the interrupts is to install irqbalance that distributes the interrupts over the processors and cores in your computer system.

References

Lesswatt.org. LessWatts is about creating a community around saving power on Linux.

Intel PowerTop. PowerTOP is a Linux tool that finds the software component(s) that make your laptop use more power than necessary while it is idle.

Posted via email from ://allthings-bare

No comments:

Post a Comment