Home > Bash scripting, DeployStudio, Mac administration, Mac OS X > Creating a never-booted 10.7 image with included Recovery HD partition

Creating a never-booted 10.7 image with included Recovery HD partition

One of my goals for 10.7 has been to recreate how my 10.6.x workflows work as closely as possible, with images being created with InstaDMG and deployed with DeployStudio. 10.7′s introduction of the Recovery HD partition threw a monkey wrench into that. However, after some research, more testing and an international effort to discover an Apple-supported way to create a Recovery HD partition without actually installing 10.7 on a drive, I was able to come up with a way to do it. See below the jump for details.


A Mac running Mac OS X 10.7.x

DeployStudio rc128 running on another Mac (other Mac does not have to be running 10.7)

DeployStudio rc128 boot set running Mac OS X 10.7.x (can be NetBoot, or using a Firewire/USB drive.)

InstaDMG1-6 r425 or higher

Install Mac OS X Lion.app

8 GB flash drive (optional)

Creating the 10.7 image with InstaDMG

To create a never-booted 10.7 image, we have to go a bit old school with InstaDMG by using InstaDMG.bash instead of InstaUp2Date.

(Update 9-2-2011:As of InstaDMG r426, InstaUp2Date now works with 10.7. Make sure to update your InstaDMG installation. If you don’t know how, see the InstaDMG manual.)

1. Download the latest version of InstaDMG to your Mac running 10.7.

2. Use Finder to locate Install Mac OS X Lion.app, right-click and select Show Package Contents.

3. Inside, find the SharedSupport folder and look for a file named InstallESD.dmg. This is the Lion installer image that you’ll use with InstaDMG.

4. Copy the InstallESD.dmg file to the following directory:


5. Run InstaDMG with the following command to create a vanilla never-booted 10.7 image. (This image will not have the Recovery HD partition, that comes later.)

sudo /path/to/instadmg/instadmg.bash

6. Once InstaDMG has finished, there should be a .dmg file in /path/to/instadmg/OutputFiles. This is your 10.7 image.

7. To make sure there’s no InstaDMG-related side effects that could affect the next steps, I recommend rebooting the 10.7 Mac at this point.

Creating Recovery HD

1. After the reboot, plug the flash drive into your 10.7 Mac (Note: any physical drive except the boot drive would work for this step, but I had the flash drive handy.)

2. Wipe the flash drive and use Disk Utility to repartition with one GUID partition. In my case, I named the flash drive RecoveryBuild.

3. Mount the InstallESD.dmg file from the Install Mac OS X Lion.app

4. Open Terminal and dump the installation choices for a standard OS install to an xml file by running the following command:

installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ ESD/Packages/OSInstall.mpkg -tgt /Volumes/RecoveryBuild -showChoiceChangesXML > /tmp/choices.xml

5. In whatever editing program you prefer, edit /tmp/choices.xml so that all of the attributeSetting keys are set to zero, except for the EssentialSystemSoftware and EssentialSystemSoftwareGroup dicts, in which case the attributeSetting key is left at 1. This is to speed the process up a bit by not installing all of the packages.

(For those who want it, I have my choices.xml for this posted at the following location: http://www.pastie.org/2290149 )

6. In Terminal, run the installer command with the modified choices.xml file:

sudo installer -verbose -pkg /Volumes/Mac\ OS\ X\ Install\ ESD/Packages/OSInstall.mpkg -tgt /Volumes/RecoveryBuild -applyChoiceChangesXML /tmp/choices.xml

Note: This process creates a never-booted recovery partition in an Apple-supported way.

Using DeployStudio to pull the Recovery HD partition into its own image.

1. Boot your 10.7 Mac from your DeployStudio rc128 boot set which running Mac OS X 10.7.x

2. Have DeployStudio pull an image from the drive you just created your Recovery HD partition on. (In my case, I was targeting RecoveryBuild.)

3. Once completed, you should have two images in your DeployStudio images directory:



filename.recovery.dmg is the image with your never-booted Recovery HD partition.

Putting it all together into a DeployStudio workflow

1. Rename your InstaDMG-created image to filename.hfs.dmg

2. Copy it to your DeployStudio images directory, so that it overwrites the existing filename.hfs.dmg.

3. Set up a new workflow, or modify an existing one, so that you are restoring using filename.hfs.dmg.

4. In the Restore task of your DeployStudio workflow, check the option for Restore system recovery partitions. Add any other steps to the workflow that you want, like setting the time, clearing the Setup Assistant, installing packages, etc.

Imaging a machine

1. Boot the machine you want to image from your DeployStudio rc128 boot set running Mac OS X 10.7.x

2. Log into the DeployStudio runtime and select the workflow with your newly-created 10.7 image.

3. Reimage the machine using that workflow.

4. After the imaging process finishes and all reboots have completed, you should have a Mac with your InstaDMG-created image on the boot partition and a fully functional and properly hidden Recovery HD partition.

  1. Adam Herman
    August 4, 2011 at 6:54 pm | #1

    This is VERY helpful. I was just working on a work-around for this but now I will just follow your steps…

  2. Kostas Backas
    August 7, 2011 at 10:56 am | #2


    Here is how I did it (my goal was to create a Lion image with a procreated user).

    1. Install Lion in a latest iMac (not the one coming with Lion) and create a user.
    2. Using latest DS, captured this image.
    3. Test the workflow by resetting the disk to a single partition and restore.
    4. The Recovery HD was created as well.


  3. novman
    August 16, 2011 at 1:18 am | #3

    Hi there,

    Am following your steps but when i run instadmg.bash i get this output:

    11:11:32 ###### InstaDMG build initiated ######
    InstaDMG version 1.6rc1 (svn revision: 388)
    Host OS: Mac OS X 10.6.8
    Host Hardware: MacBookPro4,1
    Output file name: 11-08-16.dmg
    Output disk name: InstaDMG
    11:11:33 ###### Finding main MacOS X installer disk ######
    ###### Unable to find primary installer disk ######
    11:11:33 ###### Cleaning up ######
    Restoring normal installd daemon
    Ejecting images

    Any suggestions as to where i am going wrong?

    • August 16, 2011 at 1:20 am | #4

      Going by the log you posted, you’re using an older version of InstaDMG and building on 10.6.8. Try updating your InstaDMG to the latest version available and building on 10.7. That should fix the issues you’re seeing.

      • novman
        August 16, 2011 at 2:38 am | #5

        Changes to my 10.7 server, still no luck, what is the best way to update – command line? Sorry completely new to this kind of stuff.

      • August 16, 2011 at 2:56 am | #6

        Since you’re new to InstaDMG, I recommend reading the PDF manual here: http://instadmg.googlecode.com/files/InstaDMG1-6rc1.pdf

        I also recommend building on 10.7 instead of 10.7 Server, as the image won’t be created correctly if built on Server.

  4. novman
    August 16, 2011 at 3:33 am | #7

    RTFM – im such a douchebag haha.


  5. August 16, 2011 at 2:58 pm | #8

    Is the create recovery partition necessary with current DSS builds? Had thought that automatica recovery partition creation was baked in the latest builds (could be wrong).

  6. Richard Carpenter
    August 24, 2011 at 10:09 am | #10

    I am having a problem running the following command line:

    sudo InstaDMG1-6rc1/instadmg.bash -s -I ./InstallerFiles/BaseOS/InstallESD.dmg -n “Macintosh HD” -m LionVanillaBuild

    But it bails out with an error ###### The OS Install File is missing the OS Installer Package! ######

    Please could someone have a llok at my log output?

    11:06:43 ###### InstaDMG build initiated ######
    InstaDMG version 1.6rc1 (svn revision: 388)
    Host OS: Mac OS X 10.7.1
    Host Hardware: MacBookPro8,1
    Output file name: LionVanillaBuild
    Output disk name: Macintosh HD
    11:06:43 ###### Finding main MacOS X installer disk ######
    11:06:43 ###### Looking for a Cached Image ######
    No cached image found
    11:06:43 ###### Mounting Mac OS X installer image ######
    Mac OS X installer image mounted
    11:06:45 ###### Creating intermediary disk image ######
    Target image: /private/tmp/idmg.0Ej5/C2CB1D2D-4225-4F3B-8B81-057F665B888C.sparseimage mounted successfully at: /tmp/idmg_mp.9wEG
    11:06:58 ###### Beginning Installation from /private/tmp/idmg.0Ej5/idmg_temp.2BK3EC ######
    ###### The OS Install File is missing the OS Installer Package! ######
    11:06:58 ###### Cleaning up ######
    Ejecting images
    Deleting scratch DMG

    • August 24, 2011 at 10:22 am | #11

      From the log, it looks like you’re running rev. 388 of InstaDMG and you need to be running rev. 425 or later. Try updating to the latest version and see if that fixes the problem you’re seeing.

  7. Richard Carpenter
    August 24, 2011 at 10:41 am | #12

    Thanks for the info, how do I update the version I am using. I downloaded the 1.6rc1 from http://code.google.com/p/instadmg/downloads/detail?name=InstaDMG1-6rc1.zip.

    How do i get the latest version if the distro on the website is the wrong one?

  8. Richard Carpenter
    August 24, 2011 at 12:52 pm | #14

    works a treat ta!

  9. September 6, 2011 at 5:30 pm | #15

    Hey Rich,

    I was giving this a shot today, using a build computer of my 2011 Air (new Thunderbolt) and the InstallESD.dmg that came from the App Store- version 1.0.4 (197). The build steps work fine, but when I try to create the choices.xml (or use yours), installer errors with

    Error – This version of Mac OS X 10.7 cannot be installed on this computer

    I conclude the build from the App Store can’t go on my Air. Any thoughts how to work around- better than building from different hardware?

  10. September 6, 2011 at 8:34 pm | #17

    So do we now have to be very specific with what InstallESD we grab for what hardware? My goal isn’t to build one for my Air, but an installer to test on some older Core 2 Duo era MPBs… do I have to use one of them to grab the right InstallESD, which wouldn’t necessarily be the right one for a Mac Pro?

    • September 6, 2011 at 9:05 pm | #18

      I see the problem now. The issue is that the new Air has a hardware-specific build of 10.7 and 10.7.1 (so does the new Mini.) Try building it using the App Store version on a Mac released before July 2011.

  11. September 6, 2011 at 9:10 pm | #19

    Unfortunately, based on what hardware I have available, I’ll have to build on a relatively old MBP… I’ll give it a shot and report back, once I’m done installing Lion on the machine via @gneagle’s new InstallLion.pkg, so I have another Lion machine to do the build on. :) . Tnx, Rich.

  12. September 6, 2011 at 9:13 pm | #20

    Just to be accurate… @gneagle= @gregneagle :P

  13. Kostas Backas
    September 6, 2011 at 11:11 pm | #21

    Only the new Air and the new Minis have model specific versions of Lion. The 10.7.1 “retail” is good for everything else.

  14. October 11, 2011 at 6:38 pm | #22

    Does anyone know if the Recovery partition is in any way hardware specific, like the 10.7.0 and 10.7.1 OSes were forked for the new Air and Mini models?

  15. Kostas Backas
    September 21, 2012 at 3:23 pm | #23

    Is the process diffrerent in Mountain Lion? I used the method with success (the Recovery HD is created fine) IMHO.

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


Get every new post delivered to your Inbox.

Join 125 other followers

%d bloggers like this: