# macOS 12 Monterey

# Create and mount a working image file
hdiutil create -o /tmp/tmp_iso.cdr -size 15GB -layout SPUD -fs HFS+J
hdiutil attach /tmp/tmp_iso.cdr.dmg -noverify -mountpoint /Volumes/iso

# Execute Create install media of the restore source to restore
sudo /Applications/Install\ macOS\ Monterey.app/Contents/Resources/createinstallmedia --volume /Volumes/iso --nointeraction

# Unmount the mounted volume (because unmounting is required before covert. Note that the mount name of the restore destination has changed as a result of restoration)
hdiutil eject -force /Volumes/Install\ macOS\ Monterey

# Convert working image file to ISO image
hdiutil convert /tmp/tmp_iso.cdr.dmg -format UDTO -o /tmp/tmp_iso.iso

# Rename and save the ISO image
mv /tmp/tmp_iso.iso.cdr ~/Desktop/Monterey.iso

# Delete working image file
rm /tmp/tmp_iso.cdr.dmg