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.)
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.