Installing Ubuntu on a Macbook Air

I bought a Macbook Air 4,2 (= mid 2011) last week. Despite that my last laptop was a Macbook, I really wanted to buy no Mac again since setup is always a hassle. Unfortunately, no other notebook vendor has similar hardware for the same or lower price.

So the first thing after I got the Macbook Air and trying out the multi touch gestures in OSX was to install Ubuntu and move the profile from my old laptop on it so I could continue working. Unfortunately, it was not easy. Installing really sucked - the apple engineers and programmers did their best to make it as hard as possible to get Linux running on it.

Booting a Linux installer from a USB stick

The Macbook Air has no CD/DVD drive (since those optical media are dead for me anyway), so I wanted to use a "live usb stick" with the Ubuntu installer on it. UNetbootin is a tool that takes any Linux installation CD/DVD .iso file and puts it on a USB stick that is bootable by almost all PCs. As that always worked, I used it to put the Ubuntu 11.04 live install CD iso on a USB stick.

After installing rEFIt, the stick was detected and I wanted to boot. Guess what - it does not work. Others have the same experience : Booting from USB sticks does not work on a Macbook Air. You'll learn to hate the following errors:

Missing operating system
no bootable devices

Booting the installer CD

I managed to get the Ubuntu installation CD working by putting it on a separate partition after preparing it a bit.

Partition layout for Macbook Air with 256 GB SSD
OSX device name Linux device name Type Size Description
Original partitions
disk0s0 /dev/sda1 fat32 200 MiB EFI boot partition
disk0s1 /dev/sda2 hfs+ All the disk / 60 GiB after resizing Mac OSX
disk0s2 /dev/sda3 ??? 620 MiB Hidden Mac OSX rescue partition.
Additional partitions
disk0s3 /dev/sda4 fat32 1 GiB Ubuntu installer / boot
disk0s4 /dev/sda5 ext4 50 GiB Linux root /
disk0s5 /dev/sda6 swap 4 GiB Swap
disk0s6 /dev/sda7 ext4 10 GiB /tmp
disk0s7 /dev/sda6 ext4 110 GiB Home folders /home

With the OSX disk utility, you can resize the OSX partition and prepare the new ones, all as "fat32".

USB stick and harddisk preparation

  1. Create a msdos partition table on your USB stick. Most sticks do not have one, but we absolutely need it. GParted makes that easy: Menu "Device", "Create partition table", "msdos".

  2. Create a 1 GiB FAT32 partition on it. Give it a nice name; rEFIt will show that later when booting.

  3. Use UNetbootin on a second computer to put the install CD .iso on that partition. I used the "64-bit Mac (AMD64) desktop install CD" from the Ubuntu 11.04 alternate iso download page , but I think the normal (non-mac) 64-bit iso should work, too.

  4. Boot into OSX, open the Terminal and run

    $ sudo dd if=/dev/disk2s1 of=/dev/disk1s4 bs=1m

    This will copy the partition from the USB stick onto the fourth partition on your Macbook's SSD.

  5. Install rEFIt if you haven't done that yet.

  6. Reboot. You will see the new partition in the rEFIt menu and can boot it. It will show the UNetbootin boot menu from where you can start the Ubuntu Live CD or the installer.

    When running Ubuntu, add nomodeset to the boot options - otherwise the screen will look garbled and you won't see anything. This is necessary in at least Ubuntu 11.04 and 11.10; the fix will hopefully be in Linux kernel 3.2 after is has only recently been implemented.

Very important: You will only able to boot from the first four partitions because rEFIt uses the BIOS emulation for Linux, which means that you have to use the MBR partition table. Syncing the GPT to MBR does not give you an extended partition, so the first 4 are usable only. Keep that in mind when playing around.

Installing Ubuntu Linux

Making the harddisk writable

The Ubuntu 11.04 installer has a problem installing Ubuntu on the same disk that the installer is run from. I don't know the reasoning behind that; the error is that the a partition of the disk is already in use (the installer partition).

To work around that problem, do not start the installer but the Live CD mode, run the following commands and then start the installer:

$ sudo cp -r /cdrom /cdrom2
$ sudo umount -lfr /cdrom
$ sudo rmdir /cdrom
$ sudo mv /cdrom2 /cdrom

The rest of the installation process is as usual without any problems.

Special drivers

The Macbook Air 4,2 (mid 2011) is not very well supported by the stock kernel and software in Ubuntu. Additional work is required.

The most easy way is to use Joshua V. Dillon's post-install script, post-install-natty.sh for 11.04 or post-install-oneiric.sh for 11.10.

The script fixes the graphic driver problems, so nomodeset is not required anymore. It also fixes bluetooth, the touchpad, the keyboard layout and backlight.

Hardware support

Support status for Ubuntu 11.10, kernel 3.0.0-12-generic #20-Ubuntu.

Hardware State Description
Display Works Full 1440x900 resolution
  VGA adapter Partially Full HD resolution of TV was not recognized, worked up to 1440x900
  HDMI adapter Works All TV resolutions were detected correctly
Wifi Works No problems in 11.10, 11.04 crashed under heavy load
Bluetooth Partially My phone does not see the Macbook, works the other way round
Keyboard Works Backlight, too - Gnome shell automatically supports hotkeys
Touchpad Works 2-finger scrolling works, too
Webcam Works No problems on 11.10. Didn't work on 11.04. Cheese allows 640x480 only, although HD should be possible according to Wikipedia.
Sound Works If you hear no sound, use alsamixer to unmute both surround speakers.
Suspend Works
SD card reader Works

Other resources

The Ubuntu Wiki has a very complete guide for the Macbook Air 4,2 now.

Broken?

In case the linux system does not boot anymore from rEFIt, have a look at my solution.

Written by Christian Weiske.

Comments? Please send an e-mail.