During the past few months I have written quite a few posts on Running Fedora 19 on Apple’s Macbook Air (Mid-2012). As I hear feedback from people who try out Fedora on their Macs, one of the first questions I get is about how the battery life isn’t as good on Fedora as it is in OS X. Which my answer usually is: “True, but then again, you are comparing a generic OS like Linux that is written to run on anything out there vs a pretty tuned Mac OS X that is designed to run on a very limited number of devices.”
So, tonight, I decided to do a bit of research, reading, tweaking, tuning, playing around with Power Management on Fedora 19 running on my Macbook Air. I still can’t promise comparable battery life to OS X, but honestly, what I have so far is not so bad.
First I recommend, you read Fedora 19′s Power Management Guide document. It is really well written. The rest of this post is mostly a compilation of things I did after reading the document, combined with a couple of other things I was already doing.
Note: I am assuming you are running all commands as root. If not, put ‘sudo’ in front of each command.
Other than the numbers it will give you, this tool will give you a nice set of system parameters you can use to make your laptop use less power. They are probably not going to save hours of battery life, but that’s why we are tuning, every minute helps.
$ yum install powertop
The following command will take a few minutes to run, don’t freak out. I ran mine with the macbook unplugged from the power source.
$ powertop –calibrate
Run it by itself to see your numbers, use the ‘tab’ key to navigate through the text based menu.
The coolest feature in powertop for me is the set of tunnables settings it allows you to turn on. The thing to keep in mind is that those tunnables will be reset if you reboot. On the Fedora 19 Power Management Guide you can read more about powertop2tuned if you want to make the settings persist across reboots.
A service “that uses udev to monitor connected devices and statically and dynamically tunes system settings according to a selected profile.”
$ yum install tuned
$ systemctl start tuned
$ systemctl enable tuned
To show which profile is active:
$ tuned-adm active
$ tuned-adm list
Picking power saving profile:
$ tuned-adm active powersave
If you want to see what parameters the powersave profile will modify, take a look at /usr/lib/tuned/powersave/tuned.conf
You will actually notice that there will be an overlap between the tunnables provided by powertop and tuned.
A tool that shows and sets processor power related values
$ yum install kernel-tools
The CPUfreq governors can be modified with cpupower, and you can even force certain cores to use different governors. Read the PDF in the beginning of the post for more information.
After tweaking these settings, and rebooting my machine, I have been up and running for almost 2 hours on my battery only, and according to the system the battery still 68% full. Oh, and my battery is over 1 year old. Do the math.
To make things easier for everyone reading this, I am sharing my /etc/rc.local with all my tuning explicitly ‘spelled’ out. Part of the /etc/rc.local comes from a previous post.
# echo 350 > /sys/class/backlight/intel_backlight/brightness
# the above line works, but gnome 3 overwrites it when putting
# the display to sleep. The command below takes care of it.
/usr/libexec/gsd-backlight-helper –set-brightness 4
rfkill block bluetooth
echo 50 > /sys/class/leds/smc::kbd_backlight/brightness
echo 5 > /proc/sys/vm/laptop_mode
echo ’1500′ > ‘/proc/sys/vm/dirty_writeback_centisecs’
echo ‘min_power’ > ‘/sys/class/scsi_host/host0/link_power_management_policy’
echo ‘min_power’ > ‘/sys/class/scsi_host/host1/link_power_management_policy’
echo ‘min_power’ > ‘/sys/class/scsi_host/host2/link_power_management_policy’
echo ‘min_power’ > ‘/sys/class/scsi_host/host3/link_power_management_policy’
echo ‘min_power’ > ‘/sys/class/scsi_host/host4/link_power_management_policy’
echo ‘min_power’ > ‘/sys/class/scsi_host/host5/link_power_management_policy’
echo ’1′ > ‘/sys/module/snd_hda_intel/parameters/power_save’
echo ’0′ > ‘/proc/sys/kernel/nmi_watchdog’
echo ‘auto’ > ‘/sys/bus/usb/devices/2-1.8.2/power/control’
echo ‘auto’ > ‘/sys/bus/usb/devices/2-220.127.116.11/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:02:00.0/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:1f.3/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:1f.2/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:1d.0/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:1c.4/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:1c.1/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:1f.0/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:1a.0/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:16.0/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:14.0/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:02.0/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:00.0/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:1c.0/power/control’
echo ‘auto’ > ‘/sys/bus/pci/devices/0000:00:1b.0/power/control’
echo ’1′ > ‘/proc/sys/vm/swappiness’
echo ’50′ > ‘/proc/sys/vm/vfs_cache_pressure’