Home > Bash scripting, Mac administration, Mac OS X > Creating an updated Recovery HD

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:

Lion Recovery Update

The latest version of Install Mac OS X.app from the Mac App Store

Joel Bruner’s createRecoveryHDUpdater script

Iceberg

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

Screen Shot 2012-06-26 at 8.07.18 AM

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.

Screen Shot 2012-06-26 at 8.12.02 AM

Once it has everything it needs, the script will run.

Screen Shot 2012-06-26 at 8.12.28 AM

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.

Screen Shot 2012-06-26 at 8.15.06 AM

Packaging with Iceberg:

Set up a new Iceberg project. Since well 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.

Screen Shot 2012-06-26 at 9.59.35 AM

In this case, I’m naming the project 10.7.4 Recovery HD Creation.

Screen Shot 2012-06-26 at 8.17.06 AM

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

Screen Shot 2012-06-26 at 8.16.13 AM

Screen Shot 2012-06-26 at 8.18.26 AM

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"

Screen Shot 2012-06-26 at 8.20.56 AM

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.

Screen Shot 2012-06-26 at 8.22.25 AM

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.

  1. gurduv
    July 1, 2012 at 5:54 am

    Carbon Copy Cloner has a tool to recreate a recovery partition in its “disk center” window – very nice

  2. July 3, 2012 at 8:00 am

    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”

    • July 3, 2012 at 8:50 am

      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:

  3. July 3, 2012 at 6:14 pm

    Thanks !

  4. July 13, 2012 at 10:23 pm

    Brilliant. Thank you so much.

  5. Michael Crispin
    July 27, 2012 at 11:03 pm

    Has anyone tried doing this same process for Mountain Lion?

    • July 27, 2012 at 11:07 pm

      It should work, but I haven’t tried or tested it yet.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 151 other followers

%d bloggers like this: