Home » Tech » Mac » Mac OS X Disk Images
          

Mac OS X Disk Images

Create sparsebundle:
hdiutil create -size $SIZE -fs HFS+J -Volname $VOLNAME -type SPARSEBUNDLE $VOLNAME_backup

Convert to compressed sparsebundle:
hdiutil convert $VOLNAME_backup.sparsebundle -format UDBZ -o $VOLNAME_backup_compressed.sparsebundle.dmg

Mount read-only sparsebundle with read-write Shadow:
hdiutil attach -owners on $VOLNAME_backup_compressed.sparsebundle.dmg -mount required -shadow

Unmount:
hdiutil detach $VOLNAME

Commit changes in Shadow (can’t be done in-place; have to create new file):
hdiutil convert -format UDBZ -o $VOLNAME_backup_compressed_merged.sparsebundle.dmg $VOLNAME_backup_compressed.sparsebundle.dmg -shadow