Skip to content

Instantly share code, notes, and snippets.

@startergo
Last active February 24, 2024 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save startergo/ef1433d74348966bb3f41925f67deae5 to your computer and use it in GitHub Desktop.
Save startergo/ef1433d74348966bb3f41925f67deae5 to your computer and use it in GitHub Desktop.
macOS DMG Deployment Workflow
  • Create a sparse image:
hdiutil create -size 32g -type SPARSE -fs HFS+J -volname "Macintosh HD" ~/Desktop/mountainlion_12f37_user.sparseimage
  • Mount the image:
hdiutil attach -owners on -noverify ~/Desktop/mountainlion_12f37_user.sparseimage
  • Mount the Installer:
hdiutil attach -noverify /Applications/Install\ OS\ X\ Mountain\ Lion.app/Contents/SharedSupport/InstallESD.dmg
  • Perform the Installation:
installer -pkg /Volumes/OS\ X\ Install\ ESD/Packages/OSInstall.mpkg -target /Volumes/Macintosh\ HD\ 1 -verboseR
  • Eject the Installation Target:
hdiutil eject /Volumes/Macintosh\ HD\ 1
  • Eject the Installation Media:
hdiutil eject /Volumes/OS\ X\ Install\ ESD
  • Convert the image:
hdiutil convert -format UDZO ~/Desktop/mountainlion_12f37_user.sparseimage -o ~/Desktop/mountainlion_12f37_user.dmg
  • Scan the image for restore:
asr imagescan --source ~/Desktop/mountainlion_12f37_user.dmg
  • Remove the sparse image:
rm -f ~/Desktop/mountainlion_12f37_user.sparseimage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment