Skip to content

Instantly share code, notes, and snippets.

@michaelsproul
Created February 11, 2017 07:22
Show Gist options
  • Save michaelsproul/a7104601b5089a190ee4f5f2b3934660 to your computer and use it in GitHub Desktop.
Save michaelsproul/a7104601b5089a190ee4f5f2b3934660 to your computer and use it in GitHub Desktop.
Installing rEFInd from macOS Sierra recovery mode

Installing rEFInd from macOS Sierra recovery mode

Today I installed Linux on my Mac, on an external hard-drive. I encountered only one undocumented hitch, which I'm detailing here for my own reference and in case anyone else runs into it.

Basically, the steps I followed were:

  1. Boot Devuan installer from USB
  2. Install Devuan to external disk (I went with the "use the whole disk" option)
  3. Try to boot Devuan by holding Alt key... doesn't work... search a little, work out that I need the rEFInd bootloader
  4. Boot into OS X and try to install rEFInd. No luck, system integrity protection forbids it. Installer suggests booting into recovery mode
  5. Boot into recovery mode by holding Command-R.
  6. Run ./refind-install --usedefault /dev/disk3s1, get something like the following error:
$ ./refind-install --usedefault /dev/disk3s1
mkdir: /tmp/refind_install: device is read-only
...<some other errors from mount and rmdir>...

The Fix

I just had to set InstallDir=/private/var/tmp/refind_install in the MountDefaultTarget function, so it now looks like this:

# Mount the partition the user specified with the --usedefault or --ownhfs option
MountDefaultTarget() {
   InstallDir=/private/var/tmp/refind_install
   mkdir -p "$InstallDir"
   UnmountEsp=1
   if [[ $OSTYPE == darwin* ]] ; then
      if [[ $OwnHfs == '1' ]] ; then
         Temp=`diskutil info "$TargetPart" | grep "Mount Point"`
         InstallDir=`echo $Temp | cut -f 3-30 -d ' '`
         if [[ $InstallDir == '' ]] ; then
            InstallDir=/tmp/refind_install
            mount -t hfs "$TargetPart" "$InstallDir"
         else
            UnmountEsp=0
         fi
      else
         mount -t msdos "$TargetPart" "$InstallDir"
      fi
   elif [[ $OSTYPE == linux* ]] ; then
      mount -t vfat "$TargetPart" "$InstallDir"
   fi
   if [[ $? != 0 ]] ; then
      echo "Couldn't mount $TargetPart ! Aborting!"
      rmdir "$InstallDir"
      exit 1
   fi
} # MountDefaultTarget()

Looks like /private/var/tmp is the writable tempdir in a Sierra recovery boot-up.

Versions/Hardware

  • macOS 10.12.3 (16D32)
  • rEFInd 0.10.4
  • Hardware: Macbook Pro Retina (Early 2015), aka MacBookPro12,1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment