macOS

DMG Image Edit - R/W

It is quite easy to mount a DMG image in read/write mode. Say you want to copy something inside a read only DMG.

First mount the image in "read/write" mode (with shadow option), then when finished editing the DMG, convert/copy the changes made inside the shadow copy into another DMG.

How

  • Open Terminal.app and mount the image with the shadow option
    hdiutil attach -owners on Original.dmg -shadow
    

 

  • Edit the DMG contents, when finished editing unmount the image
    hdiutil detach /dev/disk#
    

Where # is the image's disk number (use: diskutil list to list them all)

 

  • Now convert the shadow to a new DMG
    hdiutil convert -format UDZO -o The_Edited.dmg Original.dmg -shadow
    

Output Formats

These are the image output formats you can choose from:

UDRW UDIF read/write image
UDRO UDIF read-only image
UDCO UDIF ADC-compressed image
UDZO UDIF zlib-compressed image
ULFO UDIF lzfse-compressed image (OS X 10.11+ only)
UDBZ UDIF bzip2-compressed image (Mac OS X 10.4+ only)
UDTO DVD/CD-R master for export
UDSP SPARSE (grows with content)
UDSB SPARSEBUNDLE (grows with content; bundle-backed)
UFBI UDIF entire image with MD5 checksum
UDRo UDIF read-only (obsolete format)
UDCo UDIF compressed (obsolete format)
RdWr NDIF read/write image (deprecated)
Rdxx NDIF read-only image (Disk Copy 6.3.3 format;
ROCo NDIF compressed image (deprecated)
Rken NDIF compressed (obsolete format)
DC42 Disk Copy 4.2 image (obsolete format)