{"id":474,"date":"2012-03-21T11:55:58","date_gmt":"2012-03-21T16:55:58","guid":{"rendered":"http:\/\/www.brunerd.com\/blog\/?p=474"},"modified":"2015-04-10T18:06:29","modified_gmt":"2015-04-10T23:06:29","slug":"update-create-lion-recoveryhd-partition-quickly-without-reinstalling","status":"publish","type":"post","link":"https:\/\/www.brunerd.com\/blog\/2012\/03\/21\/update-create-lion-recoveryhd-partition-quickly-without-reinstalling\/","title":{"rendered":"Update \/ Create Lion RecoveryHD Partition Quickly Without Reinstalling"},"content":{"rendered":"<p><strong>April 6, 2015 Update<\/strong>:\u00a0<a href=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/createRecoveryHDUpdater-15.4.6.command.zip\">createRecoveryHDUpdater 15.4.6.command<\/a>\u00a0&#8211; built\u00a0PKG now is targetable to volumes other than \/<\/p>\n<p><del><strong>Feb 28, 2015 Update: <\/strong>New script on <a title=\"Software\" href=\"http:\/\/www.brunerd.com\/blog\/software\/\">Software<\/a> page and <a href=\"http:\/\/www.brunerd.com\/blog\/2015\/02\/28\/recoveryhd-updater-now-with-pkg-building\/\">here<\/a>:<\/del><br \/>\n<del> <a href=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/createRecoveryHDUpdater-15.2.28.command.zip\">createRecoveryHDUpdater 15.2.28.command<\/a><\/del><\/p>\n<p><del>Apple released the\u00a0<a href=\"http:\/\/support.apple.com\/kb\/DL1464\">Lion Recovery Update<\/a>\u00a0in October, 2011, and, after they updated the Lion recovery partition to 10.7.2, there was a\u00a0<a href=\"https:\/\/plus.google.com\/109088229817689076273\/posts\/CDTUmQUiBV9\">great hint<\/a>\u00a0from Clay Caviness who dug into the update and highlighted the the relevant files and commands that it used to accomplish this update.<\/del><\/p>\n<p>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&#8217;t deem it necessary to update, but for some users, this may not be good enough.<\/p>\n<p><strong>Note:<\/strong>\u00a0Running the full 10.7.3 installer from the App Store\u00a0<strong>will<\/strong>\u00a0update the partition; this is fine for your home computer but not practical for large deployments.<\/p>\n<p><strong>Script Workflow:<\/strong><\/p>\n<ul>\n<li>Asks for locations of Recovery Update, Install OS X Lion.app, and destination<\/li>\n<li>Expands and collects the dmtest tool from the Lion Recovery Update<\/li>\n<li>Collects the hidden Basesystem chunklist and dmg found in the InstallESD.dmg inside &#8220;Install Mac OS X Lion.app&#8221;<\/li>\n<\/ul>\n<div>\n<figure id=\"attachment_476\" class=\"thumbnail wp-caption aligncenter\" style=\"width: 743px\"><a href=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/makingUpdaterDMG.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-476\" title=\"makingUpdaterDMG\" src=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/makingUpdaterDMG.png\" alt=\"\" width=\"733\" height=\"662\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/makingUpdaterDMG.png 733w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/makingUpdaterDMG-300x270.png 300w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/makingUpdaterDMG-332x300.png 332w\" sizes=\"auto, (max-width: 733px) 100vw, 733px\" \/><\/a><figcaption class=\"caption wp-caption-text\">The script making the Disk Image<\/figcaption><\/figure>\n<\/div>\n<ul>\n<li>Puts it all neatly into a self-contained disk image along with the script\u00a0<strong>RecoveryHD Updater.command<\/strong>\u00a0which can be used to easily\u00a0<strong>create<\/strong>\u00a0or\u00a0<strong>update<\/strong>\u00a0the RecoveryHD partition, even on the disk you are currently booted from; don&#8217;t worry dmtest takes care of all the logic to create or update.<\/li>\n<\/ul>\n<figure id=\"attachment_475\" class=\"thumbnail wp-caption aligncenter\" style=\"width: 706px\"><a href=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/RecoveryHD-Updater-Disk-Image.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-475\" title=\"RecoveryHD Updater Disk Image\" src=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/RecoveryHD-Updater-Disk-Image.png\" alt=\"\" width=\"696\" height=\"336\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/RecoveryHD-Updater-Disk-Image.png 696w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/RecoveryHD-Updater-Disk-Image-300x144.png 300w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/RecoveryHD-Updater-Disk-Image-500x241.png 500w\" sizes=\"auto, (max-width: 696px) 100vw, 696px\" \/><\/a><figcaption class=\"caption wp-caption-text\">The final disk image<\/figcaption><\/figure>\n<p style=\"text-align: center;\"><strong>Requirements:<\/strong><\/p>\n<ul>\n<li>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 &#8220;Install&#8221; (download) the latest version available<\/li>\n<li>Download\u00a0<a href=\"http:\/\/support.apple.com\/kb\/DL1464\">Lion Recovery Update<\/a>\u00a0from Apple<\/li>\n<\/ul>\n<p><strong>Script Tip:<\/strong><\/p>\n<p>Copy and paste the script into TextWrangler, save with a .command extension and it will automatically set the executable bit.<\/p>\n<p><a href=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/createRecoveryHDUpdater.command.zip\">createRecoveryHDUpdater.command<\/a>\u00a0(downloadable script):<\/p>\n<pre>#!\/bin\/bash\r\n\r\n#this script will make a disk image with the tools needed to update your Recovery HD with the newest OS X Lion release\r\n\r\n#Required components:\r\n#Lion Recovery Update v1.0 - http:\/\/support.apple.com\/downloads\/DL1464\/en_US\/RecoveryHDUpdate.dmg\r\n#\"Install Mac OS X Lion.app\" - App Store\r\n\r\n###########################\r\n# RecoveryHD Updater.command\r\n###########################\r\n\r\n#this script that will be saved to the disk image that is created\r\nRecoveryHDUpdaterScript='#!\/bin\/bash\r\nclear;\r\nMYPATH=\"$(dirname \"$0\")\"\r\n\r\n#get destination drive\r\nif [ \"$1\" == \"\" ]; then\r\necho -n \"Please drag in DESTINATION disk for Recovery HD partition and press Enter: \"\r\nwhile [ -z \"$DEST\" ]; do\r\nread DEST\r\ndone\r\nif [ ! -d \"$DEST\" ]; then echo \"$DEST not found\"; exit; fi\r\nelse\r\nDEST=\"$1\"\r\nfi\r\n\r\n#create Recovery partition\r\nsudo \"$MYPATH\"\/bin\/dmtest ensureRecoveryPartition \"$DEST\" \"$MYPATH\"\/etc\/BaseSystem.dmg 0 0 \"$MYPATH\"\/etc\/BaseSystem.chunklist\r\n'\r\n######\r\n# END\r\n######\r\n\r\n###########################\r\n# VARIABLES\r\n###########################\r\n\r\n#IMAGETEMP is the pathname for the disk image being built, will the OS and Build appended to the name later\r\nIMAGETEMP=\"\/tmp\/Recovery HD Updater\"\r\n\r\n#temp folder for package expansion\r\nRECOVERY_EXPANDED=\"\/tmp\/RecoveryHDUpdate\"\r\n\r\n#Mounted disk image paths\r\nESDPATH=\"\/Volumes\/Mac OS X Install ESD\"\r\nRECOVERYPATH=\"\/Volumes\/Mac OS X Lion Recovery HD Update\"\r\n\r\n#############\r\n# MAIN SCRIPT\r\n#############\r\nclear;\r\n#get Recovery Update dmg path\r\nif [ \"$1\" == \"\" ]; then\r\necho -n \"Please drag in RecoveryHDUpdate.dmg and press enter: \"\r\nwhile [ -z \"$RECOVERYHDUPDATE\" ]; do\r\nread RECOVERYHDUPDATE\r\ndone\r\nif [ ! -f \"$RECOVERYHDUPDATE\" ]; then echo \"$RECOVERYHDUPDATE not found\"; exit; fi\r\nelse\r\nRECOVERYHDUPDATE=\"$1\"\r\nfi\r\n\r\n#get Lion Installer path\r\nif [ \"$2\" == \"\" ]; then\r\necho -n \"Please drag in \\\"Install Mac OS X Lion.app\\\" and press enter: \"\r\nwhile [ -z \"$LION\" ]; do\r\nread LION\r\ndone\r\nif [ ! -d \"$LION\" ]; then echo \"$LION not found\"; exit; fi\r\nelse\r\nLION=\"$2\"\r\nfi\r\n\r\n#get destination path for disk image to be created at\r\nif [ \"$3\" == \"\" ]; then\r\necho -n \"Please drag in Destination folder for disk image: \"\r\nwhile [ -z \"$DEST\" ]; do\r\nread DEST\r\ndone\r\nif [ ! -d \"$DEST\" ]; then echo \"$DEST is not a valid path\"; exit; fi\r\nelse\r\nDEST=\"$3\"\r\nfi\r\n\r\n#mount Recovery Update image\r\nhdiutil attach \"$RECOVERYHDUPDATE\"\r\n\r\n#expand packge inside to temp folder (contains dmtest)\r\npkgutil --expand \"$RECOVERYPATH\"\/RecoveryHDUpdate.pkg \"$RECOVERY_EXPANDED\"\r\n\r\n#if we were using what's inside the chunklist and recovery inside the update we would mount this\r\n#RecoveryHDMeta=\"\/Volumes\/Recovery HD Update\"\r\n#hdiutil attach \"$RECOVERY_EXPANDED\"\/RecoveryHDUpdate.pkg\/RecoveryHDMeta.dmg\r\n\r\n#open Lion install ESD image for the newest files\r\nhdiutil attach \"$LION\"\/Contents\/SharedSupport\/InstallESD.dmg\r\n\r\n#get OS version from Lion Installer ESD\r\nOSVER=$(defaults read \"$ESDPATH\"\/System\/Library\/CoreServices\/SystemVersion ProductUserVisibleVersion)\r\nOSBUILD=$(defaults read \"$ESDPATH\"\/System\/Library\/CoreServices\/SystemVersion ProductBuildVersion)\r\n\r\n#append info to path so disk image volume name is informative and useful\r\nIMAGETEMP=\"$IMAGETEMP $OSVER $OSBUILD\"\r\n\r\n#make work the folder\r\nmkdir -p \"$IMAGETEMP\"\/etc\/\r\nmkdir \"$IMAGETEMP\"\/bin\/\r\n\r\n#copy dmtest to IMAGETEMP\r\nif [ -f \"$RECOVERY_EXPANDED\"\/RecoveryHDUpdate.pkg\/Scripts\/Tools\/dmtest ]; then\r\ncp \"$RECOVERY_EXPANDED\"\/RecoveryHDUpdate.pkg\/Scripts\/Tools\/dmtest \"$IMAGETEMP\"\/bin\/\r\nelse\r\necho \"$RECOVERY_EXPANDED\/RecoveryHDUpdate.pkg\/Scripts\/Tools\/dmtest not found, exiting\"\r\nexit 1\r\nfi\r\n\r\n#copy the BaseSystem dmg and chunklist to destination\/etc\r\nif [ -f \"$ESDPATH\"\/BaseSystem.chunklist -o -f \"$ESDPATH\"\/BaseSystem.dmg  ]; then\r\ncp \"$ESDPATH\"\/BaseSystem.chunklist \"$ESDPATH\"\/BaseSystem.dmg \"$IMAGETEMP\"\/etc\/\r\n#unhide BaseSystem\r\nchflags -R nohidden \"$IMAGETEMP\"\r\nelse\r\necho \"$ESDPATH\/BaseSystem* not found, exiting\"\r\nfi\r\n\r\n#put script in folder root\r\necho \"$RecoveryHDUpdaterScript\" &gt; \"$IMAGETEMP\"\/\"RecoveryHD Updater.command\"\r\n#set permissions\r\nchmod ugo+x \"$IMAGETEMP\"\/\"RecoveryHD Updater.command\"\r\n\r\n#create disk image from folder\r\nhdiutil create -srcfolder \"$IMAGETEMP\" \"$DEST\"\/RecoveryHDUpdater_$OSVER_$OSBUILD.dmg\r\nif [ $? -eq 0 ]; then\r\necho \"Success! Created: $DEST\/RecoveryHDUpdater_$OSVER_$OSBUILD.dmg\"\r\necho \"Now opening \"$DEST\"\/RecoveryHDUpdater_$OSVER_$OSBUILD.dmg\"\r\nhdiutil attach \"$DEST\"\/RecoveryHDUpdater_$OSVER_$OSBUILD.dmg\r\nelse\r\necho \"Disk Image failed\"\r\nfi\r\n\r\necho \"Cleaning Up\"\r\n#delete temp folders\r\nrm -rf \"$IMAGETEMP\" \"$RECOVERY_EXPANDED\"\r\n\r\n#eject the volumes\r\nhdiutil eject \"$RECOVERYPATH\"\r\nhdiutil eject \"$ESDPATH\"\r\n\r\necho \"Done.\"\r\n\r\nexit<\/pre>\n<p>The script can also be run with command line arguments:<\/p>\n<blockquote><p>$ .\/createRecoveryHDUpdater.command [Recovery Update DMG] [Install Lion App] [Destination for DMG]<\/p><\/blockquote>\n<p>As well as the script that is put in the created disk image:<\/p>\n<blockquote><p>$ .\/RecoveryHD\\ Updater.command [Destination]<\/p><\/blockquote>\n<p>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&#8217;t worry about the trailing spaces it adds)<\/p>\n<p>When you run the script in the disk image you will be prompted for an admin password and away it goes, with all sorts of ugly output because it never thought a human would gaze upon it&#8217;s hidden ways&#8230;<\/p>\n<figure id=\"attachment_477\" class=\"thumbnail wp-caption aligncenter\" style=\"width: 971px\"><a href=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/dmtest-running.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-477\" title=\"dmtest running\" src=\"http:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/dmtest-running.png\" alt=\"\" width=\"961\" height=\"1500\" srcset=\"https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/dmtest-running.png 961w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/dmtest-running-192x300.png 192w, https:\/\/www.brunerd.com\/blog\/wp-content\/uploads\/dmtest-running-656x1024.png 656w\" sizes=\"auto, (max-width: 961px) 100vw, 961px\" \/><\/a><figcaption class=\"caption wp-caption-text\">dmtest updating the RecoveryHD partition<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>Update: Just tested with 10.7.4 and this script still works correctly, nothing has changed in the structure of the updated Install OS X Lion.app from the App store, note that the 10.7.4 installer is version 1.0.21 (10.7.2=1.0.13 and 10.7.3=1.0.16)<\/p>\n<p>Update: Script will work on 10.8 without modification, however I have updated the script anyway to be a bit quieter when mounting the various DMGs, to accept tilde paths, accept the RecoveryHDUpdater as either a DMG or PKG, and changed prompt phrasing to include Mountain Lion.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>April 6, 2015 Update:\u00a0createRecoveryHDUpdater 15.4.6.command\u00a0&#8211; built\u00a0PKG now is targetable to volumes other than \/ Feb 28, 2015 Update: New script on Software page and here: createRecoveryHDUpdater 15.2.28.command Apple released the\u00a0Lion Recovery Update\u00a0in October, 2011, and, after they updated the Lion recovery partition to 10.7.2, there was a\u00a0great hint\u00a0from Clay Caviness who dug into the update [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4,12],"tags":[],"class_list":["post-474","post","type-post","status-publish","format-standard","hentry","category-apple","category-os-x","category-scripting"],"_links":{"self":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/comments?post=474"}],"version-history":[{"count":11,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/474\/revisions"}],"predecessor-version":[{"id":685,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/posts\/474\/revisions\/685"}],"wp:attachment":[{"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/media?parent=474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/categories?post=474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.brunerd.com\/blog\/wp-json\/wp\/v2\/tags?post=474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}