8

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?

3
  • Does the original file have RW permissions?
    – user3463
    Oct 28, 2012 at 20:30
  • Do you mean the iso or dmg file itself? They're all 644 Oct 29, 2012 at 7:43
  • Yeah, but it sounds fine ...
    – user3463
    Oct 29, 2012 at 17:13

2 Answers 2

12
+50

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
4

I found this in the Examples section of the hdiutil man page:

 Converting:
       hdiutil convert master.dmg -format UDTO -o master
             converts master.dmg to a CD-R export image named master.cdr
       hdiutil convert /dev/disk1 -format UDRW -o devimage
             converts the disk /dev/disk1 to a read/write device image file.  authopen(1) will be used
             if read access to /dev/rdisk1 is not available.  Note use of the block-special device.

Also, this piece looks like something you could use:

Using a shadow file to attach a read-only image read-write to modify it, then convert it back to a read-only image. This method eliminates the time/space required to convert a image to read-write before modifying it.

       hdiutil attach -owners on Moby.dmg -shadow
       /dev/disk2   Apple_partition_scheme
       /dev/disk2s1 Apple_partition_map
       /dev/disk2s2 Apple_HFS               /Volumes/Moby

       ditto /Applications/Preview.app /Volumes/Moby
       hdiutil detach /dev/disk2
       hdiutil convert -format UDZO Moby.dmg -shadow

I'm even wondering how the original convert worked, it seems like the arguments are in the wrong order, eg. the input file shoud be after the word convert.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .