How to Install (And Dual Boot) Ubuntu In Macbook Air (5,2)

ubuntu-mac-mainI love Apple for their hardware, but when it comes to the desktop OS, I much prefer Linux (Ubuntu) over the OS X. I recently got myself a MacBook Air (the 2012 version, 5,2) and unsurprisingly, after using the Lion (and subsequently the Mountain Lion) as the default for two months, I have switched to using Ubuntu as the default OS. The installation process is not as easy as previous build of MBA. If you are keen to install and dual boot Ubuntu on your MacBook Air (5,2), here is the full tutorial.

1. Create a bootable Ubuntu USB Installer

If you have an external CD-ROM, it is easier to burn a Ubuntu LiveCD and boot from the CD. For me, I prefer to use the USB installer instead.

Note: The usual method of creating the USB installer using the Startup USB Creator tool in Ubuntu will not work in work. You have to follow the steps follow to get it to work.

1. In your Mac, download the 64-bit Mac (AMD64) desktop CD iso.

2. Once the download is completed, plug in your USB drive and open a Terminal (Applications -> Utilities -> Terminal).

3. Convert the iso file to img format with the following command:

hdiutil convert -format UDRW -o ~/path/to/ubuntu-12.04.1-desktop-amd64+mac.img ~/path/to/ubuntu-12.04.1-desktop-amd64+mac.iso

Replace the “/path/to” with the actual location of the iso file (you can drag and drop the iso file to the terminal to paste the file location).

4. Check the location of your USB drive:

diskutil list

ubuntu-mac-usb-disk-number

5. Unmount the USB drive:

diskutil unmountDisk /dev/diskX

Replace “diskX” with the USB drive disk number.

6. Run the following command to create the USB Installer:

sudo dd if=/path/to/ubuntu-12.04.1-desktop-amd64+mac.img of=/dev/rdiskX bs=1m

Don’t forget to replace the “path/to” and the “rdiskX” with the file location and disk number respectively.

7. Lastly, eject your USB drive.

diskutil eject /dev/diskX

2. Install rEFit

rEFit is a boot menu toolkit that can detect multi-boot system on Mac and allows you to boot into another OS easily.

1. Download the latest version of rEFit from here.

2. Install it in your Mac.

3. Partition the Mac hard drive

The next step is to partition your Mac to make space for Ubuntu. Open the Disk Utility (Applications -> Utilities -> Disk Utility)

1. On the left panel, select the Mac SSD. On the right, click the “Partition” tab.

2. Select “2 partitions” from the Partition Layout dropdown. You should see the partition layout become two equal containers.

3. Highlight the bottom container (the partition to use for installing Ubuntu). Give it a proper name and select “MS-DOS (FAT)” for the format. Next, change the hard disk size you want to allocate for Ubuntu.

ubuntu-mac-partitioning

4. Click Apply.

Once you have partitioned the hard disk, you are ready to install Ubuntu.

4. Boot into Ubuntu Installer

1. Plug in your Ubuntu USB Installer and reboot the Mac.

2. On the rEFit screen, press the right arrow to select the USB installer, and press and hold the “Ctrl” button while the USB installer is booting up. (Note: Failure to do this step will result in kernel panic)

ubuntu-mac-refit-bootscreen

3. On the Ubuntu boot option screen, first select English (or your preferred language) as the default language. Next, before you select any boot option, press F6. Scroll down the list to “noapic” and press “Enter” to select it (make sure there is a “X” beside the “noapic” option).

ubuntu-mac-noapic

4. Press Esc, and select “Install Ubuntu”. This will skip the Ubuntu Live Desktop and boot directly to the Installer.

5. Follow the onscreen instructions to install Ubuntu until you reach the point where it asks you to select the “Installation Type”. Select the last option “Something Else”.

ubuntu-mac-installation-type

6. The partition table will now show up. You need to delete the FAT32 partition and create two other partitions – one for Swap and another for Ubuntu installation (ext4 format). The general rule of the thumb for the Swap size is to allocate twice the RAM size, up to a maximum of 4GB, so if you have 4GB or more RAM, make the Swap size 4GB. Leave the rest of the free space for Ubuntu.

Note: Some people will opt to create another partition for the GRUB installation. This is purely optional.

Before:

ubuntu-mac-before-partition

After:

ubuntu-mac-after-partition

Make sure you select the correct partition for the boot loader installation.

ubuntu-mac-grub-install-partition

Once you have completed this partitioning step, you can proceed to install Ubuntu.

5. Reboot

After you have installed Ubuntu, remove the USB drive and reboot your Mac. On the rEFit boot screen, you should now see a new Penguin icon. select it.

ubuntu-mac-penguin-icon

1. When the Grub menu show up, quickly press “e” to edit the entry (we need to insert the “noapic” flag, else it will lead to kernel panic).

2. Scroll down to the entry that starts with “vmlinuz” and add “noapic” (without the quotation) at the end of the line, just before the closing quotation marks.

3. Press enter to boot into Ubuntu.

Note: If you are seeing a dark screen instead of the GRUB menu, you have to:

1. Boot to Mac OS X
2. Install the GPT fdisk terminal utility
3. Follow these instructions to build a hybrid boot menu.

If everything goes fine, you should be able to boot into Ubuntu now.

6. Post Install

There are some fixes and tweaks that we have to perform before Ubuntu can function properly.

Open a terminal and type:

wget http://pof.eslack.org/archives/files/mba42/post-install-precise.sh
chmod a+x post-install-precise.sh
./post-install-precise.sh

It will issue a warning that the script is not meant for your version of Mac. You can ignore it and continue the installation process. The script It will add a few PPAs and install a few important fixes, including macfanctld (CPU fan control), lightum (light sensor), broadcom-sta (wireless card driver), xmodmap (key mapping), suspend, etc.

Next, install the updated applesmc kernel module that works with the 2012 MBA.

sudo apt-get install applesmc-dkms
sudo modprobe applesmc

Lastly, we need to add the “noapic” flag to GRUB so the OS can be booted correctly the next time round.

sudo nano /etc/default/grub

In the file that loads up, scroll down to find the line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.i915_enable_rc6=1 resume=/dev/sdaX"

Add “noapic” to the end of the line, just before the closing quotation mark. It should become like this.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.i915_enable_rc6=1 resume=/dev/sdaX noapic"

Save (Ctrl + o) and exit (Ctrl + x) the file. Update the Grub.

sudo update-grub

That’s it. You should be able dual boot Ubuntu on your Mac now.

Things that are not working on Ubuntu

Most of the stuff should work fine in Ubuntu, but I have come across a few things that are not working well in Ubuntu.

1. Screen Lock

I have not been able to lock the screen through the gnome-screensaver or keyboard shortcut. The only way is to remove the “gnome-screensaver” and install “xscreensaver” instead.

sudo apt-get autoremove gnome-screensaver
sudo apt-get install xscreensaver
xscreensaver

2. Touchpad

The Mac touchpad doesn’t work as well as in OS X. You can install TouchEgg (compile and install from the source for the latest version) and/or follow these instructions to make the touchpad easier and better to use.

Update: I have updated to Ubuntu 12.10 without any issue. There is no need to set the “noapic” flag during boot up and the WiFi module works great.
I will keep this list updated. Check back for more details. If you come across things that don’t work and its fixes, do let us know in the comments too. For more detail, check out this post: How to Install Ubuntu 12.10 In Macbook Air

Do you like what you read here?

Receive the latest update in your inbox.

Or connect with us:

45 Comments

  • aldur

    Lockscreen is not working because of these lines:

    # no password after resume (like mac)
    echo “Disable lock screen after resume.”
    gsettings set org.gnome.desktop.lockdown disable-lock-screen ‘true’

    Anyway, thanks for the how-to, it’s great :D

    Reply

    • Damien

      Make sure you have selected the whole Apple SSD and not the Macintosh HD on
      the left pane. The partition tab will appear when you have selected the
      correct entry.

      Reply

  • marian

    I will try this HowTo on my new MBA which I will get next week. I never used a MAC beffore and have the following questions:

    1) Is the recovery partition also working after figuring out this steps? What are the stepts to recover the OSX, if I want to do this for e.g., warranty!

    2) rEFit: http://refit.sourceforge.net/ – The homepage says that: 2010-03-07: Version 0.14 was released. This software is working for the current OSX? Semms that the software is no longer in development.

    THX

    Reply

  • Knightwise

    Very ver bery good howto. Have ypu thpught abput submitting it to the ubuntu manuals ? It would be great support for the community. Excellent work !

    Reply

    • Damien

      Two things:

      1. The bug is based on the 5,1 MBA while this article is based on the 5,2
      MBA.

      2. The bug happened on Ubuntu 12.10 while the article is based on 12.04.

      Personally I have not encountered such issues because, as mentioned above,
      I don’t have a 5,1 and I am still running 12.04 on the machine.

      Reply

  • Josh Biggs

    So I have a 5,2 and installed 12.04 and am getting this bug. I was able to get to the installation by turning off the NOAPIC flag like you suggested (i should read directions better!) but now I’m getting the back screen upon first boot. Troubleshooting the hybrid mbr piece now.

    Reply

  • mlux82

    On step 5 you wrote: “Note: If you are seeing a dark screen instead of the GRUB menu, you have to:” I tried to install Ubuntu 12.04 on an other device (my girlfriend’s MBA 11″ mid 2012). After selecting the Tux-Symbol on rEFit, I see a black screen with a lonely blinking cursor. Grub is not loading/displaying.
    You are writing about a dark screen. I am not familiar with OSX and UEFI. My questions: 1) is this the same problem, your how-to solves (note, my screen is not only black – a cursr is blinking)? 2) is it possible to damage my system (not able to boot into OSX) after using “GPT fdisk” ?

    Reply

    • Damien

      Yes, I have the black screen issue too. As mentioned above, I install the
      GPT fdisk terminal utility and build a hybrid boot menu and everything just
      work. It won’t break your system.

      Reply

      • mlux82

        Yesterday, I solved the problem with the following workaround:
        On rEFit menu, I selected “repair partition table” and pressed “z” for yes.
        After that I got the message “no Operating System found” after selecting the Tux-Symbol to boot in Ubuntu the first time.
        So I went back to OSX and deleted and created the Linux partition again (as described above in this article).
        Then I did a fresh Ubuntu install again and it works now.
        Thanks Damien. I think your solution would also work. But this was a little bit too hot for me :) So I am happy that it works now!

        Reply

  • Damien

    Just an update, I have upgraded to Ubuntu 12.10 without any issue. The bootup works by default without having to set the “noapic” flag. The full tutorial will come soon.

    Reply

    • mlux82

      Yeah! Really nice news – Thanks! One question: was it an “upgrade” from 12.04 to 12.10 or a clean fresh install of 12.10??

      Reply

      • Damien

        I didn’t try the update using Ubuntu 12.04 update manager because it always fail on me. I did it via the USB installer. When you boot up from the USB drive, it will prompt if you want to do an update or fresh install. I select the “Upgrade to 12.10 from 12.04″.

        Reply

  • Mikael

    Hi, I tried to do a reinstall from my 12.04 yesterday (11″ Macbookair mid2012). I get passed the grub-loading and the system starts to load. During the boot process some process fails (its to fast to recognize and I cannot find it in the logs). I get thrown into the shell. If I wait another 2-3 minutes the desktop tries to load and I encounter a black screen. The only way to break this is to press the powerbutton. This halts the system in a standard manner. I’ve tried noapic and nomodeset options but with the same result. 12.04 works flawless on a custom 3.4.4 kernel.

    Reply

  • Jason

    Damien, thanks for the detailed steps and the responses. One question I have. Once you have Ubuntu up and running is it possible to kill the OSX partition?

    I ask because my company is forcing me into a Mac but I want to stay on a PC and Linux. I am cannot stand Mac OS.

    Thank you

    Reply

    • Damien

      Yes, you can if you want, but you have to make sure you have the osx backup if you want to restore it in the future.

      Reply

  • Isak

    When I do step nr. 6 it says: ‘No such file or directory’

    I am sure that I put everything right in with the location and the disk number. I have not renamed the file. PLEASE HELP!!

    Reply

  • abdul

    Hello i have followed your steps though m failing to get the bootable usb option with ubuntu image in grub menu. Everything worked fine until step 4 “Boot into Ubuntu Installer”. Can u please help me.

    Reply

  • Rajin

    I tried installing this but when installing the Ubuntu, it goes to a black screen and a purple letter shows, help if you can.

    Reply

  • Brian Harkness

    I did this a few times and get to the rEFIt screen, choose the external disk and get the “no operating system.” the dd’d image boots in another non mac machine and is seen as a CD ROM. I tried a different USB but get the same nonsense. I ordered an Apple Super Drive off of EBay:-( Hopefully it will load a burned CD rom.

    Reply

    • Tremaine Sterling

      Have you figured it out yet?

      If not I’ll think I know what you are talking about. I used rEFInd instead of rEFIt, which did make follow the instructs a little different. But when restarted in the rEFInd menu there were several I got several icons that all pointed to the USB. I chose the referred to icon but got the error you got. I tried several times before deciding to take a shot in the dark and choose one of the other icons which actually lead to the rest of the install. So if there are any other icons listed try one of those.

      NOTE: After installing I had a terrible time trying to get back to the Mac side. I kept getting a white folder with a ? mark. After calming down from my freak out (and playing with Linux for a bit) I found this http://support.apple.com/kb/TS1440?viewlocale=en_US , the first step is what worked for me, the Option key. But I absolutely recommend backing up your computer before doing anything. I normally do, but assume everything would go off according to the instructions but that wasn’t quite so. Now that I’m back on the Mac side I can finish the post installation and hybrid menu.

      Reply

  • Tremaine Sterling

    For anyone who has the problem on Mountain Lion

    I followed instructions from http://www.rodsbooks.com/ubuntu-efi/ to install Ubuntu without the need for hybridMBR (I’ve learned my lesson). I must I completely forgot but GOD put in mind to check the install instructions for rEFInd http://www.rodsbooks.com/refind/inst…html#installsh. Going back I realized I completely forgot to “bless” the drive. Which was more than completely important. I thought the idea od partioning the drive to share data between Mac and Linux was a great idea. Now to save you the trouble this is what I did with GOD, google, and some knowledgeable people out there. In mountain lion I had no choice but to choose FAT, exFat, or between two journaled choices. I choose journaled since it seemed easiest to work with. I followed instructions I had found to disable journaling the changed the permissions. The easiest I found is to:
    On the Mac side of course:
    Open Disk Ultity
    Select the drive
    Press and hold down the Option key then select File
    Then the Disable Journaling option should be available to select

    After that change the permissions which I found http://www.makeuseof.com/answers/cha…ard-drive-mac/.

    I thank The Lord for guiding me through. I now finally can read and write on both sides. YAY!!!!!

    Reply

  • Joshua

    Error:
    hdiutil: convert failed – No such file or directory

    this is from number 3, using newest mac, what should I do?

    Reply

Leave a Reply