First download the install app bundle. Older versions can be hard to find but the current version of the time you read this, can be found in the App Store.
To create a drive run this command: hdiutil create -o /tmp/Mojave.cdr -size 6200m -layout SPUD -fs HFS+J
.
Next you will need to mount that drive hdiutil attach /tmp/Mojave.cdr.dmg -noverify -mountpoint /Volumes/install_build
.
Use the downloaded app bundle to create the media: sudo /Applications/Install\ macOS\ Mojave.app/Contents/Resources/createinstallmedia --volume /Volumes/install_build
.
Move the drive to your desktop: mv /tmp/Mojave.cdr.dmg ~/Desktop/InstallSystem.dmg
.
Detach the drive: hdiutil detach /Volumes/Install\ macOS\ Mojave
.
Covnert it: hdiutil convert ~/Desktop/InstallSystem.dmg -format UDTO -o ~/Desktop/Mojave.iso
.
The resulting file will be ~/Desktop/Mojave.iso.cdr
. Rename this file to ~/Desktop/Mojave.iso
and choose "use .iso" from the dialog. And you're all set!
thanks for this