Installing Ubuntu on a Macbook Pro (Retina 13″)

Or two ways to install Ubuntu 13.04 on a ‘MacBook Pro, 13″ with Retina display’ (also known as MacBookPro10,2)…

Having recently joined Canonical, my first task was to provision a laptop to work on, naturally running Ubuntu. Asking for advice about which models to choose, I was advised to seek out designs with Intel wifi & graphics adaptors, presumably down to the quality of the open source drivers available. The 13″ retina MacBook has a screen I wanted to use, and met half the criteria – it uses Intel graphics. I was also encouraged to believe that installing on a modern Mac had gotten a lot easier than the information readily available suggests, so I gambled on the wifi requirement. It seems to have paid off.

The major decision is how to host OS X. You need to maintain a copy to host the firmware updates occasionally issued by Apple – they make no pretense to support anything other than OS X as a host for these.

You can elect to have OS X on an external drive, or keep an internal partition with it on. The first implies that when the external drive is not connected, the PC will be ‘single booting’ to Ubuntu, and the internal storage can be entirely managed by Ubuntu. The second option implies a ‘dual boot’ setup, and dividing the internal storage between the two operating systems. Having chosen a single boot or dual boot configuration, a secondary decision is how to select between this OS X instance and Ubuntu at boot time. The Mac’s boot manager ‘Startup Manager‘ can easily cope with multiple boot options, but it does prefer to manage instances of OS X. I only enjoy using it when it can be used as with OS X, booting straight to some preferred default unless keys are held down. rEFInd is an excellent alternative boot manager, and I’ve used it in the dual boot configuration.

To dual boot

You need:

  • The MacBook
  • A bootable usb key with a 64-bit Ubuntu 13.04 image on it
  • rEFInd. You can download this during the process
  • A wifi network your Mac can join

The basic steps

  1. Boot OS X, and get the latest updates. Adjust the volume if you want to mute the boot chime
  2. Shrink the partition hosting OS X with ‘Disk Utility’
  3. Install rEFInd
  4. Install Ubuntu, using the 3rd party software offered (that’s where the wifi drivers are)
  5. Fix a couple of audio bugs

More detailed steps

  1. Boot the Macintosh, and walk through the OS X setup
  2. Now’s a good time to adjust the volume. If you mute now, the boot chime will also be muted – Ubuntu lacks a tool to control the boot chime.
  3. Allow OS X to update (via the App Store). This may take a few cycles, if several updates need applying in sequence, and will catch any firmware updates already issued.
  4. Using Disk utility, resize the partition hosting ‘Macintosh HD’ to the amount you want. This will silently include the OS X recovery partition, so I went for 30G.
  5. Restart OS X, and download ‘rEFInd’
  6. Install rEFInd, using the –esp option if you’d like to keep it independent of your OS X install.
  7. Restart, and confirm that rEFInd is now part of the boot sequence.
  8. Insert your Ubuntu USB key (use a 64-bit, not 64-bit Mac image, see notes below), and restart. Select the offered ‘EFI\boot\grubx64.efi’ to start the setup process
  9. Elect to ‘Install Ubuntu’
  10. Elect to ‘continue’ after selecting your language. You’ll have been informed you’re currently offline by a notification window.
  11. Elect to ‘Install this third party software’ and continue. This is where your wifi driver is coming from.
  12. Elect to set up the ‘Broadcom Corporation BCM4331 802.11a/b/g/n’, selecting ‘connect to this network’, and configuring your wifi details. ‘Connect’ attempts to connect, and you use the same button a second time (as ‘continue’) to proceed if the connection works.
  13. Choose ‘Install Ubuntu alongside Mac OS X’, and then ‘Install Now’.
  14. Select your location, and continue.
  15. Select your keyboard. In my case ‘English (UK) – English (UK, Macintosh)’ seemed sensible.
  16. Enter the details for your user account
  17. Allow the install to complete.
  18. Once you’ve first logged in, allow Ubuntu to pull down the updates since the CD image you used was mastered.
  19. After it reboots, and you log in, you may find your audio is mute. In which case, you’ve been bitten by bug 1169984, and you need to follow the workaround listed. When I wrote these notes the fix hadn’t made it to the auto-update set.
  20. You will find the built in microphone doesn’t work. To enable this, the snd_hda_intel module needs to be explicitly informed which model it is running on, so add:
    options snd-hda-intel model=mbp101
    to the file /etc/modprobe.d/alsa-base.conf (sudo nano /etc/modprobe.d/alsa-base.conf is a good choice, if you’re used to mac editors), and reboot one last time.
  21. You’re done!

To single-boot

You will need:

  • The MacBook
  • A bootable usb key with a 64-bit Ubuntu 13.04 image on it
  • An external drive you can install OS X to. I used a 32Gb USB key. Slow, but I won’t be running this often!
  • A wifi network your Mac can join

Note that rEFInd is not needed – whenever you want access to OS X, Apple’s Startup Manager can offer the option.

The basic steps

  1. Boot OS X and get the latest updates. Adjust the volume if you want to mute the boot chime
  2. Restart, and ask the Mac to boot its recovery partition. (Hold down ‘option/alt’ while it boots)
  3. Install a copy of OS X on your external drive
  4. Install Ubuntu, replacing the internal OS X, using the 3rd party software offered (that’s where the wifi drivers are)
  5. Fix up the Ubuntu EFI install, so the Mac Startup Manager can understand it
  6. Fix a couple of audio bugs

Whenever you want to boot to OS X you need to insert your usb key, and use ‘option/alt’ during boot to select it.

More detailed steps

  1. Boot the Macintosh, and walk through the OS X setup
  2. Now’s a good time to adjust the volume. If you mute now, the boot chime will also be muted – Ubuntu lacks a tool to control the boot chime.
  3. Allow OS X to update (via the App Store). This may take a few cycles, if several updates need applying in sequence, and it will catch any firmware updates already issued.
  4. Restart, holding down ‘option/alt’ (the label depends on your keyboard) as the boot starts, to get the Apple Startup Manager. Select the Recovery partition, and boot that.
  5. Insert your external drive, and if needed, use Disk Utility to arrange for it to have a single ‘Mac OS Extended (Journaled)’ partition with the device using a ‘GUID Partition Table’ (This part is in Options). Note that the utility will allow space for a recovery partition also. Quit to return to the recovery menu.
  6. ‘Reinstall OS X’, selecting your external drive as the target. The setup wizard can be configured as you wish, and it appears that an Apple ID is optional to set up the OS, and receive firmware and OS updates.
  7. Boot this version of the OS, and take the chance to make sure it is up to date. Shut it down, and remove the external drive.
  8. Insert your Ubuntu USB key (use a 64-bit, not 64-bit Mac image, see notes below), and boot to the Startup Manager using ‘option/alt’. Select one of the ‘EFI Boot’ options (both seem to work equally well).
  9. Select ‘Install Ubuntu’
  10. Elect to ‘continue’ after selecting your language. You’ll have been informed you’re currently offline by a notification window.
  11. Elect to ‘Install this third party software’ and continue. This is where your wifi driver is coming from.
  12. Elect to set up the ‘Broadcom Corporation BCM4331 802.11a/b/g/n’, selecting ‘connect to this network’, and configuring your wifi details. ‘Connect’ attempts to connect, and you use the same button a second time (as ‘continue’) to proceed if the connection works.
  13. Elect to ‘Replace Mac OS X with Ubuntu’. Given that we’re effectively taking over the machine, the wizard knows how to offer full disk encryption and LVM support. Use them if you wish, and enter the necessary encryption key if you do.
  14. Check the final dialog is proposing to install on the internal disk, and then start the install proper.
  15. Select your location, and continue.
  16. Select your keyboard. In my case ‘English (UK) – English (UK, Macintosh)’ seemed sensible.
  17. Enter the details for your user account
  18. Allow the install to complete.
  19. Reboot when prompted, removing the Ubuntu USB key.
  20. The Startup Manager thinks a bit, and then gives up, prompting you with a Folder icon with a question mark. Insert the Ubuntu USB key, and after booting it, elect to ‘Try Ubuntu without installing’. We’ll use Ubuntu to patch things up with Startup Manager.
  21. Bring up a terminal, mount your EFI partition (a relatively small FAT32 partition), and rename the bootloader ubuntu installed to have the default EFI name:
    $ sudo mkdir /boot/efi $ sudo mount /dev/sda1 /boot/efi $ sudo mv /boot/efi/EFI/ubuntu /boot/efi/EFI/BOOT $ sudo mv /boot/efi/EFI/BOOT/grubx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI
    You can now shutdown Ubuntu and remove the USB key. There may be other more sophisticated ways to patch up what Ubuntu and Startup Manager can agree via the dialect of EFI they have in common, but setting the bootloader name to the default works for now.
  22. Boot the machine, and it will take you straight to Ubuntu.
  23. Once you’ve first logged in, allow Ubuntu to pull down the updates since the CD image you used was mastered.
  24. After it reboots, and you log in, you may find your audio is mute. In which case, you’ve been bitten by bug 1169984, and you need to follow the workaround listed. When I wrote these notes the fix hadn’t made it to the auto-update set.
  25. You will find the built in microphone doesn’t work. To enable this, the snd_hda_intel module needs to be explicitly informed which model it is running on, so add:
    options snd-hda-intel model=mbp101
    to the file /etc/modprobe.d/alsa-base.conf (sudo nano /etc/modprobe.d/alsa-base.conf is a good choice, if you’re used to mac editors), and reboot one last time.
  26. You’re done!

Notes

If you’ve got one, the Thunderbolt ethernet adaptor works, and removes the need to install 3rd party software at install time to get on the internet. I assume you could then choose exactly which third party software you install post-setup, and get the wifi that way.

As far as what works, the screen is gorgeous, but I think it’s worth tweaking font sizes and so on to trade readability & screen real estate (Unity Tweak Tool is your friend). I like that Ubuntu gives me more choices here than OS X. The ‘function’ keys above the keyboard work similarly to OS X, with all but the launchpad (!) and mission control buttons mapping to Ubuntu functions. The keyboard & screen backlights work, as do the audio controls. The trackpad can be configured to support two finger scrolling in the same fashion as OS X, if you’re like me and already habituated to that.

It appears that an Apple ID is optional during setup of your OS X image, and the App Store still provides OS and firmware updates to machines without a logged in ID.

FWIW, I can see no reason you couldn’t configure a dual boot system to encrypt the Ubuntu installation, but the wizard can’t help you, and I’ve not explored the options (my machine single boots).

If you’re willing to live without OS X entirely you have two recovery options if you want to uninstall Ubuntu and return to OS X. You can create a standalone recovery USB key (needs less space than an OS X bootable disk), or you can depend on the internet recovery mode available in the Apple Startup Manager.

Ubuntu 13.04 is available in at least 3 desktop flavors: 32bit, 64bit, and ’64bit Mac’. Whilst the 32bit one clearly can work (I tried it, the OS did boot), you end up using a BIOS compatibility shim that Apple seem to have only intended for use with Windows. Having used the plain 64 bit install a lot while writing this, I did briefly try the mac flavour. My notes are poor, but I recall it didn’t work well on this modern Mac. Given the current support in the standard 64 bit installer, there seems to be no need to use it. Fortunately the default download page contains apparently good advice to select the standard 64 bit verson for a modern PC.

The built in microphone not working had me puzzled for a while, and I used a USB headset until I found the workaround. I was looking for information on hotplugging thunderbolt (which seems not to work yet), and found an installation guide for Fedora 18 that noted the crucial step of letting snd_hda_intel know it is running on an mpb101. With this step the built in audio is fully functional.

I am indebted to James Jesudason for his tutorial for installing on the 15″ Macbook for setting me on the right track.

21 thoughts on “Installing Ubuntu on a Macbook Pro (Retina 13″)

  1. Pingback: Firmware updates for MacBooks that don’t dual boot OSX | Train of Thought

  2. Ataul

    I’ve recently joined a dev team where I was given the option of a Mac or Thinkpad, and I chose Mac as I could have Ubuntu/Mint and OSX for Photoshop. I hadn’t factored in that Mint certainly wasn’t capable of handling a retina screen (15″) and Ubuntu appears very very small.

    Is the Unity Tweak Tool enough to modify display settings such that text, icons and panels are all crisp AND readable? Are there any areas which don’t scale well, even with the unity tool? (In applications I mean). Thanks, will give it a try later on today but would appreciate any pointers/configurations that have you feeling satisfied!

  3. John Post author

    Yes, I use unity tweak tool and all the dev tools I use frequently (mostly emacs and terminals) work well at whatever you tweak the font size to be. Stuff I’ve installed like QT creator and the Android studio appear to ‘just do the right thing’.

    The exception is firefox, which works better for me if I use the ‘no squint’ firefox plugin to adjust the default rendering size.

    One other gotcha is that when you plug in an external monitor, it will inevitably be a lower dpi, so I found I tuned unity tweak tool to a happy medium for terminals, etc as they moved between screens, and and I flip firefox windows nosquint settings by hand as I move them between monitors.

    This will presumably get fixed when external monitor support at a different DPI is added to Unity (or wherever in the stack that belongs!)

    For me, this has been a small price to pay for huge, high res terminals, websites and emacs windows :-)

  4. John Post author

    I still like it! As noted above, the change in pixel density on an external monitor is not ideal, but that aside, it’s all good. The screen is still great. Thunderbolt hotplugging still doesn’t appear to work, but the display subsystem (perhaps technically displayport?) hotplugs well.

  5. ben101

    Hi John, thanks for your great guide. I find it especially useful because I want to use Ubuntu in single boot mode. However, my Macbook Pro 10,1 does not resume from suspend-mode. Instead, it seems to work for a few seconds after re-opening the lid and then freezes. Did you come across this problem while using ubuntu?

  6. John Post author

    I haven’t seen this problem. I don’t know what the differences are between Macbooks to suggest what might be the cause.

  7. ben copeland

    any luck on getting the SD card to work? I got the same model MBP on 13.10, would be very useful to get sd card to work.

  8. John Post author

    Seeing your comment, I realised I had never actually used that slot on my machine :-) So I stuck in an SD Card I found, and it appears to work fine. Right now, the machine has recently been distro-upgraded to 13.10, so I think SD on 13.10 ‘works for me’. I’m not aware of having done anything to achieve that :-/

  9. Juha

    Thanks for the guide. I’m having little problems.

    Refind is installed and it sees my ubuntu usb stick fine, but when I try to boot it to start the installer i get to the “grub” screen where I select Install Ubuntu option. After that the screen goes blank and after a while i end up to command prompt, or initramfs mode.

    What could be the problem here?

  10. Juha

    Got the installing problem fixed, but now I have another problem.

    My Ubuntu install works pretty well, but only problem I have is when I leave my MBP to idle for a long time. Last night when I went to bed i left my laptop to sync some android sources and when I woked up this morning and tried to start using the laptop again, i couldn’t get it to wake up. The screen “turned on” but it stayd blank, no mouse cursor or anything.

    Any ideas what could I do to fix this. I installed 13.10 using the normal desktop ISO file (not the mac version).

  11. Jason Kennedy

    I’d like to recover my system back to OSX, but the OSX recovery and disk partitioning tool won’t allow me to delete or re-partition the linux partitions. Do I need to boot up with a linux usb stick and delete all of the partitions there?

  12. John Post author

    That wasn’t my experience when I was experimenting with installing Ubuntu as I wrote this post (now some time ago). I took my machine back to virgin-osx state several times, using the recovery tools to repartition. Perhaps someone else can comment on how to get this working for you?

  13. Patrick M.

    Jason -

    I have the same problem with OSX Mavericks, but I hit corruption when deleting the new partition – that is, when trying to add the space used by it back into my “main” partition.

    I re-ran the “verify disk” while booted from the recovery mode, and it reported no errors, but now I have a partition labeled “free space” that I can’t use nor delete – I can’t even change the type or name of it :-(

    I have file vault / encryption enabled for the entire partition (“full disk” encryption).

    – Patrick

  14. Fez Miester

    well my macbook pro is 2-3 weeks old now.- duel boots, dunno why rEfiend didn’t install over rEifit .. so still rEifit boots but – WALK though the wound fixes Please. ;z) I got 0 zero sound comming out. but looks ~ otherwise (i think) ok otherwise… hah Thanks for posting!! So clear who needs this and who doesn’t from the first paragraph!!

    Fez

  15. Fez Miester

    I wasn’t sure i’d make it. ;z) i’m the guy who knows all the guys who’s friends make robots and do inteligence gov work.. and I just worked with DBM .. and can’t code unless that means understanding what the color of her eye shadow menas about her mood. ; -) j/j but my friends all maner of real coders, (who figured out why my efi installs were not loading properly) or at all past OS x and rEifit… (rEifind.. wouldn’t install over it.. *yeah i know k-/ Now that I am duel booting into my brand new mackbook pro like 2 weeks old… it’s cool but it’s not that I can’t hear anything on it. ~~~ What is the ‘few sound fixes’ you eloud to here??ks, Thanks and I loved how you started out.. because target audence is everything right? ;z)

    Fez

  16. Kimball

    Have you had any luck with hibernate in macos? From other reading it seems that rEFInd breaks it where as rEFIt works fine.

    I’ve not had my mac long enough to tell, but as I plan to use both Macos and Linux it’s quite important that hibernate (safe sleep) works correctly in Macos.

  17. Ben

    Is there any way of minimizing the wake up time after suspend? It takes about 15-20s by default at this moment.

  18. John Post author

    I haven’t looked into that – I rarely use suspend. I did look into the time it takes to boot – apparently the Mac firmware is ‘more thorough’ in its boot checks when it knows it is not running OSX. There’s a tool I found via google to adjust that, but I never used it. Depending on how suspend is working, that may be helpful. It would probably have been a grub/efi related tool.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>