Skip to content

Instantly share code, notes, and snippets.

@KEINOS

KEINOS/README.md Secret

Last active August 23, 2022 00:48
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 KEINOS/3b139cbf785a16727501dd4e5c0cf4bf to your computer and use it in GitHub Desktop.
Save KEINOS/3b139cbf785a16727501dd4e5c0cf4bf to your computer and use it in GitHub Desktop.
macOS ISO/DMG image creating bash script

Creating an ISO/DMG image from the macOS installer app

  1. Place the macOS installer app under the application directory.
  2. Follow the below steps in the terminal.
$ # Create a directory to output the ISO image
$ cd ~/Desktop
$ mkdir iso
$ cd iso
$ # Download the script (the below is for HighSierra)
$ curl -LO https://gist.github.com/raw/3b139cbf785a16727501dd4e5c0cf4bf/create_dmg_highsierra.sh
# # Execute the script and create the installer image
$ chmod +x create_iso_highsierra.sh
$ sudo ./create_iso_highsierra.sh
#!/usr/bin/env bash
# Create a DMG from the Big Sur installer app
# Originally from: https://github.com/kholia/OSX-KVM/tree/master/scripts
#
# Download URL of this script:
# https://gist.github.com/raw/3b139cbf785a16727501dd4e5c0cf4bf/create_dmg_bigsur.sh
# Bail at first DMG creation error
set -e
display_help() {
echo "Usage: $(basename $0) [-h] [<path/to/install_app.app> <path/to/output_dmg_file.dmg>]"
exit 0
}
if [ "$1" == "-h" ] ; then
display_help
fi
if [ "$#" -eq 2 ]
then
in_path=$1
dmg_path=$2
elif [ "$#" -eq 0 ]
then
in_path=/Applications/Install\ macOS\ Big\ Sur.app
dmg_path=~/Desktop/BigSur.dmg
echo "Using default paths:"
echo "Install app: $in_path"
echo "Output disk: $dmg_path"
else
display_help
fi
hdiutil create -o "$dmg_path" -size 14g -layout GPTSPUD -fs HFS+J
hdiutil attach "$dmg_path" -noverify -mountpoint /Volumes/install_build
sudo "$in_path/Contents/Resources/createinstallmedia" --volume /Volumes/install_build --nointeraction
# createinstallmedia leaves a bunch of subvolumes still mounted when it exits, so we need to use -force here.
# This might be fixed in a later Beta release:
hdiutil detach -force "/Volumes/Install macOS Big Sur"
#!/usr/bin/env bash
# Create a DMG from the Catalina installer app
# Originally from: https://github.com/kholia/OSX-KVM/tree/master/scripts
#
# Download URL of this script:
# https://gist.github.com/raw/3b139cbf785a16727501dd4e5c0cf4bf/create_dmg_catalina.sh
# Bail at first DMG creation error
set -e
display_help() {
echo "Usage: $(basename $0) [-h] [<path/to/install_app.app> <path/to/output_dmg_file.dmg>]"
exit 0
}
if [ "$1" == "-h" ] ; then
display_help
fi
if [ "$#" -eq 2 ]
then
in_path=$1
dmg_path=$2
elif [ "$#" -eq 0 ]
then
in_path=/Applications/Install\ macOS\ Catalina.app
dmg_path=~/Desktop/Catalina.dmg
echo "Using default paths:"
echo "Install app: $in_path"
echo "Output disk: $dmg_path"
else
display_help
fi
hdiutil create -o "$dmg_path" -size 9g -layout GPTSPUD -fs HFS+J
hdiutil attach "$dmg_path" -noverify -mountpoint /Volumes/install_build
sudo "$in_path/Contents/Resources/createinstallmedia" --volume /Volumes/install_build --nointeraction
hdiutil detach "/Volumes/Install macOS Catalina"
#!/usr/bin/env bash
# Create a DMG from the High Sierra installer app
# Originally from: https://github.com/kholia/OSX-KVM/tree/master/scripts
#
# Download URL of this script:
# https://gist.github.com/raw/3b139cbf785a16727501dd4e5c0cf4bf/create_dmg_highsierra.sh
# Bail at first ISO creation error
set -e
display_help() {
echo "Usage: $(basename $0) [-h] [<path/to/install_app.app> <path/to/output_iso_file.iso>]"
exit 0
}
if [ "$1" == "-h" ] ; then
display_help
fi
if [ "$#" -eq 2 ]
then
in_path=$1
dmg_path=$2
elif [ "$#" -eq 0 ]
then
in_path=/Applications/Install\ macOS\ High\ Sierra.app
dmg_path=~/Desktop/HighSierra.dmg
echo "Using default paths:"
echo "Install app: $in_path"
echo "Output disk: $dmg_path"
else
display_help
fi
# Borrrowed from multiple internet sources
hdiutil create -o "$dmg_path" -size 5600m -layout GPTSPUD -fs HFS+J
hdiutil attach "$dmg_path" -noverify -mountpoint /Volumes/install_build
sudo "$in_path/Contents/Resources/createinstallmedia" --volume /Volumes/install_build --nointeraction
# createinstallmedia may leave a bunch of subvolumes still mounted when it exits, so we need to use -force here.
hdiutil detach -force "/Volumes/Install macOS High Sierra"
#!/usr/bin/env bash
# Create a DMG from the Mojave installer app
# Originally from: https://github.com/kholia/OSX-KVM/tree/master/scripts
#
# Download URL of this script:
# https://gist.github.com/raw/3b139cbf785a16727501dd4e5c0cf4bf/create_dmg_mojave.sh
# Bail at first ISO creation error
set -e
display_help() {
echo "Usage: $(basename $0) [-h] [<path/to/install_app.app> <path/to/output_iso_file.iso>]"
exit 0
}
if [ "$1" == "-h" ] ; then
display_help
fi
if [ "$#" -eq 2 ]
then
in_path=$1
dmg_path=$2
elif [ "$#" -eq 0 ]
then
in_path=/Applications/Install\ macOS\ Mojave.app
dmg_path=~/Desktop/Mojave.dmg
echo "Using default paths:"
echo "Install app: $in_path"
echo "Output disk: $dmg_path"
else
display_help
fi
# Borrrowed from multiple internet sources
hdiutil create -o "$dmg_path" -size 7g -layout GPTSPUD -fs HFS+J
hdiutil attach "$dmg_path" -noverify -mountpoint /Volumes/install_build
sudo "$in_path/Contents/Resources/createinstallmedia" --volume /Volumes/install_build --nointeraction
# createinstallmedia may leave a bunch of subvolumes still mounted when it exits, so we need to use -force here.
hdiutil detach -force "/Volumes/Install macOS Mojave"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment