Articles‎ > ‎

Creative ways of using shadow files

posted Dec 19, 2008, 3:55 PM by Philip Rinehart   [ updated Dec 19, 2008, 3:55 PM by Greg Neagle ]
Written by Philip Rinehart   
Wednesday, 28 March 2007
One of the hidden gems of the Macintosh administrator's toolbox is hdiutil.  Why?

One of the interesting things that can be done with hdiutil is attaching a read-only image using a shadow file.  Here's how:

 First, attach the read-only image as with the shadow option:

hdiutil attach -owners on your.dmg -shadow

After typing this command, the image will be attached as a new device to your operating system.  Usually this is shown from the command line.

Next, copy over any items, or modify anything on the read-only image.  Detach the image when finished:

hdiutil detach /dev/disk#

Almost done!  Now, convert the image back to read-only

 hdiutil convert -format UDZO -o new.dmg your.dmg -shadow

 Guess, what you now have a brand new dmg, and the time and space required to convert the image to read-write has been eliminated.