Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Update/Create Lion RecoveryHD partition quickly Without Reinstalling System 10.7
Apple released the Lion Recovery Update in October, 2011, and, after they updated the Lion recovery partition to 10.7.2, there was a great hint from Clay Caviness who dug into the update and highlighted the the relevant files and commands that it used to accomplish this update.

Recently, 10.7.3 came out, however, and the RecoveryHD partition is not updated if you use Software Update; it will stay at 10.7.2. This is probably not a big deal, as Apple didn't deem it necessary to update, but for some users, this may not be good enough.

Note: Running the full 10.7.3 installer from the App Store will update the partition; this is fine for your home computer but not practical for large deployments.

Script Workflow:
  • Asks for locations of Recovery Update, Install OS X Lion.app, and destination
  • Expands and collects the dmtest tool from the Lion Recovery Update
  • Collects the hidden Basesystem chunklist and dmg found in the InstallESD.dmg inside "Install Mac OS X Lion.app"
  • Puts it all neatly into a self-contained disk image along with the script RecoveryHD Updater.command which can be used to easily create or update the RecoveryHD partition, even on the disk you are currently booted from; don't worry dmtest takes care of all the logic to create or update.

  • Requirements:
  • Download the latest version of Install OS X Lion.app. Option-click the Purchases tab in the App Store and you will be able to "Install" (download) the latest version available
  • Download Lion Recovery Update from Apple



    Script Tip:
    Copy and paste the script into TextWrangler, save with a .command extension and it will automatically set the executable bit.

    createRecoveryHDUpdater.command:
    #!/bin/bash
    
    #this script will make a disk image with the tools needed to update your Recovery HD with the newest OS X Lion release
    
    #Required components:
    #Lion Recovery Update v1.0 - http://support.apple.com/downloads/DL1464/en_US/RecoveryHDUpdate.dmg
    #"Install Mac OS X Lion.app" - App Store
    
    ###########################
    # RecoveryHD Updater.command
    ###########################
    
    #this script that will be saved to the disk image that is created
    RecoveryHDUpdaterScript='#!/bin/bash
    clear;
    MYPATH="$(dirname "$0")"
    
    #get destination drive
    if [ "$1" == "" ]; then
    echo -n "Please drag in DESTINATION disk for Recovery HD partition and press Enter: "
    while [ -z "$DEST" ]; do
    read DEST
    done
    if [ ! -d "$DEST" ]; then echo "$DEST not found"; exit; fi 
    else
    DEST="$1"
    fi
    
    #create Recovery partition
    sudo "$MYPATH"/bin/dmtest ensureRecoveryPartition "$DEST" "$MYPATH"/etc/BaseSystem.dmg 0 0 "$MYPATH"/etc/BaseSystem.chunklist
    '
    ######
    # END
    ######
    
    ###########################
    # VARIABLES
    ###########################
    
    #IMAGETEMP is the pathname for the disk image being built, will the OS and Build appended to the name later
    IMAGETEMP="/tmp/Recovery HD Updater"
    
    #temp folder for package expansion
    RECOVERY_EXPANDED="/tmp/RecoveryHDUpdate"
    
    #Mounted disk image paths 
    ESDPATH="/Volumes/Mac OS X Install ESD"
    RECOVERYPATH="/Volumes/Mac OS X Lion Recovery HD Update"
    
    #############
    # MAIN SCRIPT
    #############
    clear;
    #get Recovery Update dmg path
    if [ "$1" == "" ]; then
    echo -n "Please drag in RecoveryHDUpdate.dmg and press enter: "
    while [ -z "$RECOVERYHDUPDATE" ]; do
    read RECOVERYHDUPDATE
    done
    if [ ! -f "$RECOVERYHDUPDATE" ]; then echo "$RECOVERYHDUPDATE not found"; exit; fi 
    else
    RECOVERYHDUPDATE="$1"
    fi
    
    #get Lion Installer path
    if [ "$2" == "" ]; then
    echo -n "Please drag in \"Install Mac OS X Lion.app\" and press enter: "
    while [ -z "$LION" ]; do
    read LION
    done
    if [ ! -d "$LION" ]; then echo "$LION not found"; exit; fi 
    else
    LION="$2"
    fi
    
    #get destination path for disk image to be created at
    if [ "$3" == "" ]; then
    echo -n "Please drag in Destination folder for disk image: "
    while [ -z "$DEST" ]; do
    read DEST
    done
    if [ ! -d "$DEST" ]; then echo "$DEST is not a valid path"; exit; fi 
    else
    DEST="$3"
    fi
    
    #mount Recovery Update image
    hdiutil attach "$RECOVERYHDUPDATE"
    
    #expand packge inside to temp folder (contains dmtest)
    pkgutil --expand "$RECOVERYPATH"/RecoveryHDUpdate.pkg "$RECOVERY_EXPANDED"
    
    #if we were using what's inside the chunklist and recovery inside the update we would mount this
    #RecoveryHDMeta="/Volumes/Recovery HD Update"
    #hdiutil attach "$RECOVERY_EXPANDED"/RecoveryHDUpdate.pkg/RecoveryHDMeta.dmg
    
    #open Lion install ESD image for the newest files
    hdiutil attach "$LION"/Contents/SharedSupport/InstallESD.dmg
    
    #get OS version from Lion Installer ESD
    OSVER=$(defaults read "$ESDPATH"/System/Library/CoreServices/SystemVersion ProductUserVisibleVersion)
    OSBUILD=$(defaults read "$ESDPATH"/System/Library/CoreServices/SystemVersion ProductBuildVersion)
    
    #append info to path so disk image volume name is informative and useful
    IMAGETEMP="$IMAGETEMP $OSVER $OSBUILD"
    
    #make work the folder
    mkdir -p "$IMAGETEMP"/etc/
    mkdir "$IMAGETEMP"/bin/
    
    #copy dmtest to IMAGETEMP
    if [ -f "$RECOVERY_EXPANDED"/RecoveryHDUpdate.pkg/Scripts/Tools/dmtest ]; then
    cp "$RECOVERY_EXPANDED"/RecoveryHDUpdate.pkg/Scripts/Tools/dmtest "$IMAGETEMP"/bin/
    else
    echo "$RECOVERY_EXPANDED/RecoveryHDUpdate.pkg/Scripts/Tools/dmtest not found, exiting"
    exit 1
    fi
    
    #copy the BaseSystem dmg and chunklist to destination/etc
    if [ -f "$ESDPATH"/BaseSystem.chunklist -o -f "$ESDPATH"/BaseSystem.dmg  ]; then
    cp "$ESDPATH"/BaseSystem.chunklist "$ESDPATH"/BaseSystem.dmg "$IMAGETEMP"/etc/
    #unhide BaseSystem
    chflags -R nohidden "$IMAGETEMP"
    else
    echo "$ESDPATH/BaseSystem* not found, exiting"
    fi
    
    #put script in folder root
    echo "$RecoveryHDUpdaterScript" > "$IMAGETEMP"/"RecoveryHD Updater.command"
    #set permissions
    chmod ugo+x "$IMAGETEMP"/"RecoveryHD Updater.command"
    
    #create disk image from folder
    hdiutil create -srcfolder "$IMAGETEMP" "$DEST"/RecoveryHDUpdater_$OSVER_$OSBUILD.dmg
    if [ $? -eq 0 ]; then
    echo "Success! Created: $DEST/RecoveryHDUpdater_$OSVER_$OSBUILD.dmg"
    echo "Now opening "$DEST"/RecoveryHDUpdater_$OSVER_$OSBUILD.dmg"
    hdiutil attach "$DEST"/RecoveryHDUpdater_$OSVER_$OSBUILD.dmg
    else
    echo "Disk Image failed"
    fi
    
    echo "Cleaning Up"
    #delete temp folders
    rm -rf "$IMAGETEMP" "$RECOVERY_EXPANDED"
    
    #eject the volumes
    hdiutil eject "$RECOVERYPATH"
    hdiutil eject "$ESDPATH"
    
    echo "Done."
    
    exit
    

    The script can also be run with command line arguments:
    $ ./createRecoveryHDUpdater.command [Recovery Update DMG] [Install Lion App] [Destination for DMG]

    As well as the script that is put in the created disk image:
    $ ./RecoveryHD\ Updater.command [Destination]

    Otherwise just double-click it in the Finder and it will ask you for the files and paths which you can just drag into the Terminal window and press Enter (don't worry about the trailing spaces it adds)

    [kirkmc adds: Great script, thanks for this. I haven't tested it.]
  •     •    
    • Currently 4.17 / 5
      You rated: 2 / 5 (6 votes cast)
     
    [27,974 views]  

    Update/Create Lion RecoveryHD partition quickly Without Reinstalling | 12 comments | Create New Account
    Click here to return to the 'Update/Create Lion RecoveryHD partition quickly Without Reinstalling' hint
    The following comments are owned by whoever posted them. This site is not responsible for what they say.
    Update/Create Lion RecoveryHD partition quickly Without Reinstalling
    Authored by: ChipMck on Mar 22, '12 08:02:37AM

    Tried this.
    The creation process went well.
    Using the image on an existing Recovery HD (650 MB) resulted message about insufficient space.



    [ Reply to This | # ]
    Update/Create Lion RecoveryHD partition quickly Without Reinstalling
    Authored by: Vynce on Mar 25, '12 08:54:28PM
    Update/Create Lion RecoveryHD partition quickly Without Reinstalling
    Authored by: Graig on Mar 28, '12 08:53:58PM

    So I have installed Lion 10.7.3 from the Mac App Store on my iMac and assume that the RecoveryHD partition has also been updated. My question is, do I have to install Lion Recovery Update 1.0 now or is this update included in the 10.7.3 Mac App Store update?



    [ Reply to This | # ]
    Update/Create Lion RecoveryHD partition quickly Without Reinstalling
    Authored by: tleaming on Mar 31, '12 11:30:03AM

    At the end of the full blog (see link above), it is stated:

    "No need for Lion Recovery Update 1.0, that was for users of 10.7.1 who updated to 10.7.2"



    [ Reply to This | # ]
    Update/Create Lion RecoveryHD partition quickly Without Reinstalling
    Authored by: slb on Apr 25, '12 09:48:54AM

    Hi, every time I try to use the Recovery HD builder/updater, it gives me:
    “Error (async): The target disk is too small for this operation (-69771)
    logout”

    I erased the partition and tried that to no avail. Any insights?



    [ Reply to This | # ]
    *** Update on the "Not enough space" issue...
    Authored by: slb on Apr 25, '12 05:34:49PM

    The problem is (for me at least) is that I was selecting the "Recovery HD" as the target when in fact, you select your boot volume. It seemed odd to me, but I got immediate contact from Joel and that's the answer. So, hope that helps someone else.



    [ Reply to This | # ]
    10.7.4 works
    Authored by: joelbruner on May 10, '12 09:50:33AM

    Just tested with the newest "Install Mac OS X Lion.app" by downloading the full version from the App Store again (just hold down Option and click Purchases in App Store) and the script still works, yay, they didn't change anything around! The dmgs are still where the script expects them to be and so everything compiles great.

    Now whether you really need 10.7.4 on your Recovery HD partition that's another question :> However, this script will get you there without needing to run the entire installer again to do it!



    [ Reply to This | # ]
    10.7.4 works
    Authored by: Sven G on May 12, '12 04:21:44AM

    Yes, it works very well, indeed: tried it yesterday, on two computers that had been updated from 10.7.3 to 10.7.4.

    BTW, I wonder why Apple doesn't automatically update the recovery partition with every 10.7.x update...



    [ Reply to This | # ]
    Update/Create Lion RecoveryHD partition quickly Without Reinstalling
    Authored by: La_Tristesse on Aug 04, '12 03:26:22AM

    I just used the Recovery Update script inside the created dmg, but after specifing my Partition I can only boot into the "Recovery HD". please get back to me. I'm using FileVault2.



    [ Reply to This | # ]
    Update/Create Lion RecoveryHD partition quickly Without Reinstalling
    Authored by: Sven G on Jan 05, '14 11:41:38PM

    Is it safe to use this recovery partition update script also with OS X Mavericks, e.g., from 10.9 to 10.9.1...?



    [ Reply to This | # ]
    Update/Create Lion RecoveryHD partition quickly Without Reinstalling
    Authored by: Sven G on Jan 19, '14 04:34:50AM

    OK, so I tried it within a VMware Fusion 6.0.2 OS X 10.9.1 virtual machine, and indeed the script seems to work as before also in Mavericks: the recovery partition was updated from 10.9 to 10.9.1, and it also worked when booting into it (with cmd-R)...



    [ Reply to This | # ]
    Update/Create Lion RecoveryHD partition quickly Without Reinstalling
    Authored by: Sven G on Feb 08, '14 12:53:51AM

    FYI, here's an updated script, also for Mavericks:

    http://www.brunerd.com/blog/software

    http://www.brunerd.com/blog/wp-content/uploads/createRecoveryHDUpdater.command.zip

    There's only one cosmetic glitch remaining: now, in Mavericks, "BaseSystem.chunklist" and "BaseSystem.dmg" should be invisible, while they are again visible after running the Recovery HD updater created by the script; but this is easily fixed, from the Terminal:

    $ diskutil mount Recovery\ HD

    $ sudo chflags hidden /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.chunklist /Volumes/Recovery\ HD/com.apple.recovery.boot/BaseSystem.dmg

    It would probably be rather easy to update the script to include this (i.e., make these two files automatically invisible)...



    [ Reply to This | # ]