# Macbook Air (6,1) 2013 model with Ubuntu


> Assorted notes, not a step-by-step HOWTO!

How to get Ubuntu Raring (13.04) up and running on your shining new MacbookAir. Note some things
are not working (yet). This is with 3.11:

* audio (speakers don't work, plugged in headset does work), however see this 
    [latest patch](https://bugzilla.kernel.org/attachment.cgi?id=107811);
* webcam (see <http://mactaris.blogspot.co.uk/2013/07/webcam-settings-20-will-support.html> for a list of changes, it is not a UVC device anymore);
* after a resume the screen brightness only knows on/off.

Expectation for 3.12 (when released), everything is working, except:

* backlight only on/off after resume;
* no working iSight camera.

Links that may come in handy:

* <https://wiki.archlinux.org/index.php/MacBook#Mid_2013_13.22_-_Version_6.2C2>
* <http://uli-heller.github.io/blog/2013/06/24/macbook-air/>
* <http://mattoncloud.org/2013/07/18/fedora-19-on-a-macbook-air-2013-model/>

# Installation

Repartition from inside OS X, with the disk util tool (can't remember the name) from Mac OS X, just leave enough free space
for a swap partition and some Linux paritions.

Download the normal Ubuntu image and get it on an USB stick, boot from that. For Apple hardware
this means holding the Alt (option) key during boot and then selecting the USB stick for booting. You can
then install the OS. After the installation reboot. Hold the Alt key again and select Windows (yeah, yeah)...
this will bring you to the grub menu from where you can boot Ubuntu.

> Note: Doing this install results in a non-EFI install, which is bad, because, among other things, booting
> without `nosmp` will fail...

To fix the above you'll need to add `nosmp` to the kernel parameters when booting Ubuntu.
You can easily convert it to an EFI type boot later, but first fix the network, because the Broadcom chip
has a closed source driver... Also see [this German site](http://uli-heller.github.io/blog/2013/06/24/macbook-air/) for
some pointers about this.

You can optionally edit `/etc/default/grub` and add `nosmp` to the file, because without it won't boot (this is removed later).

 Post installation

Download the [closed source driver from Ubuntu](https://launchpad.net/ubuntu/+source/bcmwl/6.30.223.30+bdcom-0ubuntu2), and now you'll need 
another Ubuntu system to actually build the .deb. You can of course build it on this MacbookAir, but you'll need a 
bunch of dependencies and your network isn't working....

When you have the .deb copy it over and install it, also copy over any missing dependencies it wants (`dkms` comes to
mind).
[As this](http://uli-heller.github.io/blog/2013/06/24/macbook-air/) says, this install "hangs", abort with ^C, reboot
and try again, now it will work (?!?!?!). Reboot again: your network is working.

 Converting to EFI

Follow [this HOWTO from Ubuntu](https://help.ubuntu.com/community/UEFI#Converting_Ubuntu_into_EFI_mode) to
convert to EFI. You don't need to create any partitions, the one from Mac OS X will do fine. Note this will also
creates new grub startup files thereby deleting the `nosmp` addition to `/etc/default/grub`.

Reboot and marvel at our CPUs.

 Kernel upgrade

For some reason the mainline PPA kernels from Ubuntu hang during boot ("Loading ramdisk..."), I did not felt the need
to debug this, so I just tried to compile the latest kernel myself.

Download the latest kernel, when I did this, it was 3.11-rc6, and compile and install it yourself. Copy the `/boot/config-<version>`
kernel config to `.config` and do a

    make oldconfig

Note this kernel does not support the touchpad and keyboard, so it needs a [patch](https://launchpadlibrarian.net/148354532/macbookair-3.11-rc6.patch),
to make it work (perfectly). Then build with:

    fakeroot make-kpkg --initrd --revision 3.11rc6custom kernel_image  

And install the resulting .deb file. Reboot.

I did not install reFind to automatically boot to Linux. I reboot once a month, or less, so holding down the Alt key
12 times a year is not a big issue to me.

Some sites also list that `libata.force=1:noncq` should be given to the kernel (via grub), I do that, but still see the
errors this should prevent...

# Conclusion

The laptop is working quite nicely, but the non-working bits are a nuisance. Work is progressing fast, so I expect
a default install in the near future where everything works out of the box.

Some bugs that you can track:

* [Macbook Air 2013 boot stuck at smpboot: Booting Node 0, Processors #1](https://bugzilla.kernel.org/show_bug.cgi?id=60635)
* [Ubuntu fails to properly boot on Macbook Air 2013 6,1 & 6,2](https://bugs.launchpad.net/ubuntu/raring/+source/linux/+bug/1197450)
* [MacBook Air 6,2 (mid2013) Touchpad is Non-Functional](https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1195822)
* [MacBook Air mid2013 touchpad is not fully functional](https://bugzilla.kernel.org/show_bug.cgi?id=60181)
* [MacBookAir6,2, No sound though speakers](https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1212639)
* Kernel bug for the sound: <https://bugzilla.kernel.org/show_bug.cgi?id=60811>

Another one with this Air and trying Ubuntu (using the patch I reworked for 3.11-rc6):

* <http://blogs.aerys.in/jeanmarc-leroux/2013/08/28/ubuntu-13-04-on-the-new-macbook-air-2013/>
* <http://blogs.aerys.in/jeanmarc-leroux/2013/08/30/upgrading-to-linux-3-11-on-the-new-macbook-air-2013/>

# 3.11

Patch updated (change was removing `-rc6` from the file) to apply cleanly to 3.11. 
Download it [here](/downloads/2013/macbookair-3.11.patch), and 
apply with `patch -p1 < macbookair-3.11.patch`.

# 3.12 (unreleased)

These new USB IDs are now incorperated in 3.12, so you won't need to patch yourself anymore (for this 
problem at least).

[Patch to fix sound](https://bugzilla.kernel.org/attachment.cgi?id=107811).

