Skip to content

Instantly share code, notes, and snippets.

@ChrisTollefson
Last active March 13, 2025 02:52
Show Gist options
  • Save ChrisTollefson/94d0ef653c1fcdd4754afb8c795fc91a to your computer and use it in GitHub Desktop.
Save ChrisTollefson/94d0ef653c1fcdd4754afb8c795fc91a to your computer and use it in GitHub Desktop.
Create macOS installation ISO
# Commands to download and create an ISO image for installing macOS.
# NOTE: Not actually a script; run commands individually.
# SPDX-License-Identifier: MIT
# Copyright © 2025 Chris Tollefson.
# Licensed under the MIT License (https://opensource.org/licenses/MIT).
# NOTE: This process will take a fair amount of time,
# and a lot of disk space, currently approaching 60 GB...
# To start, download the latest version of macOS.
# This could be done from the App Store, or using the command line.
# From the App Store, download the latest version of Sequoia, for example, from:
# macappstores://apps.apple.com/app/macos-sequoia/id6596773750?mt=12
# (See https://support.apple.com/en-ca/102662 for more info and other versions.)
# Or download it using the command line as follows...
# ... Check which versions are available.
softwareupdate --list-full-installers
# ... Download the latest full installer. (Takes awhile.)
# (FYI, combo updates are no longer provided separately,
# so just get the full latest version.)
softwareupdate --fetch-full-installer --full-installer-version 15.3.2
# That will create an "Install macOS ..." app package in your Applications folder.
# Optional tip: Copy that app and back it up elsewhere for future use,
# to save you from having to download it again.
# Create a temporary sparse image big enough to contain the entire installer.
# (Only occupies the disk space of the files it actually contains; grows as necessary.)
hdiutil create -size 20g -type SPARSE -fs HFS+J -volname MACOS -layout SPUD /var/tmp/macos.sparseimage
# Attach and mount the image. (Don't bother checking it, as it's empty,
# plus we'll completely overwrite it anyway. Also make it invisible to Finder.)
hdiutil attach /var/tmp/macos.sparseimage -noverify -nobrowse
# Create the macOS installer onto the image. (Takes awhile.)
# (See https://support.apple.com/en-ca/101578 for other versions of macOS.)
# If this is Sierra 10.12 or earlier, you might need to add the applicationpath argument:
# sudo /Applications/Install\ macOS\ Sequoia.app/Contents/Resources/createinstallmedia --volume /Volumes/MACOS --applicationpath /Applications/Install\ macOS\ Sequoia.app
sudo /Applications/Install\ macOS\ Sequoia.app/Contents/Resources/createinstallmedia --volume /Volumes/MACOS
# Unmount and detach the image.
hdiutil detach /Volumes/Install\ macOS\ Sequoia
# Shrink the image to the minimum possible size.
hdiutil compact /var/tmp/macos.sparseimage
hdiutil resize -sectors min /var/tmp/macos.sparseimage
# Convert it to an optical disk image. (Takes awhile.)
hdiutil convert /var/tmp/macos.sparseimage -format UDTO -o /var/tmp/macos.cdr
# Remove the temporary sparse image.
rm /var/tmp/macos.sparseimage
# Rename the optical disk image.
mv /var/tmp/macos.cdr /var/tmp/Install\ macOS\ Sequoia.iso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment