Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A script to shrink and compress disk images easily' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to shrink and compress disk images easily
Authored by: sabi on Mar 10, '03 11:38:35AM
 && hdiutil resize -sectors `hdiutil resize \!:1.UDRW.dmg | awk \{print\ \$1\}` \!:1.UDRW.dmg \
This line can be made simpler:
 && hdiutil resize -sectors min \!:1.UDRW.dmg \
Here's a size comparison:
-rw-------    1 nicholas staff      458970 Mar 10 10:28 ICeCoffEE-1.3.2-awk.dmg
-rw-------    1 nicholas staff      458974 Mar 10 10:25 ICeCoffEE-1.3.2-min.dmg
-rw-------    1 nicholas staff      459134 Mar 10 10:21 ICeCoffEE-1.3.2-orig.dmg
-rw-------    1 nicholas staff      458970 Mar 10 10:30 ICeCoffEE-1.3.2.dmg
The file named "-awk" uses the script as provided, "-min" uses "-size min" instead of "-sectors min", and "-orig" is just gzipped, not resized first.

Interesting hint, thanks! hdiutil is very powerful, just hard to understand at times. Another useful space-saving hint is to create a partition map-less dmg, like this:

hdiutil create "$DMG" -megabytes 5 -ov -layout NONE -fs 'HFS+' -volname "$VOL"
You'll see it mount as /dev/disk#, instead of /dev/disk#s2.

[ Reply to This | # ]