Skip to content

Instantly share code, notes, and snippets.

@iqiancheng
Forked from NapoleonWils0n/hdiutil.txt
Created February 26, 2024 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iqiancheng/49a1a21e0b63a8e880399e0b2143b37e to your computer and use it in GitHub Desktop.
Save iqiancheng/49a1a21e0b63a8e880399e0b2143b37e to your computer and use it in GitHub Desktop.
macosx: hdiutil creating disk images
hdiutil
Creating Internet-enabled Disk images
hdiutil internet-enable -yes /Path/to/image/myapp.dmg
burn an iso
hdiutil burn image.iso
hdiutil create -fs HFS+ -volname Backup -size 100m ~/Desktop/backup.dmg
hdiutil mount ~/Desktop/backup.dmg
ditto -rsrc -V ~/Desktop/datatobackup /Volumes/Backup >> /Volumes/Backup/backup.log
hdiutil unmount /Volumes/Backup
hdiutil burn ~/Desktop/backup.dmg -noverifyburn -noeject
hdiutil attach ./file.dmg
hdiutil detach ./file.dmg
Assuming your new image is called ~/Desktop/Master.cdr (the file is on your desktop and called Master.cdr) type:
hdiutil makehybrid -iso -joliet -o Master.iso Master.cdr
# Create an initial disk image (32 megs)
hdiutil create -size 32m -fs HFS+ -volname "My Volume" myimg.dmg
# Mount the disk image
hdiutil attach myimg.dmg
# Obtain device information
DEVS=$(hdiutil attach myimg.dmg | cut -f 1)
DEV=$(echo $DEVS | cut -f 1 -d ' ')
# Unmount the disk image
hdiutil detach $DEV
# Convert the disk image to read-only
hdiutil convert myimg.dmg -format UDZO -o myoutputimg.dmg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment