Backtrack:  
 
by lunarg on May 3rd 2021, at 13:07

macOS installers come equipped with a script (called createinstallmedia) to create a macOS bootable USB installer drive. But sometimes it may be necessary to create a bootable ISO. The process is similar as we will use a DMG image instead of a physical drive to create the installer, which can then be converted to ISO.

Follow these steps to get the work done:

  1. First, download the macOS installer of your choice (direct links to most installers can be found in this article). Note that you need to do this on a supported Mac with an Apple ID. The installer app will be placed in your Applications folder.
  2. After downloading, the installer will automatically be launched: ⌘ + Q out of it.
  3. Fire up Terminal, which is were you will perform all the tasks.
  4. Create a disk image (DMG) large enough to hold the bootable installer. For Catalina or below, 8500 MB is enough but newer versions may require a larger disk image size.
    hdiutil create -o ~/Desktop/macOS.dmg -size 8500m -volname macOS -layout SPUD -fs HFS+J
    Note that the names mentioned here are temporary and can be renamed if needed.
  5. Mount the freshly created disk image (DMG). The createinstallmedia expects it (just like with an USB flash device):
    hdiutil attach ~/Desktop/macOS.dmg -noverify -mountpoint /Volumes/macOS
  6. Next, like with a regular USB flash media, run the createinstallmedia command to create the installation media inside the mounted disk image:
    sudo /Applications/Install macOS Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/macOS --nointeraction
    Notice

    I encountered an issue where if any of the steps would fail, subsequent runs of createinstallmedia would immediately fail with the following error:

    Erasing Disk: 0%... 10%...
    Error erasing disk error number (22, 0)
    A error occurred erasing the disk.

    Looking on the internet, you find some messages claiming that it's due to incorrect permissions on the DMG file but this was not the case. The only workaround was to reboot my Mac and try again. I assume there's some sort of lock in place which causes this issue, and that rebooting obviously clears this lock.
  7. When the process has completed, the disk image will now hold a bootable copy of the installation media. Unmount the disk image before continuing with the conversion to ISO. Note that the mountpoint will be renamed to whatever version of macOS you're creating the installation media for, so adjust accordingly:
    hdiutil detach /volumes/Install macOS Mojave
  8. After unmounting the disk image, run the conversion:
    hdiutil convert ~/Desktop/macOS.dmg -format UDTO -o ~/Desktop/macOS.cdr
  9. After the conversion is completed, you can decide to keep or delete the original disk image (macOS.dmg). If necessary, rename the CDR file to ISO to be able to use it in VMware Fusion or VirtualBox.