LMT: Laptop Battery Life Enhancer for Ubuntu Linux

LMT (“Laptop Mode Tools”) is a set of tools that are designed to enhance battery life in GNU/Linux. It’s actually sort of a front-end as most of those tools are embedded into the Kernel and LMT lets you tweak them with ease. But for various reasons, most GNU/Linux distributions don’t enable some of them by default. This is also the case with Ubuntu (including the latest 11.10 version) as well.

Although according to the LMT’s man page, it primarily relies on another tool called “hdparm” (advanced tool that has the ability to spin down your HDD drives thus saving power consumption). However, LMT uses a lot of other built in tools to apply power saving settings to various hardware devices such as the CPU, Wi-Fi (plus Bluetooth) adapters, HDD, Ethernet cards, USB, DPMS (a display related power saving feature) for reducing power usage.

But, since “fine tuning” these tool manually is really a hectic task, all you gotta do is to install “LMT” and it’ll take care of the rest for you by automatically applying those settings!.

Does it really work?

Heck ya it does! ;-). As you can see from the below 2 screenshots, the first one is my Vostro V131’s power consumption without LMT installed (marked in Red) and the next one is after installing LMT (marked in Blue).

In both occasions, I rebooted the notebook and after login into the desktop, didn’t run any apps (for letting the notebook to come into an idle state) and fired up “powerstat” right away to measure the power consumption and it managed to save me about 2-4 Watts which is pretty impressive!. (And I didn’t manually change any of LMT’s settings either).

Before …

After installing LMT …

I did test it few times and although the numbers could’ve changed here and there, but in general, LMT did improve the power consumption (lowered it :D).

Main features …

*. As said above, it works with your HDD (especially with SATA drives and their advanced power management features), CPU, wireless network adapters, Ethernet cards, sound cards (On-board AC97), USB and other hardware devices to help you enhance the battery life.

*. For most users, it’s better to leave the default settings untouched. However, if you know what you’re doing, then you can manually change settings of LMT with ease by editing its default configuration file (more below).

*. You can also change settings of individual hardware devices such as manually tweaking the CPU based power saving features, Intel HD audio based settings, HDD power saving parameters, adjusting display brightness settings etc from their individual configuration files (again, more below) as well.

You can install “laptop-mode-tools” in Ubuntu 12.04 Precise Pangolin, 11.10 Oneiric Ocelot, 11.04 Natty Narwhal, 10.10 and 10.04 by using the below command in your Terminal window.

sudo apt-get install laptop-mode-tools

Now for changes to take effect, reboot the computer. From now on, “laptop-mode-tools” will automatically start optimizing the power consumption of your Computer. That’s it!.

Optional Tweaks …

Why is it disabled by default ?, are there any drawbacks after enabling it?

Although I cannot be certain why it’s disabled by default. Perhaps it’s because under some hardware LMT might make your system a bit unstable. However it ran quite fine in my Vostro V131, but if you’re having issues after installing it, then please use the below command to remove it, which should solve those issues.

sudo apt-get autoremove laptop-mode-tools

Tweaking the settings …

Note: As mentioned in the beginning, once installed, LMT adjusts the settings automatically thus the user don’t have to do any manual tweaking. However, if you’re a bit of a power user then you can adjust its settings.

But please be very careful while adjusting settings related to HDD (“hdparm” utility) for instance, because if you enable some of the “risky features” (disabled by default), you might end up losing your data. But you can experiment with adjusting settings like the “readahead” settings of your HDD and few other ones, again if you know what you’re doing.

As a safety precaution, enter the below command to backup the LMT’s configuration folder.

cp -r /etc/laptop-mode /home/gayan

Replace “/home/gayan” with your preferred location.

To restore the folder later (if you’ve successfully managed to corrupt it ;-)), use the below command.

sudo cp -r /home/gayan/laptop-mode /etc

Again, replace “/home/gayan” with your location of the backup folder.

To edit the main configuration file, open your Terminal and enter the below command.

sudo gedit /etc/laptop-mode/laptop-mode.conf

This should open it in the Gedit text editor as shown below. Before each command, there’s a simple (but well explained) description. So please read that text before changing the configuration settings.

And after making a change, make sure to click on the “Save” button to save them permanently as well.

For instance, if you want to temporarily disabled LMT (without unistalling it), then scroll down a bit until you see a text field as shown below (you can also copy the below text and search in Gedit, to easily locate it as well).

ENABLE_LAPTOP_MODE_TOOLS=

As you can see from the below screenshot, it’s enabled by default (obviously).

If you want to disable LMT temporarily, then replace “1” with “0” and reboot your PC. That should do it. Anytime you want to enable a feature, use the value “1” and to disable a setting, use the value “0”.

Enabling it even when running using AC power …

Although it doesn’t make a whole lot of sense to enable aggressive power saving features while on AC power (thus slowing down your PC’s performance), but if you want, you can forcefully enable LMT even when your Laptop/Notebook is running on AC power (disabled by default).

To do that, make sure you’ve opened the configuration file and search for the below text.

ENABLE_LAPTOP_MODE_ON_AC=

Now remove the value “0” and replace it with “1”. That should do it.

Adjusting Hard Disk Drive related settings (again, for most, it’s better to leave these settings alone)…

*. Changing the “readahead” settings.

What the heck is “readahead”?

MS Windows calls it “prefetching” & GNU/Linux calls it “readahead”. Although there could be many technical differences. But they both accomplish the same task of making your urns OS faster by loading the frequently accessed programs and other data into the RAM.

This is a much better way to do it rather than always storing those data in the HDD, which is a hell lot slowish plus makes your PC consume more energy as the HDD has to find files, read them … using its mechanical “head” etc (lot of disk activity in other words).

For example, let’s assume that I was playing a video file with 600MB of size which is about 60 minutes long. Now since loading a 600MB file into your RAM is not practical plus you don’t really need the whole video data at first (unless you’ve figure out a way to watch a movie within few seconds ;-)).

So a better implementation would be to split up the 600MB file into smaller ones (say 30MB ones) and load each one when necessary.

So after loading the first 30MB file (assuming it holds 3 minutes of video content), if there isn’t anything else to do, the HDD can then slow down a bit (until you watch it), then few seconds before the first 3 minutes of video data is about to end, it can re-spin the disk and load the second 30MB file and spin down the disk back again … which helps a lot while preserving energy. As you can see, the disk always reads data slightly ahead of the required amount, and perhaps that’s why it’s called “read-ahead” (not sure about that one though).

Now this is just an example of the process and the actual disk caching (readahead) values are configured by the OS for optimal performance and power saving. However, LMT lets us manually change the “readahead” values too.

The values are in Kilobytes and please don’t add huge readahead values, but if you want to experiment a bit, then you can do so by searching for the below term (or scroll down through the configuration settings file) in Gedit.

LM_READAHEAD=

And replace the default value of 3072 (in Kilobytes, about 3MB) with your preferred value (make sure to save the changes).

If you want to completely disable LMT trying to manipulate the “readahead”, then again search for the below term and replace the default value of “1” with “0” and save.

CONTROL_READAHEAD=

HDD idle timeout settings …

A HDD idle timeout is the waiting seconds before the HDD goes into a low power mode (due to HDD inactivity). For example, a HDD idle timeout value of “20 seconds” means that, after 20 seconds of non HDD activity, the HDD will be slowed down in order to preserve power consumption

It’s better to leave these settings alone. However, if you want to, you can change those settings as well. Again, search for the below text first.

LM_BATT_HD_IDLE_TIMEOUT_SECONDS=

Then replace the default value (20) with your experimental ones (eh! ;-)).

If you scroll down below, you’ll see a lot of some other experimental feature such as HDD write-cache (disabled by default, don’t enable it unless you know what you’re doing as it can sometimes result in data loss!) etc as well.

As you can see, the default configuration file mostly consists of HDD based power saving features more than anything. But if interested, you can change CPU, Display, AC 97 Audio, USB devices etc and their individual settings too. For that please go to the below location in Nautilus and double click on the each file to edit (while editing, you’ll need “sudo” privileges).

/etc/laptop-mode/conf.d/

Anyhow, since the article is awfully long, I’ll stop here.

But as an ending note, please don’t expect it to do “miracles”, but as said before, after installing it and without doing any manual tweaking, LMT was able to save me about 2-4Watts which is a pretty decent value concerning the general power consumption of a typical Laptop/Notebook!. So if you want to try to enhance the battery life in Ubuntu (or GNU/Linux in general), then LMT is a tool that’s worth trying.

If anything happens, use the backup file to restore the original settings OR, you can completely remove it from your system. And just in case, please use it with our own risk ;-), good luck.

8 thoughts on “LMT: Laptop Battery Life Enhancer for Ubuntu Linux

  1. Ram

    i don't think LMT works as well these days, and makes laptops with SSDs worse according to some… the biggest hog lately is the CPU, so sniping processes that wake up too frequently is the most important thing, along with putting other peripherals like usb, bluetooth, wifi, etc. into lower power modes until they're needed…

    back in 2000 just running hdparm would get my thinkpad down to a drip drip of energy, but these days the situation is so complicated

    1. Ritesh Raj Sarraf

      LMT is not just for the storage device. It covers almost all I/O Controller devices on your box.
      And for SSDs, yes, there’s no need to spin down. But for long, LMT has had the ability to detect a SSD device and just skip it.

  2. Lochii

    Hi :)

    I just came across this post by google and happen to have a V131 as well. I'm as well struggling with horrible battery life on linux (I run Mint 12). I equipped my laptop (which is a 2430M) with a crucial M4 SSD and 8gigs of ram. On idle (minimal brightness, backlit keyboard off) I got about 15 watts, which equals to just over 4 hours of battery life. Horrible! Especially since Dell claims to get up to 9.5.

    I've tried many things, like removing a DIMM from the system but that didn't quite solve my issue. I read alot of articles on power issues on the latest releases of linux kernels and there seems to be something with power management on latest intel chipsets. They claimed RC6 to be responsible for high power draw. There is only one solution I found really working, which got me from 15W on idle to ~10W. That was to add i915.i915.enable_rc6=1 to the kernel boot options. It doesn't affect anything else on the system really. There's also other parameters like pcie_aspm=force but they do not seem to effect power usage on the vostro at all.

    I also read an article on Ubuntu tempting to fix this on their new LTS release (12.04). I tried their unstable beta but power usage is exactly the same as in the current Mint release. Even with the rc6=1 option I mentioned earlier.

    I did run Windows 7 for a while and that seems to last much, much longer. I used a tool to measure power usage and Windows 7 got me to as low as 5.8 watts on idle, which makes a total of over 10 hours of use. I even had the power management tool tell me I had over 11 hours left. Crazy! Well, let's hope this issue gets addresses asap, since I feel a bit screwed my system only gets around 4.5 hours on normal use while Windows users get double. Love linux nonetheless! ;-)

    Cheers,

    Erik

    1. Gayan Post author

      Hi Erik,

      I can conform a lot of what you're saying too.

      I have the Core i3 Version with 4GB of RAM and 320 SATA HDD. And under Windows 7 it uses like 10-11 Watts on idle.

      But in Ubuntu 11.10 (with the RC6 disabled), as you can see it uses a lot more Watts and the Fan keep running in a slightly higher speeds due to that GPU heating up (I think). Now I didn't try RC6 enabling in 11.10 as some say it's a bit buggy and thought using 12.04 (when released), with RC6 enabled by default, would come close around readings of Windows 7. But again, I think as you've said 5 Watts reduction after enabling RC6 is reasonable.

      But since I also use Window, I can confirm that by default Windows applies a lot of other power saving features (to Wi-Fi, Bluetooth, HDD, etc) and even the Intel GPU driver adds few enhancements to the LED display (not just dimming it but also adjusting the brightness sensitivity of the LED etc) which should also help.

      Anyhow, have you tried enabling "TRIM" in your SSD?

      I don't know if this is dangerous, and would even cause data-loss, so please use it with caution. I'm sure you know this already, but just in case ;-), you can read the below article I found in "AskUbuntu" which explains how to enable it (it's disabled by default). You can also try tweaking settings in "LMT" for Wi-Fi etc as well.
      http://askubuntu.com/questions/18903/how-to-enabl

      I don't know if that would make a difference, but who knows :). BTW, Thanks for the comment!.

  3. Andy

    I am about to give up Linux (Ubuntu 12.04 64bit) and return to win 7 as my main OS. This is with a heavy heart as I do love Linux but 95% of my computing is done on a laptop (dell studio – i5 – 4Gb). I get almost 4 hours use from full charge with win 7 when running photoshop, indesign, illustrator etc. compared to around one and a half hours use on Ubuntu running gimp, scribus and Inkscape. I have tried lots of tweaks in laptop mode tools and other suggested things online but without significant improvement. Unless improvements are made to the kernel regarding power management then I am afraid Linux will be relegated to a ‘live’ USB system to recover systems or do some disk management. Although my one remaining desktop PC has different power management needs than my laptop I have set it as a dual boot for Ubuntu and win 7 and have noticed that it runs quieter and cooler under windows.

    1. Gayan Post author

      Hi Andy,

      That’s sad to hear. However, what is the model of your Dell Laptop and its graphics card?

      The reason I asked this was because, one of the reasons that can have a massive negative impact on battery life is an improperly managed power consumption of a graphics card. And GNU/Linux is known for those. If you have a graphics card other than Intel, then have you tried installing the official proprietary GPU driver ? …

      Another thing. As you have said that the other Windows desktop computer than runs cooler under Windows … that too well might be because of the GPU. Because, except in rare occasions, GNU/Linux also has very low CPU consumption at idle. So have you tried installing the proprietary drivers ?

      P.S: You probably have already done those … if so, please ignore the questions (just trying to help :)).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>