Install Refind Mac

I recently decided to run Kali Linux on my MacBook. I originally thought I'd just build it into a Virtual Machine (using Parallels), but was concerned that I might not have the control over the hardware that I'd need in order to make Kali effective as a learning environment. So, I set about working on a dual-boot scenario. Needless to say, I failed miserably when I opted to have Kali install Grub and it overwrote my primary Boot Manager on the Mac and rendered the system unbootable (and eventually unrecoverable). Thank goodness for good backups...

WARNING: Do not proceed with any of these steps unless you have the ability to restore a bare-metal backup. Everything I'm doing has the potential to trash all of the data on your computer, requiring a clean installation of macOS and subsequent data recovery from backups. I use a combination of Time Machine, CrashPlan, and Arq to back up my system, you should too.

If you lower the security, then you can install and boot with or without using rEFInd. Installing Ubuntu to the internal drive of the newest Macs may not yet be possible. With rEFInd, the following happens: The firmware boots rEFInd. The user chooses Ubuntu from the rEFInd menu. REFInd instructs the firmware to boot Grub. Note that the refind-install isn't supported due to well not running a real Mac. It's super simple on Linux, but make sure you're booted through the BIOS and not OpenCore to avoid any issues. Run refind-install and go through the setup; If you have issues with installation, see Installing rEFInd Manually Using Linux. 前書き 知り合いにmacでデュアルブートする方法を教えてくれと言われて書いたものです。せっかくなので記事にしました。 手順1:rEFInd のダウンロード rEFInd をダウンロードし、任意のディレクトリに配置します。. I tried to install rEFInd boot manager and screwed up my Bootcamp so windows 8 will not boot. It does show up on boot holding the option key, but it does nothing but a black screen when selected. Same when selecting to boot from CD/DVD, black screen. I've read a few posts similar to this but he suggestions from 'LonerT' did not fix my issue. REFInd is a fork of the rEFIt boot manager. Like rEFIt, rEFInd can auto-detect your installed EFI boot loaders, and it presents a pretty GUI menu of boot options. REFInd goes beyond rEFIt in that rEFInd better handles systems with many boot loaders, gives better control over the boot loader search process, and allows users to define their own boot loader entries.

Triple Boot the Right Way

If you're interested in triple booting your MacBook Pro, and Windows is going to be one of the Operating Systems you're going to boot, then take my word for it, this is the only way you want to accomplish this feat.

At a high level, the process goes like this:

  1. Install Apple's Bootcamp and use it to install Windows 10
  2. Use Windows 10 to shrink the Bootcamp partition, freeing up space to install Linux
  3. Install Linux (I used Kali) into the newly freed space
  4. Install rEFInd as a Boot Manager for all 3 OSes

To be fair, a lot of my instructions and the guide I initially followed, can be found here. However, several of the steps in that guide I didn't have to use at all, so I'm documenting my process here.

Install Apple's Boot Camp

Apple provides a supported method of installing Windows as a dual-boot option for Macintosh owners. There are several advantages to using Apple's process:

  1. Apple supports this as a way to boot Windows
  2. Apple provides native drivers for the hardware under Windows
  3. You will have supported ways to control the Windows and macOS boot process on your MacBook from within Windows (via the Boot Camp Control Panel)

Apple's official documentation for Boot Camp is found here.

Install Refind Mac

Follow Apple's instructions for installing Windows, but make sure you create the Windows partition approximately 64GB larger than what you want to end up with for Windows, that space will end up being given to Linux. Adjust if you wish, I used a 196GB partition for Windows 10, then split it into 128GB for Windows and 64GB for Linux (FYI, a Windows 10 installation with Office 365 installed takes up 68GB, so give yourself enough room under Windows).

Install refind mac

Note: Apple only supports Windows 8.1, or newer, for hardware released after 2014. There is no way to install an earlier version of Windows using Boot Camp on newer hardware. See this table to check your hardware and what versions of Windows are supported on it.

Now that you have an Apple-supported dual-boot system running macOS and Windows 10 (presumably), it's time to perform the Linux installation.

Create Partition for Linux

For the purposes of this article, I'm going to install Kali Linux, that's what I used, but installation with ANY version of Linux should work the same way.

The first step is to shrink the Windows partition to make some space for Linux:

  1. Boot into Windows 10
  2. Right-click on the Start Menu and select Disk Management
  3. Select the BOOTCAMP partition, right-click and select Shrink Volume
  4. Enter the size, in megabytes, by which to shrink the volume. I shrunk mine by 64GB, so I entered 65,536

This image is AFTER I did my initial shrink and subsequent installation of Kali linux, you'll have fewer partitions when you do this. I also have an SD card mounted.

The shrinking process took a LONG time (~30 minutes), don't worry about it, let it run to completion and do not interrupt.

After the Volume shrinking process is completed, it's time to download some files to perform the installation; however, you probably want to do this under macOS, so first boot back to your macOS volume and the download them both:

  1. Kali Linux, 64-bit, can be downloaded here
  2. rEFInd, can be downloaded here

Install Refind Macbook Air

Place all of the rEFInd files (after unzipping) on a removable volume (SD Card, USB drive, or even a secondary HFS+ volume) so you can use it in the next step.

Install rEFInd

For all macOS versions starting with El Capitan (10.11) Apple has enabled System Integrity Protection (SIP). This security feature of macOS prevents changes to various areas of the Operating System including System-owned files. That means that you cannot install rEFInd directly on drives where SIP is enabled. In order to install rEFInd you will have to boot into Recovery. Make sure the rEFInd files are available on a drive that macOS can see and use, then follow these instructions:

  1. Reboot the computer and hold down Command-R
  2. Once in Recovery mode select Terminal from the Utilities menu
  3. Find the volume where you have rEFInd stored (start with ls /Volumes)
  4. Change into the rEFInd directory and run ./refind-install
  5. You will still get a warning that SIP is enabled, but you can ignore it (SIP is enabled on the boot volume, but you're not installing it there

Full installation instructions can be found on the rEFInd site.

You may also want to theme rEFInd to look more 'mac-like'. I used the OSX Standard Theme 1.0 found here. Upate 20200906: This theme's installation instructions ask you to 'replace the EFI folder' in the rEFInd install you just did, it ALSO replaces the more curent version of rEFInd and the cryptographic keys that were provided. You probably shouldn't do that, though your milage may vary on getting this to work. At the time of this article's original publication, they were both the same version, but now, 3 years later, the theme's version of rEFInd is woefully outdated. Use with caution or update the components in the theme with the newer versions. (thank you Phillip!)

Test that rEFInd is installed and operational. Just reboot and you should be taken to the rEFInd boot menu, from there you should be able to boot into either macOS or Windows 10.

Note: rEFInd will automatically find what it believes to be bootable volumes. They probably all won't be bootable, through trial-and-error you should be able to find the correct macOS and Windows 10 volumes. You can then configure rEFInd to ignore some volumes, but save that for after you have everything working properly.

Install Linux##

Boot into macOS and have a USB key available to be reformatted, it can be pretty small (small works better), an 8GB drive is perfect.

In order to create a bootable USB drive, you can use the Terminal:

  1. Run the Terminal from the Utilities folder under Applications
  2. Change the directory to where you downloaded the ISO for your Linux installation, e.g. kali-linux-2016.1-amd64.iso
  3. Find your USB key by running: diskutil list, note the drive name, e.g. disk2
  4. Run the command: dd -if=kali-linux-2016.1-amd64.iso -of=/dev/disk2 bs=1m
  5. The above command will take a long time to run, as it is imaging the ISO onto the USB drive. Once it finishes you should have a bootable USB key for Kali Linux (or whatever)

Alternatively, if you want a graphical imaging process, you can use UNetbootin as documented here for Ubuntu (just use Kali or whatever image you want).

You're now ready to install Linux. The reason you had to install rEFInd before installing Linux was that, in my experience, I could not get the standard macOS boot manager to recognize the USB drive I had prepared with Kali Linux. However, if you reboot now, you'll see the rEFInd boot menu. You can then insert your USB drive, then hit ESC to refresh the volumes and you should see the Linux installation drive appear. Select it for booting.

Follow the instructions for installing Linux, making sure to select the correct partition that you created while you were under Windows 10 earlier.

Completed

You should now have a triple-booting MacBook Pro. Using rEFInd you can select the appropriate OS and it should boot cleanly on your hardware.

In the event that rEFInd gets clobbered (you'll know, because a power-cycle takes you to the built-in macOS boot manager) you should still be able to boot into Windows, but you'll probably lose the ability to boot into Linux. Just follow the instructions and re-install rEFInd again and it should come back and allow you to boot again.

In this blog post I’ll be covering the process of installing and troubleshooting refind bootloader from a machine running Windows 10 1903 (although I hope this will survive any updates from Microsoft).

At first, I tried following the official documentation and replacing the {bootmgr}’s path with refind’s, but it didn’t work. Then, I used BCDEDIT.exe to modify every single path to bootmgfw.efi I cound find but to no effect. After every reboot, Windows kept showing up no matter what.

So, I’ll be describing here the steps I had to take in order to make everything work as expected, and some guide to troubleshoot any error that you stumble on. Here’s a screenshot of the final result:

What our goals are

  • Install and theme refind from a Windows 10 machine
  • Make refind the default bootloader
  • Prevent Windows from setting itself as the bootloader after every boot

What our goals aren’t

  • Cover the details of installing refind from any other Operating System (if you’re not on Windows 10 and wants to install refind, take a look here)
  • Make Secure Boot happy (I may or may not make a blog post about this in the future. If you want to use Secure Boot - which I recommend -, you can start by taking a look at the official documentation on this topic)

What you’ll need

  • refind (duh)
  • Explorer++ or some other file explorer that can be launched as Administrator (I’ll assume that you have one, but it is not required at all. If you feel confortable, you can do all the file moving/editing from your command prompt)
  • A Windows 10 bootable USB stick (or DVD if you live in a cave)¹

¹NOTE: The Windows 10 bootable is not required, but is recommended in case you mess things up.

Before we get started

⚠️ UPDATE: Before you proceed, I recommend trying the steps on the official documentation and using this only as last resort. If you do have to follow this path, I recommend you backup your refind installation folder after the installation is complete. When you are installing some OSes (e.g. Linux), they will overwrite refind’s files and prevent you from booting into refind (but booting into the fresh installed OS will work). If this happens, all you have to do is login into the OS you just installed and restore your refind backup.

Install Refind Mac

First of all, go ahead and disable UEFI’s Secure Boot. I won’t go into details on how to do it, since it changes from system to system. If you don’t know how to do it just search around. Pay attention not to disable UEFI, just Secure Boot.

Getting started

In ordet to get started, we’ll need access to the Windows’ FAT32 EFI partition. To do that, we’ll have to mount it. From an elevated command prompt, issue the following command (where B: is the letter you want to assign to the partition):

After this, you should have your partition mounted at B: (or whatever letter you specified). In order to access it, you’ll have to launch Explorer++ as Administrator (see the note below). If you open it up you should see the following structure:

NOTE: The old trick of killing explorer.exe and launching it from an elevated command prompt doesn’t seem to be working anymore. The B: drive shows up but is not accessible. I prefer not to mess around with this drive’s permissions, so I’m using this alternative method.

Microsoft Windows’ Boot Environment

Microsoft’s folder intuitively contains files used to boot Windows. I’ll summarize what I think is important about the boot process, but if you want to know more, I suggest you start here (this link is where I’m getting all the info below).

NOTE: I’m not an expert, so I may say something that is not 100% accurate. If you find something that you think is incorrect, please drop me a line.

With just Windows installed, this is what the boot flow looks like:

  • UEFI Firmware: Performs CPU and Chipset initialization, load drivers, etc.

  • UEFI Boot Manager: Loads UEFI device drivers and loads boot application

  • Windows Boot Manager (EFIMicrosoftBootbootmgfw.efi): Is responsible for loading the Windows Loader (C:WindowsSystem32winload.efi) chosen by the user (in case there’s more than one Windows installed).

Replacing Windows Boot Manager

Our goal here is to replace Windows Boot Manager with refind (but, of course, allowing refind to call the Windows Boot Manager later if that’s what the user wants).

In order to do that, we’ll use the EFI fallback file. Here’s a quick definition, but if you want to know more, take a look here and here.

The firmware will look through each EFI system partition on the disk in the order they exist on the disk. Within the ESP, it will look for a file with a specific name and location. On an x86-64 PC, it will look for the file EFIBOOTBOOTx64.EFI.

So… let’s recap: we know that the firmware looks for Windows Boot Manager on EFIMicrosoftBootbootmgfw.efi and we know that, if it doesn’t find it, it’ll look for whatever file is at EFIBootbootx64.efi. Hmm…

You probably realized where we are going here, but in case you dind’t: our plan is to set refind as the EFI fallback file and move Windows Boot Loader to some place where the firmware can’t find it. Then, we can create an entry in refind pointing to the place where we moved Windows’ files.

This is actually quite simple, but will require a few hacks. Lets begin.

Installing refind

First of all, rename the existing EFIBoot folder to something like EFIBoot.old, so that you have a backup in case you need it. With this out of the way, create a new EFIBoot folder and copy refind’s files there. Rename refind_x64.efi to bootx64.efi.

One more thing, add the following entry to your refind.conf file (this is important, trust me), replacing {folder} to anything BUTMicrosoft (I’ll use _Microsoft) and {pathtoyouricon.png} with the actual path of your icon:

After this step, refind is properly set up as the EFI fallback. All we have to do now is make Windows Boot Loader unfindable by the UEFI firmware.

Renaming the Microsoft folder

This should’n need a dedicated section, but is not as straightforward as it seems. The EFIWindows folder cannot be renamed from Windows (since it is kept in use).

So, you’ll need to get a command prompt at boot. In order to do that I usually use the Windows bootable (just press Shift + F10 on menu), but there are other ways to do it in case you didn’t set up your bootable media.

At the boot command prompt, mount the EFI partition and navigate to the EFI folder:

At this point, if you explore this folder, you should have your Boot folder with refind’s files and Microsoft folder with Windows’ ones. All you have to do is rename the Microsoft folder to the same name you used on your refind’s menuentry.

⚠️Remember to replace {folder} by the exact same thing you used in your refind.conf file.

And that’s it. Close the command prompt and restart your computer. Next time you boot your firmware should not find Windows Boot Manager and fallback to refind. Since we manually added the Windows entry to refind, you should be able to boot into Windows from there.


Troubleshooting

I messed things up and now I can’t boot my computer

Keep calm. This probably happened to me a few dozen times in the process of trying to install refind.

All you have to do is fix your EFI partition. I usually just format the partition and ask Windows to rebuild it, this way you should have a fresh start. Note that this will only work if Windows is the only operating system installed in this partition.

To format and rebuild the partition, boot into your Windows 10 media (I hope you have one), launch a command prompt and execute the following:

This should rebuild your EFI partition and you should be able to boot into Windows now.

Refind shows up without any option (hangs)

This happened to me. In my case it was an issue with the NTFS driver, so all I had to do was remove the ntfs_x64.efi file from the EFIBootdrivers_x64 folder.

NOTE: You don’t need the NTFS driver to boot into Windows, since the EFI partition is using FAT. For more info, take a look here

If it isn’t a drive issue for you, see if any of the below helps. This is a quote from refind’s author Roderick W. Smith:

Install Refind Mac Pro

This sort of problem normally indicates a filesystem issue – rEFInd is getting stuck in an infinite loop attempting to read one of the filesystems on the disk. I recommend you try the following:
1. If you have any external disks attached to the computer, try unplugging them. Such disks sometimes cause problems. If this fixes the problem but you need to use the external disk on a regular basis, you may need to further debug the problem as below; but if it’s just a USB flash drive that you don’t need to leave permanently attached, then this should be the end of it.
2. Remove (or move) all the EFI filesystem drivers from the “drivers”, “drivers_x64”, and “drivers_ia32” subdirectories of the rEFInd installation directory. (Normally there’ll be only one drivers subdirectory; just remove all those driver files.) Reboot. 3. If rEFInd hangs even with no EFI filesystem drivers installed, then the problem is likely with the ESP or some other FAT filesystem. You can try doing a filesystem check on such partition(s) with dosfsck in Linux, CHKDSK in Windows, or similar utilities. In an extreme case, you could try backing up the ESP (and/or other FAT partitions), creating a fresh filesystem, and restoring the data.
4. If rEFInd comes up and shows a menu after removing the filesystem drivers, even if the menu options are incomplete, then this is good; it indicates that there’s a problem with one of the filesystems or their drivers. You can then begin restoring the driver(s) that you need. Normally this will be just one, for whatever filesystem holds your Linux kernels. (You do NOT need the NTFS driver to boot Windows.)
5. If rEFInd works at this point, then you’re done – the problem was in some superfluous driver(s) that you weren’t using. 6. If rEFInd hangs, then you can try booting in some other way and using a filesystem check utility like fsck on the filesystem(s) that can be read with the driver(s) you restored. With any luck this will fix the problem.
7. If the problem persists at this point, you have a number of options:
a) Remove the offending filesystem driver, install GRUB, and use it to boot the Linux kernel. GRUB uses a different filesystem driver and so may not be affected.
b) If you don’t already use one, create a small (~1GiB) partition to use as /boot, using a different filesystem than your main Linux partition. You can then install the EFI driver for the /boot partition, copy the contents of /boot to it, and adjust /etc/fstab to mount this partition at /boot. The ext4fs, Btrfs, and ReiserFS EFI drivers are the fastest ones.
c) Do as in option b, but use FAT, which requires no special driver. This works better with some distributions than others, though. Debian-based distributions often use symbolic links, which aren’t supported on FAT, in /boot, for instance. Some Arch Linux users like to use FAT on /boot (or mount the ESP at /boot), by contrast.
d) Completely wipe and re-install the offending partition(s). It’s possible that the EFI driver is flaking out because of leftover data that wasn’t completely erased when you created the partition. If you opt to do this, I recommend completely zeroing the partition (with “dd if=/dev/zero of=/dev/{wherever}” or something similar) before restoring it.
e) Try a different EFI filesystem driver. The efifs project (http://efi.akeo.ie/) offers a large number of EFI filesystem drivers, and its variant of the rEFInd driver might work better on your system.
There may be some other options and potential causes I’m forgetting.