Skip to content

Instantly share code, notes, and snippets.

@Jolly-Pirate
Forked from julianxhokaxhiu/create-iso.sh
Last active March 1, 2017 02:42
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 Jolly-Pirate/703c70979f9062b7fb2b7fc55e76f0e7 to your computer and use it in GitHub Desktop.
Save Jolly-Pirate/703c70979f9062b7fb2b7fc55e76f0e7 to your computer and use it in GitHub Desktop.
Bash script to create a Bootable ISO from macOS Sierra Install Image from Mac App Store
#!/bin/bash
#
# Credits to fuckbecauseican5 from https://www.reddit.com/r/hackintosh/comments/4s561a/macos_sierra_16a238m_install_success_and_guide/
# Adapted to work with the official image available into Mac App Store
#
# Modified to use a sparse image
hdiutil attach /Applications/Install\ macOS\ Sierra.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app
hdiutil create -o /tmp/Sierra.sparseimage -size 7316m -type SPARSE -layout SPUD -fs HFS+J
hdiutil attach /tmp/Sierra.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build
asr restore -source /Volumes/install_app/BaseSystem.dmg -target /Volumes/install_build -noprompt -noverify -erase
rm /Volumes/OS\ X\ Base\ System/System/Installation/Packages
cp -rp /Volumes/install_app/Packages /Volumes/OS\ X\ Base\ System/System/Installation/
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/OS\ X\ Base\ System/BaseSystem.chunklist
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/OS\ X\ Base\ System/BaseSystem.dmg
hdiutil detach /Volumes/install_app
hdiutil detach /Volumes/OS\ X\ Base\ System/
# Resize the partition in the sparse file to remove any free space
hdiutil resize -size `hdiutil resize -limits /tmp/Sierra.sparseimage | tail -n 1 | awk '{ print $1 }'`b /tmp/Sierra.sparseimage
hdiutil convert /tmp/Sierra.sparseimage -format UDTO -o /tmp/Sierra.iso
# Remove the temporary sparse file
rm /tmp/Sierra.sparseimage
mv /tmp/Sierra.iso.cdr ~/Desktop/Sierra.iso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment