Creating an updated Recovery HD
One of the challenges with imaging with Lion and the upcoming Mountain Lion can be creating a Recovery HD partition. There’s an existing solution developed by Clay Caviness which uses Lion Recovery Update to install a Recovery HD partition, but that update installs a Recovery HD that’s running 10.7.2.
Joel Bruner built on Clay’s work to develop a scripted process for installing or updating the Recovery HD partition with the current OS, but Joel’s process requires user input. For those wanting to have an automated process, Allen Golbig built on Joel’s work to develop an installer package that installs an up-to-date Recovery HD partition on Macs that have an older or missing Recovery HD partition. Since the installer doesn’t need user input, the installer can be run by itself or as part of an automated workflow. See below the jump for the procedure.
Prerequisites:
The latest version of Install Mac OS X.app from the Mac App Store
Joel Bruner’s createRecoveryHDUpdater script
Getting the various pieces you’ll need:
Once you’ve got Lion Recovery Update, the latest version of Install Mac OS X.app from the Mac App Store and Joel’s createRecoveryHDUpdater script available, create a folder for the output of Joel’s script. In my case, I created a folder on my destop called recover
Once you have your destination folder created, double-click on createRecoveryHDUpdater.command to open it.
It’ll prompt you for the various parts it needs as well as the location of the output folder, which you can just drag into the Terminal window and press Enter.
Once it has everything it needs, the script will run.
The eventual output is a disk image that will be stored in your output folder. In that disk image are the parts needed to build an up-to-date Recovery HD partition.
Packaging with Iceberg:
Set up a new Iceberg project. Since we’ll need to run this installer with root privileges, I recommend setting the project type to Darwin: Package. That will open the project with the installation privileges automatically set to root.
In this case, I’m naming the project 10.7.4 Recovery HD Creation.
Open the disk image from your output folder, then drag the following files into the Additional Resources section of your Iceberg project. (The order doesn’t matter.)
dmtest
BaseSystem.chunklist
BaseSystem.dmg
The last piece is telling the dmtest tool to build the new Recovery HD partition. For this, you’ll need a postflight script. Here’s the one I’m using:
#!/bin/sh "$1/Contents/Resources/dmtest" ensureRecoveryPartition / "$1/Contents/Resources/BaseSystem.dmg" 0 0 "$1/Contents/Resources/BaseSystem.chunklist"
Once you’ve got the postflight script built, run the following command to make the script executable:
sudo chmod a+x /path/to/postflight
Next, add the postflight script to your Iceberg package.
Last step, go ahead and build the package. (If you don’t know to build, check the Help menu for the Iceberg User Guide. The information you need is in Chapter 3 – Creating a package.)
Once the package has been built, you can test it by running it on one test machine that has an older Recovery HD and on another test machine that doesn’t have a Recovery HD partition. In both cases, you should now have an up-to-date Recovery HD partition.
Carbon Copy Cloner has a tool to recreate a recovery partition in its “disk center” window – very nice
How to create the Posflight script ? Can You Please Elaborate
when i type the following commands in terminal –
“#!/bin/sh
“$1/Contents/Resources/dmtest” ensureRecoveryPartition / “$1/Contents/Resources/BaseSystem.dmg” 0 0 “$1/Contents/Resources/BaseSystem.chunklist”
and Press Enter it says – “No such file or directory”
Saurabh,
You need to create a shell script to run the commands, not run them directly in Terminal. There’s a YouTube video available that shows the basics of making a shell script:
Thanks !
Brilliant. Thank you so much.
Has anyone tried doing this same process for Mountain Lion?
It should work, but I haven’t tried or tested it yet.