If you find yourself regularly creating disk images, you may find it helpful to automate this process. While a complete script is beyond the scope of this document, this section includes a code snippet to get you started.
For more information on hdiutil, see hdiutil.
Listing 8-1 Automatic Disk Image Creation using hdiutil
# 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 |
Last updated: 2008-04-08