Skip to content

Instantly share code, notes, and snippets.

@rowanphipps
Created August 10, 2017 17:53
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rowanphipps/e4c0e6037b71e9ea96dd8fe403461ee3 to your computer and use it in GitHub Desktop.
Save rowanphipps/e4c0e6037b71e9ea96dd8fe403461ee3 to your computer and use it in GitHub Desktop.
A guide to using rEFInd on macOS

A Guide to Multibooting a Mac

Disclaimer: This has the potential to destroy all the data on your drive. Make sure you have adequate (and verified working) backups before you proceed. You have been warned!

That being said this should leave all of your data untouched.

Background:

I have a mid-2012 15” non-Retina Mac book pro with a 1TB hard drive. I decided that I wanted to make my system faster by replacing the hard drive with an ssd and while I was at it I decided I also wanted to have Windows and Ubuntu partitions. Doing it this way meant that I had no data on the SSD while I experimented with partitions and boot managers although everything I did should be possible on a drive with an existing system.

Goals:

  • Multiple OSs installed with the ability to add more
  • A nice, manageable boot loader
  • Full disk encryption for macOS using filevault

Requirements:

  • A Mac running a recent-ish version of macOS
  • A linux ISO or install disk (Any should work but I picked Ubuntu Desktop)
  • A windows iso or install disk
  • An extra flash drive (may not be needed but can be very useful)
  • A macOS installer for your chosen version of macOS (can be downloaded from the App Store)
  • A second computer (again, may not be needed but also might be essential for troubleshooting)
  • A copy of rEFInd
  • a wired internet connection (in my experience this was necessary in order to get wifi working on Ubuntu but you mileage may vary)

Part 1: Installing rEFInd

These instructions assume an x86_64 architecture, if you for some reason have something different then you will need to pick a different set of files to copy across.

  1. Disable System Integrity Protections: this sounds bad but in order to mess with the EFI boot loader you have to do this.
    1. Boot into recovery mode
    2. Open terminal
    3. Run the command: csrutil disable to disable SIP
  2. Mount the EFI partition.
    mkdir /Volumes/ESP
    mount -t msdos /dev/disk0s1 /Volumes/ESP
  3. Create a directory called REFIND in the EFI volume at /EFI/REFIND
  4. Copy the right files.
    All paths are from the root of the rEFInd directory that you downloaded and all the files go into the directory you just created.
    • refind/drivers_x64/
    • refind/icons/
    • refind/refind_x64.efi
    • refind/tools_x64/
  5. Copy the sample config file to the same place as the other files and rename it to refind.conf
  6. Bless rEFInd. bless --mount /Volumes/ESP --setBoot --file /Volumes/ESP/EFI/REFIND/refind_x64.efi --shortform

Part 2: Partitioning

Note: For reasons best know to itself, Windows refuses to install on a partition numbered higher than 5 (eg. disk0s5). MacOS wil be installed in one of the first partitions since it is already installed and linux doesn’t care where you install it to. Don’t worry about accidentally removing the recovery partition, you can get it back later and removing it my make it easier to get windows to install.

Part 3: Windows

I felt that windows was the most likely to cause problems so I decided to do it first to minimize my losses if it failed and wiped everything.

Boot Camp drivers

In order for windows play nicely with mac hardware you need to install the bootcamp drivers.

  1. Open Boot Camp Assistant and click continue.
  2. On the second page select the option to download the latest Windows support software from apple an follow the instructions. This shouldn't do anything to your hard drive.

Installing Windows

  1. Restart the machine to get to the rEFInd menu
  2. Insert the Windows install media and press escape to make reFind regenerate its list of boot options.
  3. Select the Windows installer.
    There will probably be two options where one of them is labled legacy. I have always avoided the legacy options and had good experiences so I would recommend picking the other option.
  4. Once inside the installer, select advanced/custom install
  5. Select the correct partition and reformat it to ntfs.
    If it then complains about the partition table just restart the machine and it might work the second time. If not then you could try repartitioning the drive again.
  6. Finish the installation then install the bootcamp drivers once windows has booted
  7. Fix rEFInd

Part 4: Linux

The Linux installation process is similar to windows but it doesn't care which partition it is installed into. The exact process will vary between distributions but you will probably want to select the advanced option to make sure it only touches the correct partitions. If there is an option, I would recommend enabling proprietary drivers as this may help make wifi work. After the install is finished you will need to fix rEFInd again.

Part 5: Filevault

Try enabling it normally. (Hey, it might work, who knows!) If it complains about a lack of recovery disk then complete the section on recreating the recovery partition and try again.

Fix rEFInd

Whenever you install a new OS or somtimes when you install updates, one of the operating systems may decide that you EFI boot selection is all broken and that it needs to be fixed. When this happens then when you reboot it will boot straight into that OS and skip rEFInd. Instructions for how to fix this are below and there is a script in the attached file.

  1. Restart and hold down the option key.
    This tells the hardware to skip straight to the mac bootloader, allowing you to bypass your broken EFI settings.
  2. Select your macOS partition to boot from.
  3. Open terminal
  4. Mount the ESP volume:
    mkdir /Volumes/ESP
    mount -t msdos /dev/disk0s1 /Volumes/ESP
  5. Bless the reFind program bless --mount /Volumes/ESP --setBoot --file /Volumes/ESP/EFI/REFIND/refind_x64.efi --shortform

Everything should be fixed now and rEFInd should work as normal

Recreate Recovery Partition

  1. Download the Recovery Partition tool
    This tool is very simple and does exactly what it claims to do. The only downside in my experience is that it gives no indication of progress.
  2. Run it. You may need to provided it with an installer for your current version of macOS.
  3. Check to see if it worked.
    Restart and hold option. If it worked you should see an option to boot into recovery mode.

What Next

If you got this far then you should still have a working macOS install and in addition you should now be using rEFInd and have one or more other operating systems installed. At this point adding, removing, or changing which OSs you have should be fairly simple and rEFInd should automatically detect them. From time to time installing updates will break you rEFInd configuration but when that happens just follow the instuctions to fix it and everything should be ok. Unfortunately System Integrity Protections are still disabled but if they are enabled again they will make it impossible to fix rEFInd and may break things.

References

#!/bin/bash
mkdir /Volumes/ESP
mount -t msdos /dev/disk0s1 /Volumes/ESP
bless --mount /Volumes/ESP --setBoot --file /Volumes/ESP/EFI/REFIND/refind_x64.efi --shortform
@jddcef
Copy link

jddcef commented May 27, 2021

Does this apply to Windows 7 or 8? And not Windows 10 right? Macbook5,1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment