Add a macOS recovery partition without reinstalling macOS #

If you search the web for how to restore a missing recovery partition, chances are you'll come across advice like:
"Generally the best and simplest method is to reinstall OS X entirely. This is a neat way of triggering for a second time the process whereby the recovery partition is created. It's quite a drastic and time-consuming approach, however."
-- How to create a Mac recovery partition in OS X El Capitan and Yosemite
and:
"The only way to solve this problem is to download the latest installer from App Store and re-install OS X"
-- How to re-create a missing recovery partition in OS X Yosemite (updated to OS X El Capitan)

However, thanks to davidjb's recovery.sh (detailed in his blog post Creating a macOS Recovery Partition without reinstalling OSX or re-running your installer), it is possible to add a recovery partition without reinstalling macOS.

Boot the Mac from an external drive or into Target Disk Mode*, then run:

TARGET="/Volumes/Macintosh HD"                                # Specify where to configure Recovery partition
MACOS_INSTALLER="/Applications/Install macOS Sierra.app"      # Path to your macOS installer

# Remaining paths ahead are dependent on OS version
# This *should* support 10.9 and above but is only tested on 10.12

curl http://support.apple.com/downloads/DL1464/en_US/RecoveryHDUpdate.dmg -L -o ~/Downloads/RecoveryHDUpdate.dmg

hdiutil mount -nobrowse ~/Downloads/RecoveryHDUpdate.dmg

pkgutil --expand /Volumes/Mac\ OS\ X\ Lion\ Recovery\ HD\ Update/RecoveryHDUpdate.pkg /tmp/recoveryupdate

hdiutil mount -nobrowse "$MACOS_INSTALLER/Contents/SharedSupport/InstallESD.dmg"

/tmp/recoveryupdate/RecoveryHDUpdate.pkg/Scripts/Tools/dmtest ensureRecoveryPartition "$TARGET" "/Volumes/OS X Install ESD/BaseSystem.dmg" 0 0 "/Volumes/OS X Install ESD/BaseSystem.chunklist"

hdiutil eject "/Volumes/Mac OS X Lion Recovery HD Update"

hdiutil eject "/Volumes/OS X Install ESD"

Notes:

/mac | Feb 14, 2018


Subscribe or visit the archives.