Recreate HD Recovery Partition
A number of scenarios can cause the Mac to "lose" it's recovery partition. Like manual partitioning to install other OSes, partition cloning among others. However, the recovery partition (Recovery HD) is required for a number of tasks. For instance, to disable SIP (System Protection Integrity) in El Capitan and newer OSes, or to recovery from serious partition errors you need this partition.
This is an ADVANCED tutorial, and should NOT be used by beginners! Read the tutorial in full BEFORE you start!
It contains the tool that will be used to create the partition.
Install OS X El Capitan.appor
Install OS X Yosemite.appor other installation app. (download from AppStore). Use the same version of the install app your system is currently using!
This contains the image (content) of the partition to be created. (Lion or newer)
We will be using the sudo command.
If your user does not have a password, you will have to create one before you start.
Backup of all HDD data (all partitions)
We done this procedure many times and never had a single problem. But we understand the risks. I've added this as a requirement so you understand the stakes: all your data might be wiped if something goes wrong, the whole disk! Better safe than sorry. Backup!
First things first. Before we start we need to see how the hard drive is partitioned. Chances are that you already know how the disk is partitioned.
Open Terminal.app (located in /Applications/Utilities) and type:
The first column (#) indicates the partition number, the second column (TYPE) is the type of the file system, the third column (NAME) is the volume name, the fourth column (SIZE) is the size of the partition, and finally the fifth column (IDENTIFIER) is the node identifier of the partition. In this particular disc the first partition is an EFI partition type FAT16 and with name EFI that is hidden and is necessary for the EFI operation. It's very likely that you already have that, if you don't, don't worry about it.
The second is a
Apple_HFS partition type with name
El Capitan. Right after the OS X partition we should have a hidden partition called
Recovery HD, but because all partitions on this disk were manually created this partition does not exist.
The solution to recreate the Recovery HD partition is to shrink the end of the OS X partition by 650MB, and in the empty space left recreate a recovery partition. The process is automated and there is no need to resize the OS X partition or re-create the Recovery HD manually. We will only need the above requirements!
Setting Up To Recreate Recovery
Place the required files (the dmg and the app) on the Desktop, and open the Terminal.app.
To mount the RecoveryHDUpdate.dmg that contains the tool that we will be using to recreate the partition type the following in the Terminal:
hdiutil attach -nobrowse ~/Desktop/RecoveryHDUpdate.dmg
Now to extract the contents of RecoveryHDUpdate.pkg that contains the tool type:
pkgutil --expand /Volumes/Mac\ OS\ X\ Lion\ Recovery\ HD\ Update/RecoveryHDUpdate.pkg /tmp/RecoveryHDUpdate
We now have a new directory called RecoveryHDUpdate within the/tmp directory. And within this directory the tool that will be used to recreate the recovery partition.
Our tool setup is ready, now we need to mount the image that contains the partition data. Follow the steps:
(A) Locate on your Desktop the
OS X installer (Install OS X El Capitan.app or Install OS X Yosemite.app, or other)
(B) Right click it and choose Show Package Contents
(C) Navigate to Contents/SharedSupport folder
(D) Copy the file InstallESD.dmg to your Desktop
Now we can mount the OS X installation image using the
Terminal! Type in:
hdiutil attach -nobrowse ~/Desktop/InstallESD.dmg
Recreating The Hd Recovery Partition
Everything ready! Now let's run the command to create the
Recovery HD partition. BE PATIENT and wait for the command to complete its execution. It may take a while, DO NOT close the terminal and DO NOT interrupt the program!!!
To avoid typos, simply copy and paste the command in the terminal. To start the process type:
sudo /tmp/RecoveryHDUpdate/RecoveryHDUpdate.pkg/Scripts/Tools/dmtest ensureRecoveryPartition / /Volumes/OS\ X\ Install\ ESD/BaseSystem.dmg 0 0 /Volumes/OS\ X\ Install\ ESD/BaseSystem.chunklist
When the command above finishes the partition will be created. But we need to update the kexts caches. To do this we need to run the touch command on the com.apple.Boot.plist file to change its date thus forcing an update of the cache.
To update the kexts run the following commands:
sudo touch /Library/Preferences/SystemConfiguration/com.apple.Boot.plist sudo kextcache -f -u /
Let's now clean what was left behind. First delete the folder you created in /tmp:
sudo rm -rf /tmp/RecoveryHDUpdate
And finally unmount the two images that were previously mounted:
hdiutil eject /Volumes/Mac\ OS\ X\ Lion\ Recovery\ HD\ Update hdiutil eject /Volumes/OS\ X\ Install\ ESD/
Now when you start your Mac you can press CMD + R to boot-up the Recovery partition.
Obviously, if you have El Capitan installed should use the El Capitan installation app, if you have Yosemite installed then use the Yosemite installation app. Always use the image of the OS you have installed!
If you do not have the OS Install application (it is automatically deleted after the update) you can get it from the AppStore. Open the AppStore and click on Purchased and search for it in the list. Click Install, the App will be re-downloaded to the Applications folder.
Remember, you are creating a new partition after the OS X partition. If there are already other partitions after OS X partition these will have their numbers and nodes changed. In the above example, the Windows partition number 3 on the node disk0s3 was turned into partition number 4 on the node disk0s4. And the Linux partitions number 4 node disk0s4 turned into number 5 node disk0s5.
Because of what is described above you will need to update/reinstall the bootloader (grub/lilo) of your Linux distro (if applies) to reflect the new root node/UDID. Windows should be ok.
If you use a third-party bootloader, such as rEFInd, then you should be all ok, as it does the
boot loadingof the thing.
DO NOT FORGET TO BACK UP BEFORE YOU START!