Almost all read-only DMGs are actually compressed (UDZ0
-- see the hdiutil(1)
man page), so their file format doesn't support simply "flipping a bit" to make them writable.
You could use Disk Utility or
hdiutil imageinfo filename.dmg
...to see what format your disk image is in. Then you could use Disk Utility or something like
hdiutil convert filename.dmg -format UDSP -o filename.sparseimage
...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 means UDZ0
which just isn't true. From the hdiutil(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).
UDRW - UDIF read/write image
UDRO - UDIF read-only image
UDCO - UDIF ADC-compressed image
UDZO - UDIF zlib-compressed image
UDBZ - UDIF bzip2-compressed image (OS X 10.4+ only)
UFBI - UDIF entire image with MD5 checksum
UDRo - UDIF read-only (obsolete format)
UDCo - UDIF compressed (obsolete format)
UDTO - DVD/CD-R master for export
UDxx - UDIF stub image
UDSP - SPARSE (grows with content)
UDSB - SPARSEBUNDLE (grows with content; bundle-backed)
RdWr - NDIF read/write image (deprecated)
Rdxx - NDIF read-only image (Disk Copy 6.3.3 format)
ROCo - NDIF compressed image (deprecated)
Rken - NDIF compressed (obsolete format)
DC42 - Disk Copy 4.2 image
The mount option user
only allows the filesystem to be mounted by any user. The rw
option makes the filesystem not readonly. You will have to use permissions to make the parent directory writeable.
chmod 777 /media/foo
The chmod
command you show only affects the existing files within /media/foo
.
Best Answer
overlayfs has been merged in kernel 3.18-rc2. Now that it has graduated to the main Linux tree, it is reasonable to guess that overlayfs will see a wider adoption in the future.