Power Management on Linux can be a bit of an issue, sometimes. It certainly was for my MacBook Pro, which ran really hot, and only got 1.5 hours of normal usage on Ubuntu 10.04 compared to 6 hours of the same on Mac OS. Needless to say, this is unacceptable. So I fixed it. Here are the steps that worked for me.
First, the kernel version that comes with Ubuntu Lucid has a bug that causes excessive kernel ticks. Kernel ticks wake the CPU up, which wastes power, so if you keep the kernel ticks to a minimum, you won’t waste as much power. Simple enough, right? So to fix the bug (at the time this writing,) you have to install Brian Rogers’ patched kernel. Add the repository to your sources list by typing:
# sudo add-apt-repository ppa:brian-rogers/power # sudo aptitude update
Then you’ll need to install the following:
Then reboot into your new kernel. No more useless interrupts! This will most likely knock out your STA (wireless) drivers, and your touchpad drivers (if you’ve installed the one that allows you to click and drag, rather than the default, i.e. useless, one.) To fix this, you must download the Broadcom STA drivers and both patches. Then you have to download another patch here: http://bugs.gentoo.org/attachment.cgi?id=232555, go into the src/wl/sys directory, and execute:
# patch < ~/path/to/wl_linux.c.diff
Then edit src/include/linuxver.h and change the line that says “#include <linux/autoconf.h>” to “#include <generated/autoconf.h”. Finally, compile with:
# make # sudo make install
Then you’ll have to disable the b43 and ssb modules by typing:
# sudo bash -c 'echo blacklist b43 >> /etc/modprobe.d/blacklist.conf # sudo bash -c 'echo blacklist ssb >> /etc/modprobe.d/blacklist.conf
Now to fix the touchpad. Ubuntu, by default, uses tho bcm5974 module to handle the touchpad. Sadly, this driver doesn’t support click and drag with the Apple touchpad, unless you use a experimental version. However, the experimental version doesn’t play nicely with the kernel we just installed (in fact it won’t ever compile,) so we’ll use another driver called multitouch, which allows two finger click, two finger scrolling, regular clicking, and click-and-drag. So type in the following commands:
# sudo aptitude install xserver-xorg-dev # git clone http://bitmath.org/git/multitouch.git # cd multitouch # make && sudo make install
Now you need to add the following lines to /etc/X11/xorg.conf:
Section "InputClass" MatchIsTouchpad "true" Identifier "touchpad" Driver "multitouch" EndSection
Now reboot again, and you should have click-and-drag support! I’m not sure how this whole modern xorg.conf thing works, so it might get erased when you update X11. In that case, you can add it again; just remember what you did. I noticed that the mouse was quite a bit faster with the multitouch driver, so I tweaked the acceleration and sensitivity in the Gnome mouse configuration (System->Preferences->Mouse.)
The new kernel should get your power usage to around 20W. To take it down to 17W, you can change your SATA link power management policy and increase the VM Dirty Writeback time thusly:
# sudo bash -c 'echo 1500 > /proc/sys/vm/dirty_writeback_centisecs' # sudo bash -c 'echo min_power > /sys/class/scsi_host/host0/link_power_management_policy'
You might want to put these in a script of some sort that runs at startup, but I haven’t done this yet.
Finally, go into System->Administration-> Hardware Drivers, and install the latest NVidia driver. Reboot. If this took you a few minutes to do, your MacBook should be pretty hot by now. After rebooting, just for fun, let it sit for a few minutes – running all the while – and come back to it. It will feel a lot cooler. I can hardly tell that my computer is on right now, and I’ve been using it for a few hours now. According to my calculations, I should now get 6.6 hours of battery life. In real life this is probably less than accurate, but it’s a decent estimate based on the capacity of my battery (4816 mAh, or 17.34 kC, for the electrical engineers among us,) and my current power usage (an average of around 10 to 12 watts.) I’ll try to actually test this over the next few days and post an update of my actual battery usage.