I have DMG I need to mount and write a file to. When I mount it, finder shows the root and all as read-only.
Then I discovered 'mount -w'. But when I run that, I get 'mount: unknown special file or file system.'
How can I mount this disk image as writable, or force a file into it?
Best Answer
Almost all read-only DMGs are actually compressed (
UDZ0
-- see thehdiutil(1)
man page), so their file format doesn't support simply "flipping a bit" to make them writable.You could use Disk Utility or
...to see what format your disk image is in. Then you could use Disk Utility or something like
...to convert it to a read-write format. Note that the conversion does not happen in-place, so you'll have to tell it to put the output file on a filesystem that has enough room for an uncompressed copy of all the data from your
.dmg
.The
.dmg
extension does not guarantee that the image is actually compressed, but that's by far the most likely possibility.There are several other possibilities available to you with
hdiutil
. For instance, if your.dmg
is actually uncompressed read-only (UDRO
), it might be possible to force it to mount read-write. Also, if you want to leave your.dmg
compressed but still want to mount it in a writable fashion, you can mount it with a "shadow file"; all writes actually get written to the shadow file.Update: Other Answers on this Question seem to think
.dmg
always meansUDZ0
which just isn't true. From thehdiutil(1)
man page, here are the list of internal formats a.dmg
can have (note that a couple of these can have different default filename extensions like.sparseimage
, but I'm pretty sure that's not a hard-and-fast rule either).