Linux on a MacBook Air 2012
It’s now almost two months since I’ve got my MacBook Air. Time to write up a little review.
First, lets take a quick look at the hardware. It’s basically what I expected from Apple. It really is nice. Small, silent (as in no noticeable noise at all!) and yet still powerful enough for my workloads.
Only (major) downside: Apple seems to love glossy displays while I tend to hate dislike them.
I am pretty sure that OS X is a pretty nice system. In fact I wouldn’t recommend anyone anything else unless he or she has a good reason not to use it.
I do in fact have a (good) reason. I love tinkering with my system, and more importantly: I have a Linux setup that behaves the way I want it to. Customizing OS X in the same way that I customized Linux isn’t possible. So yes, Linux is more customizable, but you probably already knew. So lets see how running Linux on a MacBook Air works out:
Use a recent kernel ¶
And in this case “recent” means as new as 3.6. Here’s why:
Kernel panics using default boot media under arch kernel 3.5. Adding ‘intremap=off’ fixes this. Additionally, there are problems loading the ‘applesmc’ module (meaning the temperature sensors, fan, and keyboard backlight do not work). These problems are fixed in the linux 3.6-rc4 mainline kernel.
Save the power ¶
Linux still has a bad reputation regarding power management. The good news is that it works surprisingly well on the MacBook. I can get over 8 hours uptime if I don’t start compiling huge code bases.
But in order to achieve this uptime a few tweaks are necessary. Some people recommend various tools to apply the various power saving settings, I like to do it in a simpler way.
Module options ¶
I’ve created various files in
/etc/modprobe.d/ that apply the power saving settings when the modules get loaded.
> cat /etc/modprobe.d/i915.conf options i915 i915_enable_rc6=1 options i915 i915_enable_fbc=1 options i915 lvds_downclock=1 > cat /etc/modprobe.d/snd_hda_intel.conf options snd_hda_intel power_save=1 > cat /etc/modprobe.d/usbcore.conf options usbcore autosuspend=1
In addition the Bluetooth module can be disabled completely if it isn’t required. (I do need it, so I don’t have this setting active).
> cat /etc/modprobe.d/btusb.conf backlist btusb
Tweaking /proc and /sys parameters ¶
Archlinux already migrated to the new
systemd init system that includes so called
tmpfiles which provide a way to change parameters for files in
/proc (or anywhere else) at boot time.
Using Intels wonderful powertop utility I’ve created a report that displayed all the parameters that can be tweaked. Based on that report I created a tmpfile that looks like this:
> cat /etc/tmpfiles.d/powersavings.conf w /sys/class/scsi_host/host0/link_power_management_policy - - - - min_power w /proc/sys/kernel/nmi_watchdog - - - - 0 w /proc/sys/vm/dirty_writeback_centisecs - - - - 1500 w /sys/bus/usb/devices/2-1.8.3/power/control - - - - auto w /sys/bus/usb/devices/2-1.8.2/power/control - - - - auto w /sys/bus/usb/devices/2-1.8.1/power/control - - - - auto w /sys/bus/usb/devices/4-188.8.131.52/power/control - - - - auto w /sys/bus/usb/devices/4-184.108.40.206/power/control - - - - auto w /sys/bus/usb/devices/4-220.127.116.11/power/control - - - - auto w /sys/bus/usb/devices/4-1.8.3/power/control - - - - auto w /sys/bus/usb/devices/4-1.8.2/power/control - - - - auto w /sys/bus/pci/devices/0000:00:1f.0/power/control - - - - auto w /sys/bus/pci/devices/0000:00:02.0/power/control - - - - auto w /sys/bus/pci/devices/0000:00:14.0/power/control - - - - auto w /sys/bus/pci/devices/0000:02:00.0/power/control - - - - auto w /sys/bus/pci/devices/0000:00:1f.2/power/control - - - - auto w /sys/bus/pci/devices/0000:00:1d.0/power/control - - - - auto w /sys/bus/pci/devices/0000:00:1c.0/power/control - - - - auto w /sys/bus/pci/devices/0000:00:1c.1/power/control - - - - auto w /sys/bus/pci/devices/0000:00:1b.0/power/control - - - - auto w /sys/bus/pci/devices/0000:00:1a.0/power/control - - - - auto w /sys/bus/pci/devices/0000:00:16.0/power/control - - - - auto w /sys/bus/pci/devices/0000:00:1c.4/power/control - - - - auto w /sys/bus/pci/devices/0000:00:00.0/power/control - - - - auto
And setting laptop_mode never hurts:
> cat /etc/tmpfiles.d/laptop_mode.conf w /proc/sys/vm/laptop_mode - - - - 5
Other than that all I do is reduce the backlight as much as I can. Depending on the environment where I am working.
So much about power saving. The only party pooper is the wlan module, which doesn’t support a power saving mode and consumes quite a lot of power.
The keyboard ¶
Apple somehow thinks that the special functions on the F1-F12 keys are more important than the regular functions. I have a slightly different opinion on that matter. Luckily there is an easy solution for that:
> cat /etc/modprobe.d/hid_apple.conf options hid_apple fnmode=2
Applying this setting will make
F1 a real
F1 and not “decrease backlight brightness”. To do that you still got
If you wanted to get the keyboard backlight working you’d have to install pommed. I don’t like the backlight so I didn’t bother.
I am still not a hundred percent happy with my touchpad settings. I use the synaptics drivers and setting
FingerHigh already helped a lot over the defaults:
> cat /etc/X11/xorg.conf.d/10-synaptics.conf Section "InputClass" Identifier "touchpad catchall" Driver "synaptics" MatchIsTouchpad "on" MatchDevicePath "/dev/input/event*" Option "FingerHigh" "50" Option "TapButton1" "1" Option "TapButton2" "2" Option "TapButton3" "3" Option "PalmDetect" "1" EndSection
And I also have
syndaemon running that disables the touchpad if I am typing.
> syndaemon -t -k -i 2 -d &
The bad and ugly: Thunderbolt ¶
The tldr version is that Thunderbolt support is currently a pain in the ass. It’s so bad that in very weak moments I sometimes consider switching to OS X. (Just kidding, I wouldn’t do that)
Coldplugging works just fine. If you turn on the notebook with the display connected and don’t unplug it until you’re done there is nothing to worry about.
Hotplugging doesn’t work. If you want to walk around and get back later to the Thunderbolt monitor you’re out of luck.
Even worse is that a solution to the issue isn’t very likely to appear ever. According to Intel developers the kernel does support the Thunderbolt hotplugging just fine. It is the BIOS that gets it all wrong and is sending some invalid values. So unless Apple starts to think that properly supporting Linux would be a good idea we’ll never see a fix.
Tiny solace: Connecting a regular monitor using a mDP adapter works fine.
There is also an issue that will degrade the performance of the notebook if connected to a Thunderbolt display. But that can be fixed by disabling polling:
> cat /etc/modprobe.d/drm_kms_helper.conf options drm_kms_helper poll=N
It’s slow ¶
There seems to be a kernel regression with the cpu_ondemand module. So the cpu always runs with only 800 MHz instead of increasing the speed on high load.
This can be fixed by changing the
> echo 70 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
Unfortunately by changing this value it takes the cpu longer to adjust the speed back down once the load disappears and therefore increases the power consumption.
Starting with Linux 3.10 the
intel_pstate driver is in use. Therefore it is
no longer necessary to change the
The system should feel way snappier since the cpu frequency can be adjusted faster. But apparently under certain workloads power consumption might be increased.
If having a long uptime is more important then performance try adjusting the
Linux 3.17 will include patches that should make Thunderbolt work on Apple hardware
Uh, so much trouble, is it really worth it? ¶
Of course it is!