Skip to content

Instantly share code, notes, and snippets.

@Underdoge
Forked from julianxhokaxhiu/create-iso.sh
Created October 2, 2024 22:47
Show Gist options
  • Save Underdoge/f50fbc56c37bf8ea6a7f06880f5533c4 to your computer and use it in GitHub Desktop.
Save Underdoge/f50fbc56c37bf8ea6a7f06880f5533c4 to your computer and use it in GitHub Desktop.
Simple bash script to create a Bootable ISO from macOS Catalina Install Image from Mac App Store
#!/usr/bin/env bash
#===========================================================================
# Works only with the official image available in the Mac App Store.
# Make sure you download the official installer before running this script.
#===========================================================================
DISK_SIZE="${2:-16016m}"
VERSION="${1:-Sequoia}"
#===========================================================================
echo "Using '$VERSION' for macOS version, and size of '$DISK_SIZE'."
hdiutil create -o "/tmp/$VERSION.cdr" -size $DISK_SIZE -layout SPUD -fs HFS+J
hdiutil attach "/tmp/$VERSION.cdr.dmg" -noverify -mountpoint /Volumes/install_build
extra_size=`sudo /Applications/Install\ macOS\ $VERSION.app/Contents/Resources/createinstallmedia --volume /Volumes/install_build --nointeraction 2>&1`
if [[ ! "$extra_size" == *"additional"* ]]; then
hdiutil detach "/Volumes/Install macOS $VERSION"
hdiutil convert "/tmp/$VERSION.cdr.dmg" -format UDTO -o "/tmp/$VERSION.iso"
mv "/tmp/$VERSION.iso.cdr" ~/Desktop/$VERSION.iso
rm "/tmp/$VERSION.cdr.dmg"
else
extra_size="$(echo $extra_size | awk '{ print $11 }')"
extra_size=`expr $extra_size*1024+1 | bc`
extra_size=${extra_size%.*}
DISK_SIZE=${DISK_SIZE::${#DISK_SIZE}-1}
DISK_SIZE=`expr $DISK_SIZE+$extra_size | bc`
DISK_SIZE="${DISK_SIZE}m"
echo "New Size: $DISK_SIZE"
rm "/tmp/$VERSION.cdr.dmg"
hdiutil create -o "/tmp/$VERSION.cdr" -size $DISK_SIZE -layout SPUD -fs HFS+J
hdiutil attach "/tmp/$VERSION.cdr.dmg" -noverify -mountpoint /Volumes/install_build
sudo /Applications/Install\ macOS\ $VERSION.app/Contents/Resources/createinstallmedia --volume /Volumes/install_build --nointeraction 2>&1
hdiutil detach "/Volumes/Install macOS $VERSION"
hdiutil convert "/tmp/$VERSION.cdr.dmg" -format UDTO -o "/tmp/$VERSION.iso"
mv "/tmp/$VERSION.iso.cdr" ~/Desktop/$VERSION.iso
rm "/tmp/$VERSION.cdr.dmg"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment