Dual-booting Ubuntu 18.04 with macOS (including full disk encryption)

Introduction

I’ve been running Ubuntu on Macbook Pros for a couple years now, and while the ease of installation, driver support, and general stability has greatly improved in recent years, it can be difficult to find up-to-date guides. I’ve recently set up a mid-2015 macbook pro dual booting macOS with Ubuntu 18.04, so I figured I’d document my steps. First some overall notes and warnings, then simple instructions for a non-encrypted install, followed by slightly longer instructions for an encrypted install.

Notes and Warnings

• I’ve heard that support for the newer touchbar-equipped macbook pros is not great. I have not tried those, but I’ve used a mid-2014, as well as 2 variants of mid-2015 macbook pros long-term, on 14.04, 16.04, and 18.04.
• If you get your disk into any terrible state, macbooks come with pretty great recovery options. Command-R will boot into a recovery partition, and even if that’s lost, Option-R will get you into an internet-recovery mode.
• If you want to remove Ubuntu, and find that grub is still hanging around (or somehow end up with an extraneous grub), run the following from macOS.

mkdir mnt
sudo mount -t msdos /dev/disk0s1 mnt
sudo rm -rf mnt/EFI/ubuntu

• System upgrades of either macOS or ubuntu may cause refind to lose priority and make it more difficult to dual-boot. If that happens, you can run refind-mkdefault, which is available in the mac download as explained below, or from sudo apt install refind. For more information see this handy guide from the refind website.

Create Ubuntu bootable USB

Instructions for macOS, Ubuntu, Windows

Prepare macOS

First thing we’ll need to do is reduce your macOS partition size in order to make some space for Ubuntu. This should be fairly straightforward using macOS’s Disk Utility applicaton.

Next, install rEFInd, which is available here, and run the refind-install binary. Most likely you’ll see an error message about System Integrity Protection being enabled. As the error message suggests, we can either install from the recovery partition, or temporarily disable SIP. To get into recovery mode, hold command + r while booting, and from there a terminal can be accessed via the Utilities menu. You can try running refind-install from recovery mode, but I had no luck with that, and just got the same error. So instead, I ran csrutil disable to disable SIP. After a reboot (back to non-recovery mode, because it’s faster), refind-install should work. You can then re-enter recovery mode to run csrutil enable. After this process, you should now see the refind menu whenever you boot. You’ll be able to choose between macOS and any other operating systems you load, as well boot from external drives.

Install Ubuntu 18.04 (no encryption)

After booting from the Ubuntu bootable USB, you can either install straightaway, or do it from within the “try ubuntu” environment. Either way, the only important step is to select “Something else” on the menu that asks how/where to install Ubuntu. You should see the empty space on your disk that you freed up from macOS, and be able to add partitions. This is my configuration:

• Boot partition, 500 MB, ext4, mounted at /boot (sda4 for me)
• Root partition, remaining space, ext4, mounted at / (sda5 for me)
• Bootloader installed to boot partition (sda4 for me)

You could optionally add a swap partition, but Ubuntu 18.04 now supports swap files

Everything should be good to go from here. As a side-note the installer crashed for me apparently because I had another copy of grub hanging out on my /sda from some earlier tests. Deleting it per the notes above, and then retrying worked for me.

Install Ubuntu 18.04 with full disk encryption

After going through the above process, I discovered that Ubuntu 18.04 no longer supports homedir encryption. Furthermore, while full disk encryption is an option in the installer, it requires wiping the entire physical disk. So that’s not great either. Fortunately, I came across this well-written blog post that provides all the details to manually encrypt the Ubuntu partition before installing. As above, I chose to skip the swap partition steps, and otherwise followed it with only one issue.

Strangely, I again had the installer repeatedly crash on me while “copying files”. This time it was not due to any grub conflicts that I could find. As an unsatisfying workaround, I realized that it would only crash after I entered my account/login details. So I simply stayed on that screen until the activity led on my usb drive stopped flashing. I then continued forward, allowed it to crash, and then moved on with the post-installation instructions, and so far things are working.