↓ Archives ↓

Archive → January, 2014

Mac CLI: Simple creation and management of disk images

From Mac command line you can crate a disk image as:

FOLDER=
hdiutil create $FOLDER.dmg -ov -volname "$FOLDER" -fs HFS+ -srcfolder "$FOLDER"

If you want to convert the Read-Only DMG image to a writable sparsebundle you can use:

hdiutil convert $FOLDER.dmg -format UDSB -o $FOLDER.sparsebundle

And you can set the dimension as:

hdiutil resize -4g $FOLDER.sparsebundle

Mac sparsebundles can be cloned with rsync as:

rsync -aNHAXEx --delete --protect-args --fileflags --force-change $FOLDER.sparsebundle /path/to/destination

References: