diskutil eject /dev/disk2
: Use the specific command for your version. For example, for macOS Sonoma: sudo /Applications/Install\ macOS\ Sonoma.app/Contents/Resources/createinstallmedia --volume /Volumes/MyVolume (Replace "MyVolume" with the name of your USB drive) .
For very old OS X installers (e.g., Lion, Mountain Lion), you may need to use a different method or restore the .dmg directly via Disk Utility's Restore feature.
sudo /Applications/Install\ macOS\ Ventura.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled
Name the drive something simple, like "MyVolume," to make the next steps easier. 2. Mount the DMG