Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create OS X Install ISO Scripts
#!/bin/bash
OSX_NAME=ElCapitan
hdiutil attach "/Applications/Install OS X El Capitan.app/Contents/SharedSupport/InstallESD.dmg" -noverify -nobrowse -mountpoint /Volumes/esd
hdiutil create -o $OSX_NAME.cdr -size 7316m -layout SPUD -fs HFS+J
hdiutil attach $OSX_NAME.cdr.dmg -noverify -nobrowse -mountpoint /Volumes/iso
asr restore -source /Volumes/esd/BaseSystem.dmg -target /Volumes/iso -noprompt -noverify -erase
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -rp /Volumes/esd/Packages /Volumes/OS\ X\ Base\ System/System/Installation
cp -rp /Volumes/esd/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/
cp -rp /Volumes/esd/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/
hdiutil detach /Volumes/esd
hdiutil detach /Volumes/OS\ X\ Base\ System
hdiutil convert $OSX_NAME.cdr.dmg -format UDTO -o $OSX_NAME.iso
mv $OSX_NAME.iso.cdr ~/Desktop/$OSX_NAME.iso
#!/bin/bash
OSX_NAME=Yosemite
# Mount the installer image
hdiutil attach /Applications/Install\ OS\ X\ Yosemite.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
# Convert the boot image to a sparse bundle
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/$OSX_NAME
# Increase the sparse bundle capacity to accommodate the packages
hdiutil resize -size 8g /tmp/$OSX_NAME.sparseimage
# Mount the sparse bundle for package addition
hdiutil attach /tmp/$OSX_NAME.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build
# Remove Package link and replace with actual files
rm /Volumes/install_build/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/
# Copy Base System
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/install_build/
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/install_build/
# Unmount the installer image
hdiutil detach /Volumes/install_app
# Unmount the sparse bundle
hdiutil detach /Volumes/install_build
# Resize the partition in the sparse bundle to remove any free space
hdiutil resize -size `hdiutil resize -limits /tmp/$OSX_NAME.sparseimage | tail -n 1 | awk '{ print $1 }'`b /tmp/$OSX_NAME.sparseimage
# Convert the sparse bundle to ISO/CD master
hdiutil convert /tmp/$OSX_NAME.sparseimage -format UDTO -o /tmp/$OSX_NAME
# Remove the sparse bundle
rm /tmp/$OSX_NAME.sparseimage
# Rename the ISO and move it to the desktop
mv /tmp/$OSX_NAME.cdr ~/Desktop/$OSX_NAME.iso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment