Change DMG capacity

There isn't a good way via GUI that I've seen to do this - you've got to use hdiutil as you asked. It's a quick command. To resize (change 25G to whatever you want),

hdiutil resize -size 25G /PATH/TO/DISK/IMAGE.dmg

Another way to compress it is to clone your disk image into a sparsebundle, then compress the sparsebundle. This may or may not work, depending on how much compression takes place.

First, create the disk image which mirrors your old disk image:

hdiutil convert /location/of/disk.dmg -format UDSP -o /PATH/TO/NEWIMAGE.sparseimage

Then, compact the resulting sparseimage:

hdiutil compact /PATH/TO/NEWIMAGE.sparseimage

If these commands don't work then it's got something to do with your disk image and/or permissions.

I have spent a lot of time playing with hdiutil and it's far from flawless - I've found & submitted bugs in Snow Leopard that still haven't been corrected in Mountain Lion, so if you do get a bit of odd behavior, don't be off-put!


Try this one:

hdiutil compact image.dmg

But as you can see in hdiutil manual:

Depending on the location of files in the hosted filesystem, compact may or may not shrink the image.

After cjc pointed out to ask the question at apple.stackexchange.com, I did. When asking the question I got to a related questing answered by someone saying to try Carbon Copy Cloner.

Carbon Copy Cloner cloned the files via FireWire to my SSDisk no questioned asked, and everything is how it should be..

Here's the question I'm referring to:

Restore system from DMG (original source disk bigger than destination)

For those of you interested in resizing a disk image:

Make your disk image read-write in Mac's Disk Utility:

Mount the disk, select it and click new disk image. Select read-write in the disk image structure drop down and click save. ( My OS is dutch, so these are my own translations ).

Use hdiutil to resize the disk image:

In terminal: hdiutil resize -size 100G /location/of/disk.dmg. You can replace 100G by the size you want.

Optional (didn't work for me), you can try to compact it:

In terminal: hdiutil convert /location/of/disk.dmg -format UDSP -o /location/of/NEW/disk.dmg.

This creates a sparse image.

Then: hdiutil compact /location/of/SPARSE/disk.dmg.sparseimage

This will try to free up space on the disk image.. If it works I guess you may need to resize your DMG again to lower the capacity (I'm not sure)..