Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

When changing my mac HDD to an SSD I ran into the following problem:

I've created a DMG image of my old HDD which has a capacity of 320GB. The DMG file remembered and saved the capacity in the image, and the problem is my SSD is only 120GB.. So the DMG can't be used if I can't decrease the capacity somehow..

EDIT: The total amount of used space on the image is only 15GB..

I've looked at hdiutil but I'm actually a ruby on rails developer so I don't really get this stuff..

Is their any way with this or another util to decrease the capacity of the DMG?

Thanks!

share|improve this question

migrated from serverfault.com Aug 13 '12 at 20:22

This question came from our site for professional system and network administrators.

3 Answers 3

up vote 14 down vote accepted

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 /location/of/NEW/disk.dmg

Then, compact the resulting sparsebundle:

hdiutil compact /PATH/TO/DISK/IMAGE.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!

share|improve this answer
    
I've tried this, but the resize verb throws a permission problem, I'm now creating an RW disk image of to see if that works. –  Tim Aug 14 '12 at 8:00
    
With my RW disk image, I was able to use the resize verb and shrink the image to 120G, this resulted in a 128,85 GB capacity.. So that's the right way, but it's still not enough to fit on my SSD.. The compact verb doesn't work, it says compact failed - function not implemented. –  Tim Aug 14 '12 at 8:40
    
I've updated my answer, with a more detailed description of how it should be done.. If you can check if I'm explaining it right and update your answer I can flag yours as the right answer. Your answer is confusing because resize doesn't create a sparseimage which you refer to. And compact doesn't compress into a sparseimage, but it needs one. At least this is what I figured out.. Thanks! –  Tim Aug 14 '12 at 9:27
    
Updated to reflect your correction; sorry I hadn't included the part where you clone your image over. Slipped my mind! –  SoFLy Aug 15 '12 at 23:14
1  
Great! Flagged your answer, hope it can help some others! –  Tim Aug 16 '12 at 9:46

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.
share|improve this answer
    
Thanks for your reaction.. When executing this command I get the response that theirs a permission problem.. Probably because the dmg is a read-only formatted disk image.. I now have Carbon Copy Cloner creating a copy via FireWire.. –  Tim Aug 13 '12 at 20:02
    
You can use Mac OS X Disk Utility to convert from ro to rw image. –  klocek Aug 13 '12 at 20:08
    
I got it working with CCC, thanks for your help anyway! –  Tim Aug 13 '12 at 20:11

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)..

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.