Installing Ubuntu 12.04 on a 2012 MacBook Air (5,2)

Oh hi! So this topic is basically what drove me to writing this blog. So I bought a shiny new MacBook Air for a work computer, but the problem is I need to use Ubuntu 12.04 to actually do said work. I didn’t want to run Ubuntu on a virtual machine inside Mac OS X,  so what is a man to do but start installing a dual boot configuration. The ubuntu wiki has quite extensive coverage of MacBooks in general, but the 2012 (also known as 5,1 or 5,2 depending on the SSD size) model still lacks an article. I wanted to contribute my tutorial there, but that proved to be a way too labour intensive operation. Therefore, I shall write the installation process that worked for me down here. Hope it helps someone, at least until they manage to document it at the actual ubuntu wiki.

Anyway, now that that’s out of my chest, onward to the actual tutorial! This tutorial abides mostly by the guidelines of the MacBook Air 4,2 tutorial of the actual ubuntu wiki. I also try to clarify some steps that I felt were a tad bit fuzzy on the original doc. This tutorial is tested to work with Ubuntu 12.04 LTS.

This tutorial will make you a dual boot installation, so you can still use Mac OS X as well. For me this is perfect, because I still need to pop by OS X every once in a while to do some light photoshopping.

Step 1 – Create a bootable USB stick

The first thing we need to install something is of course the installation media. I assume you want to do everything on your shiny new MacBook, so go ahead and start it up. Boot to OS X. Don’t worry, you won’t have to endure the lion for too long. You will need a USB stick as well.

I found the best image for my Air was the special Mac image referred by the original 4,2 tutorial. You can download it here: (mirror).

After you have finished downloading the image, follow these instructions to create your bootable flash drive. Do not  boot the computer yet however.

Step 2 – Make room for Ubuntu

We now need to reduce the size of the Mac OS X partition to make some room for Ubuntu to dwell in. It is mostly up to you to decide how much room you want to leave for OS X. Since my Air has a 256GB SSD, I left OSX approximately 100GB of space to dance in, repartitioning the rest for Ubuntu’s usage.

Go to Applications > Utilities > Disk Utility and start it up. Resize the OSX partition to what you like, and format the empty space as msdos (FAT32) partitions. We will erase the msdos partition later on with the Ubuntu installer to make proper partitions.

Step 3 – Install rEFIt

We also need to install a custom bootloader that understands the weird and wonderful soul life of the MacBook’s EFI. The bootloader will allow you to choose between OS X and Linux.

Download rEFIt and install it. Follow the installation instructions and that’s it.

Step 4 – Stick in the USB and reboot

After creating the installation stick, the partition and installing rEFIt, you are ready to exit the clutches of OS X (for a while). Reboot your computer. This next step requires some quick action, so please read this step fully before executing anything to avoid unnecessary frustration

When the computer boots, you will see the rEFIt menu. This menu will now appear every time you reboot your machine from now on. Select the legacy OS option from the menu.

The screen should go blank, and then you should see the Ubuntu’s Vitruvian man+keyboard icon on the bottom of the screen. When they appear, press F6 or your computer will go to a kernel panic and crash! You should see a menu with boot options.

Set the noapic -option. This is a new problem with the MacBook Air 5,2 that hasn’t been present earlier. After you have done this, select the  Try Ubuntu from the USB stick -option.

Ubuntu should now boot up to a live version. Do not yet click on the Install now-option

If you end up with a kernel panic, please ensure that you really have the noapic option set. At least for me this was the most common cause of problems.

Step 5 – Partitioning

Now we need to make proper partitions for Ubuntu. Press the Ubuntu button at the top, and write gparted. Start gparted and use it to destroy the msdos partition. You need to make 3 partitions to make everything work.

  • Create 1 partition for the GRUB2 bootloader. 1MB with the ext2 filesystem is sufficient. Remember to set the bios_boot flag to this partition. You can also do this later on with the command line with these instructions.
  • Create a partition for swap. A good rule of thumb is to make the swap partition about the twice the size of the RAM on your computer, so basically if your MacBook has 4GB of RAM, make the swap partiton 8GB. Obviously, 8GB of rRAM means a 16GB swap partition.  Swap partitoning isn’t an exact science, so feel free to explore sizes how ever you feel.
  • Finally, create the partition to be used as the actual linux drive. Format the rest of the empty disk space as ext4. Again, other options and file systems are valid, feel free to use what ever you like.
After you are done making the changes, verify them and start the formatting operations. After you are done, you can now install Ubuntu! Click on the install Ubuntu icon on the desktop.

Step 6- Installation a go go

Let the installation scroll through. During installation choose manual partitioning. Remember to set the newly created partitions correctly (swap mounted as swap), the large ext4 mounted as /, and the bootloader set to the small boot partition. Verify everything is done correctly before moving on.

Let the installation finish. Grab a cup of coffee. Once the installation finishes, reboot. Remove the USB stick as well before rebooting.

Step 7 – Refresh rEFIt and configure GRUB

This is an easy one, press y to refresh rEFIt partition tables. The part after this again requires some precision timing, so please read this section beforehand again. You should now see a happy tux sitting next to the apple icon. Give the penguin some love by selecting him and pressing enter.

Because Ubuntu won’t boot without the noapic -flag set, you will need to add an extra flag to the GRUB kernel boot options to start ubuntu this time. When you see the GRUB -menu, press e to start editing kernel parameters. Scroll down to the entry that starts with vmlinuz- and add noapic as the last entry inside the quotation marks, like the other terms before them.

After editing, press enter to boot into Ubuntu. Even though ubuntu starts, there are still some configurations left to do in order to make it fully functional.

First, open up a terminal and start editing the file /etc/default/grub with your favourite text editor. You need to be a super user to do this, so for example:

sudo nano /etc/default/grub

Scroll down to the section marked GRUB_CMDLINE_LINUX_DEFAULT=” and add noapic inside the quotation marks as the last entry. Save and close. After this is complete, run

sudo update-grub

to save your changes in the actual bootloader. Reboot your computer, select linux from rEFIt and wait. Ubuntu should now boot with no problems.

If you have problems booting to Ubuntu, or after selecting linux from the rEFIt menu is just blank, follow these instructions (debug instructions from the Ubuntu wiki topic). Otherwise, skip these:

  1. Boot to Mac OS X
  2. Install the GPT fdisk terminal utility
  3. Follow these instructions:

Step 8 – Post installation configuration

After installation we still need to make a few tweaks. Download this file: and move it any location. Afterwards, open a terminal and run the following commands to execute the file:

 chmod a+x location/to/

. location/to/

Just say yes to the questions. They appear because the script is made for the 2011 MacBook Air, but it still mostly works with the 2012 model.

Congratulations! Now your MacBook Air is 99% usable! There are still some optional configurations and tweaks you can do to make your system more usable. You may also stop here, but why install Linux if you don’t want to fine-tune the living snot out of everything ;).

Step 9 – OPTIONAL – Fix Suspend

If you try to suspend the computer (e.g. close the lid), it will go down peacefully, but never wake up. This can be fixed by editing the grub boot parameters. First we need to find out in which device and partition the swap partition resides. To do this, run this command from a terminal

cat /etc/fstab

In the comments, you should find a line that reads like:

# swap was on /dev/sda5 during installation

this means that swap is found on /dev/sda5. Mark it down. Now we need to edit GRUB2 options again and add a new boot parameter. run

sudo nano /etc/default/grub

add resume=/dev/sda5 as a new boot flag for the kernel, where you of course replace the path with your computers one. After adding the option, the line should look something like this:

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash i915.i915_enable_rc6=1 noapic resume=/dev/sda5″

Save the file and run

sudo update-grub

Restart the machine and your hibernate should now work. However, installing some apps might still mess around with it, for example my computer immediately wakes up after hibernating if dropbox is installed.

Step 10 – OPTIONAL – Fix keyboard mappings

If you are like me and transitioning from the IBM-PC world, the mac keyboard may be a strange and scary thing to type with. No shortcuts work the way you intend them. Also if you are again like me and have strange and exotic letters in your keyboard (like åäö), you will need to use a custom keymap.

These keymaps flip the ALT and CMD-buttons, so they will work like a regular IBM PC keyboard.

First we must install xmodmap. Open a terminal and run

sudo apt-get install xmodmap

then we need to download a keymap. This is the one I use, and here’s an alternative one. Save the wanted keymap in your home directory as a file named .xModmap. You can also create your own map if you wish. Finally, run this command to activate the keymap:

xmodmap ~/.Xmodmap

Step 11 – OPTIONAL BUT AWESOME – Boot to Ubuntu by default and in no time

Okay, so this is the final little thing I did to make boot times smaller and generally more efficient. The order in which you do these two things do not matter.

You probably have noticed by now that the wait times are quite long in both rEFIt and GRUB. To reduce these, we need to edit some configurations in both. For GRUB, you need to be in Ubuntu to do the edits, and for rEFIt you need to be in OS X.


Open terminal, and again, edit the grub config file

sudo nano /etc/default/grub

find the line that says


and change the number to 0. Save and close and run

sudo update-grub

to finish the option. Now the grub waiting time is 0 seconds, so it will not even show you the grub menu.

Boot to OSX and open a terminal. We need to locate a file called refit.conf . The location varies, so the best way to locate it is to run:

sudo locate refit.conf

You might encounter an error that says you need to build a location database by running a certain command. Run that command, let it generate the database (should take a minute or two), and then rerun the above locate-command.

After locating the refit.conf file, run

sudo nano /path/to/refit.conf

Find the line that says timeout 20 and change it to

timeout 1

Then, go to the bottom of the file and find the line that says #legacyfirst. This is basically an option to set linux as the primary boot OS. Uncomment this so the line reads just


Save the file (CTRL+X) and that’s it! Reboot your computer and enjoy a relatively fast boot time (for me about 10secs).

Aand we are done! These are all the things I did to my MacBook to make it function. I’ve now used it for a couple of weeks, and it mostly works great. For a clear conscience I need to state that it has crashed a couple of times during usage, but I’m fairly confident newer updates will fix this problem. Enjoy your nice and now-functional MacBook and the scornful looks of people as they ask you why you put Linux on a Mac (in the time I’ve had this computer I’ve heard that remark at least three times now, once from a complete stranger).


Hello world!

Welcome to! This is your very first post. Click the Edit link to modify or delete it, or start a new post. If you like, use this post to tell readers why you started this blog and what you plan to do with it.

Happy blogging!