Macos – Can’t mount dmg image as read/write

dmg-imageiso-imagemacososx-snow-leopard

Hello I've downloaded a bootable .iso image that I'd like to write to an USB stick under OSX (10.6).

I've converted the image with the command

 hdiutil convert -format UDRW -o ./X15-65804.img ./X15-65804.iso

The problem is that I need to remove a file from the image before writing it to USB.
As far as I understand during the conversion the new image file has become read/write (due to the -format UDRW switch). Still, I can't delete files from the mounted image (Permission denied).

I also tried to mount from command line:

hdiutil attach -readwrite X15-65804.dmg

Still no luck, the image is read-only. How could I mount it in read/write mode?

Best Answer

Disk images are just containers that emulate a disk. The DMG's contents are distinct from the DMG container. So you've probably only converted the container to read/write.

For example:

We can convert a DMG that contains an ISO to be read/write, but the ISO itself can only be read-only:

 ___________________        ___________________
|                   |      |                   |
|  Disk Image (r/o) |      |  Disk Image (r/w) |
|  _______________  |      |  _______________  |
| |               | |  ==> | |               | |
| | ISO9660 (r/o) | |      | | ISO9660 (r/o) | |
| |_______________| |      | |_______________| |
|___________________|      |___________________|

You run into a similar problem with the hybrid filesystem images that many OS distributions are shipping these days.

Here's an excerpt from the hdiutil(1) man page section on Hybrid images:

The generated image can later be burned using burn, or converted to another read-only format with convert.

The generated filesystem is not intended for conversion to read-write, but can safely have its files copied to a read/write filesystem by ditto(8) or asr(8) (in file-copy mode).

So there's the work-around: Copy the files off and make another DMG.

Which, unfortunately, is probably what you were hoping to avoid.

By the way, you might find this command helpful to peek into the DMG's partitions:

hdiutil pmap your_file.dmg
Related Question