Sunday, 19 January 2014

Installing Ubuntu on a Retina Macbook Pro - the easy way

Update: If you have Mac OS X 10.10 (Yosemite) installed, then the rEFInd installation needs to be handled differently. Please check the rEFInd website for more details.

In my previous installation guide, I outlined the first way that I found of installing Ubuntu on a Retina Macbook Pro. One of the challenges of the installation was that the boot manager, rEFInd, needed the Linux kernel to be copied from the Linux partition to the Mac OS X partition. This then becomes a painful process that needs to be repeated every time there is a kernel update on Ubuntu. Fortunately, there is a better way! Thanks to a comment on the rEFInd website, I found out that file system drivers can be installed that allow rEFInd to read the Linux partition.

This post outlines the full installation instructions, but if you already followed the previous guide, you can update the rEFInd installation and configuration file. I've included some instructions on that in the post.

1. Partition the Hard Drive

This step is nice and easy on the Mac. Just launch Disk Utility, click on the laptop's hard drive and click on the Partition tab. From there the Mac OS X partition can be resized. Disk Utility allows you to create a new partition with the extra space, but I just left it as Free Space, so that it would be created by the Ubuntu installer.

2. Create the Ubuntu USB Installer

The latest stable release of Ubuntu is available at - you'll need the 64-bit Mac (AMD64) desktop image.

Instructions for creating a bootable USB stick are provided, you'll just need to remember to use the latest ISO that was downloaded above. Note: unlike some disk image files, Mac OS X cannot mount the disk image, but it will boot fine from it.

3. Install an EFI Boot Manager: rEFInd

Previously, I've used Refit as a boot manager and boot loader for Ubuntu on a Mac, but that doesn't seem to be maintained any more. So, for the Retina Macbook Pro I've switched to rEFInd, which is just a Boot Manager. We'll then be loading Ubuntu using EFI instead of Grub, which means we can leave the old world of BIOS behind. See the rEFInd website for more information about boot managers and loaders, EFI and Grub.

Download the binary rEFInd zip file from and unzip it by double-clicking the file in the Mac OS X Finder. You'll want to check out the rEFInd installation instructions, but I chose the simplest option of installing rEFInd in the Mac OS X partition. There are other possibilities, but this seemed the easiest for me to manage - especially if something went wrong.

The installation needs to be done in the Terminal, by running the script:
 cd ~/Downloads/refind-bin-0.7.7  
 ./ --alldrivers

The '--alldrivers' option installs the file system drivers for rEFInd, which allows the boot manager to be able to access the Ubuntu kernel files on the Linux file system. If you are upgrading from a previous installation of rEFInd, it will keep your existing rEFInd config file and copy the latest version with a different name.

The script will prompt for your password so it can run with administrator privileges using sudo. Once the script has run, rEFInd is installed and you can see the configuration files at /EFI/refind.

You'll need to reboot a couple of times before you can see the rEFInd menu appearing. We'll need to configure rEFInd later.

4. Installing Ubuntu

Connect your bootable USB drive into the Macbook Pro and reboot - you should see the USB stick as an option in the rEFInd boot menu, so boot from that. In the Ubuntu installer, select the Try Ubuntu option and it will take you to the Ubuntu desktop at a resolution of 2880x1800 - you may need a magnifying glass handy to read the text. That said, it does look beautiful!

By default, Ubuntu has 'touch to click' enabled for the trackpad by default, which I found difficult work with. So the first thing I did was to turn that off in the Mouse and Trackpad area of System Settings. Next, it's worth changing the screen resolution to something more usable - I selected 1680x1050 (16:10). After that, if you are using WiFi, then you'll need to connect to the network.

4.1 Install Ubuntu

You're now ready to install Ubuntu. We want to do this without installing the Grub boot-loader, which would put us back into the old-world BIOS mode. To install without Grub, run the following in a terminal:
 ubiquity -b  
This will launch the installer and you can follow the instructions to install Ubuntu on the free space that we created earlier, alongside Mac OS X.

Once you are done, you can reboot into Mac OS X. You'll notice that the Ubuntu partition is not showing up in rEFInd as yet - that's what we need to fix next.

5. Configure rEFInd

We need to configure rEFInd so that it sees that Ubuntu partition and has all the correct details so it can boot from it. The rEFInd configuration is in /EFI, which will need root access to be able to update the details. I found that TextWrangler is a great option for editing config file as it allows you to authenticate to update the files. Make sure that you download TextWrangler from the Barebones site as the version in the Apple App Store does not have this facility.

5.1 Configuration File Changes

It's worth checking the rEFInd site for more details about the configuration file changes, as there are a lot more options than I will cover. The main configuration file is /EFI/refind/refind.conf. If you've upgraded from a previous version of rEFInd, you may want to use the sample config file instead of the current version that you are using. We need to configure rEFInd so that it scans the hard disk for other boot options. The following file shows only the lines that I've changed from the default config file:

# Enable the scan for file system drivers
scan_driver_dirs EFI/tools/drivers,drivers

# Choose which drives to scan. This will only scan the internal hard drive.
scanfor internal

# Load the Linux file system driver
fs0: load ext4_x64.efi
fs0: map -r

These configuration file changes ensure that the Linux file system driver is loaded (ext4_x64.efi) and that the internal hard disk is scanned for bootable partitions. If there is more than one kernel found on the Linux file system, rEFInd will display all the available kernels.

That's it. If you want to make the boot screen a it prettier, you can copy a PNG or BMP image file to /EFI and add an extra line to the configuration file:
banner /EFI/MilkyWay.png 

6. Reboot Into Ubuntu

Once you reboot you should see the Ubuntu icon in the rEFInd boot menu, and it should start up. When  it does, you'll see Ubuntu in its 2880x1800 pixel glory. I've increased the default text size in Ubuntu and the browsers to roughly 1.5 times the normal size, and that has made a great work machine.