Sunday, December 16, 2012

Ubuntu 13.04 Daily Build Macbook Pro Retina documentation and install guide

      Over the past few days I have embarked on a journey:  to install and run Linux on a Retina Macbook Pro. (15-inch 2.3 GHz base model)  The main issues were the kernel not supporting it and the lack of internet connections that work immediately without extra hardware. (As well as the lack of solid instruction, which is why I created this guide.)

      Other places I have seen this topic discussed have been focused on current releases, which is understandable.  However, looking at these changes for Ubuntu 13.04, one of which states that it will be compatible with this computer, I decided to try the daily build.

      The daily build of Ubuntu 13.04 has kernel support for this computer.  This first post will describe the current state of Ubuntu 13.04 and the various steps I used to get Ubuntu working.

When partitioning, it is better to let Linux do the partitioning of free space in the installer rather than creating an msdos partition in Mac OS X.  This prevents the creation of a hybrid MBR and creates a protective MBR which has a standard.

 Installing to an external drive--Important Note

Your disk's partition table needs to be GUID/GPT  (GPT and GUID are the same thing).  External drives can be checked in disk utility under partitions.  Underneath the picture of the partitioning scheme, there is a button named options.  Click it, and you should be able to see what the partition table format is.  If it is GPT, you can proceed.  if it is not, the EFI bootloader will not work.

To make the drive GPT, it will need to be reformatted, erasing all the data on the disk, so don't convert unless you have somewhere to put those files.

Before you begin:

Create enough free space (unformatted) for Ubuntu to fit.

Grab a 1GB or larger flash drive and a DVD-R, or a 4GB or larger flash drive.

Recommended:  an ethernet adapter that works with the retina mac

Now for the actual guide.  Hopefully it is easy enough that people who are newer to linux can follow it.

1:  Install rEFInd

       The should be run in a Mac OS X partition with the --drivers option and I (personally) installed it to the Mac partition rather than the EFI (ESP according to the rEFInd guide).  For more information, the creator of rEFInd has this information organized already:

so unzip the files, run the

If you want to have Linux on an external hard drive, or want to dual-boot, you may run either option:

      ./ --alldrivers

but if you want only Linux on your internal hard drive, you must run this:

       ./ --esp --alldrivers

Test if rEFInd works.  It may take two reboots for it to load.

2:  Install Linux


The iso image for the daily build can be grabbed here:

(grab the amd64 mac iso)

Insert an ethernet or wifi adapter if you have one.  If you have a thunderbolt ethernet adapter, you will need to plug it in before booting Ubuntu.

If not, you will need this .deb file and this driver package later:

Save them to the flash drive. 

Make the LiveCD

Reboot into the Ubuntu LiveCD through the rEFInd menu

Select try ubuntu.

Get the ethernet settings set up

run the installer with

      ubiquity -b

This will prevent it from installing grub.  Since we will be booting from the kernel itself, grub is not necessary for this install.

Go through the normal installation process

Select "continue to try ubuntu": there are a couple more steps to make this visible to the mac's EFI.

3:Configure rEFInd

Mount your /boot (if you made one) to your install's /boot or your hard drive's EFI (if you didn't) to your install's /boot/efi directory (make one if it isn't there.)

Create the path /boot/efi/EFI/ubuntu/

Then run:

     sudo cp /boot/vmlinuz<version> /boot/efi/EFI/ubuntu/vmlinuz<version>

     sudo cp /boot/initrd<version> /boot/efi/EFI/ubuntu/initrd<version>

As an example, my current vmlinuz and initrd reads vmlinuz-3.8.0-0-generic and initrd-3.8.0-0-generic. 

      Find your UUID with either "sudo blkid /dev/sdXY" (the one you want to know) or with  "ls -l /dev/disks/by-uuid/"  and finding the /dev/sdXY that you need

UUID is a long string of numbers and letters.

My options inside refind_linux.conf look like this:

"Boot using standard options" "root=UUID=<Your root partition's UUID> ro   quiet splash $vt_handoff"
"Boot using minimal options"  "root=UUID=<Your root partition's UUID> ro"
"Boot to shell"                           "root=UUID=<Your root partition's UUID> ro text"
"Boot using recovery options" "root=UUID=<Your root partition's UUID> ro recovery nomodeset"

This uses the kernel (which should be above 3.7 if you are following this guide) as the bootloader, with no requirements for grub.  (Grub can be safely ignored, as with this setup the mac cannot see grub as a boot option)

If you upgrade your kernel, you will need to also copy it inside the ubuntu folder like before.

4:Final Adjustments

At this point, reboot into your newly-working Ubuntu install.

(There should be an Ubuntu logo on the rEFInd boot selection screen)

Reconfigure wired internet if required.

Wireless Drivers

If you have Ethernet working

Download the drivers from here: 

open with the archive manager and extract wl_apsta.o to your home folder.

     sudo apt-get install b43-fwcutter

then run

     sudo b43-fwcutter -w /lib/firmware/`uname -r` ~/wl_apsta.o

     sudo modprobe b43

Wireless networking should be working.  If it isn't, reboot.

Without Ethernet

Mount your flash drive and move the files to your home folder.

Open the driver package with the archive manager and extract wl_apsta.o to your home folder.

       sudo dpkg -i b43-fwcutter.deb

       sudo b43-fwcutter -w /lib/firmware/`uname -r` ~/wl_apsta.o

      sudo modprobe b43

Wireless networking should be working.  If it isn't, reboot.

 Nvidia graphics

Nvidia drivers work from the standard repository (run

           sudo apt-get update; sudo apt-get install nvidia-current

in the terminal), but the setting must be configured by the Nvidia x Server settings program to display properly.

Reboot after install.  I saw 3 mirrored 800x600 screens stacked on top of each other, with garbage to the right.

Open the x server settings. 

Selection:  change to  X screen 0

click advanced

click X server Display Configuration

click the first button after "metamode" and select nvidia auto-select

hit apply.  if the screen goes back to looking like a 2880x1800 screen, reopen x server settings if it closed, check the configuration to make sure it's the same, and click "save to X configuration file"  This will keep this setting throughout reboots.

*For changing the resolution, after the NVIDIA graphics is set up correctly, my second post has a scrip that you can use.*

Changing the desktop environment:

This should work.  If you speakers stop working after installing it, run

sudo apt-get remove --purge alsa-base
sudo apt-get remove --purge pulseaudio
sudo apt-get install alsa-base
sudo apt-get install pulseaudio
sudo alsa force-reload

The current status below is in a shorthand, descriptive format.

Retina Macbook Pro Ubuntu 13.04 daily-build, installed on eternal hard drive.

Desktop Environment:  Cinnamon
Steam for Linux working properly
EFI boot working
Nvidia Graphics working (yes, at the same time as EFI booting)
full screen resolution  2880x1800

Current Status:

      Kernel of LiveCD and installed OS does not require any extra configuration from the default. Thunderbolt and USB to ethernet adapters work, but only when plugged in from boot.

      b43 wireless drivers work after install with sudo modprobe b43 with a reboot, using the standard b43-fwcutter with the open-source broadcom driver 5.100.138. No network drops seen so far.

      The booting is handled by rEFInd using the kernel as an EFI stub inside the external drive's ESP (labelled EFI) in the GUID as described by the creator of rEFInd.

       Installing cinnamon desktop destroyed detection of sound card, though it can be fixed by reinstalling alsa-core and pulseaudio and running sudo alsa force-reload

      At this point, everything that I have tested works. The system usually reports a couple crashes early on after login which don't affect the stability. One freeze has been seen while changing the auto-hide option in the cinnamon settings, but  later attempts to recreate failed, so no confirmed bugs.

      The trackpad is sensitive to the lightest tap, so a USB mouse in recommended, though I had heard of someone editing the trackpad config... which if I get around to it I will include in another post. The keyboard works normally, AFAIK.

      With the latest updates and the proper libraries, steam and TF2 work, although TF2's frame-rate is choppy and resolution cannot be changed in TF2 in fullscreen mode. Unknown whether this is an issue with hardware or optimization by Valve being incomplete or something else entirely.

Enjoy having linux on that 2880x1800 screen!