Skip to content

Instantly share code, notes, and snippets.

@tjarksaul
Last active October 8, 2015 14:06
Show Gist options
  • Save tjarksaul/9cf419250eccf1c13702 to your computer and use it in GitHub Desktop.
Save tjarksaul/9cf419250eccf1c13702 to your computer and use it in GitHub Desktop.
Create Bootable ISO from Mavericks App.
#!/usr/bin/env bash
# Original: http://thezinx.com/2013/10/29/create-bootable-dmg-iso-mavericks-app.html
V_BUILD=/Volumes/install_build
V_APP=/Volumes/install_app
T_SI_B=/tmp/elcap
T_SI=$T_SI_B.sparseimage
# Mount the installer image
hdiutil attach /Users/tsaul/elcap/Install\ OS\ X\ El\ Capitan.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint $V_APP
# Convert the boot image to a sparse bundle
hdiutil convert $V_APP/BaseSystem.dmg -format UDSP -o $T_SI_B
# Increase the sparse bundle capacity to accommodate the packages
hdiutil resize -size 8g $T_SI
# Mount the sparse bundle for package addition
hdiutil attach $T_SI -noverify -nobrowse -mountpoint $V_BUILD
# Remove Package link and replace with actual files
rm -v $V_BUILD/System/Installation/Packages
cp -vrp $V_APP/Packages $V_BUILD/System/Installation/
# Unmount the installer image
hdiutil detach $V_APP
# Unmount the sparse bundle
hdiutil detach $V_BUILD
# Resize the partition in the sparse bundle to remove any free space
hdiutil resize -size $(hdiutil resize -limits $T_SI | tail -n 1 | awk '{ print $1 }')b $T_SI
# Convert the sparse bundle to ISO/CD master
hdiutil convert $T_SI -format UDTO -o $T_SI_B
# Remove the sparse bundle
rm -v $T_SI
# Rename the ISO and move it to the desktop
mv -v $T_SI_B.cdr ~/Desktop/macosx.iso
echo done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment