One way to avoid keeping DMG files after installation

Jan 11, '08 07:30:02AM

Contributed by: jef_pearlman

I often find my downloads directory filling with disk images I've downloaded off the internet, installed, and forgotten to delete after unmounting (and possibly rebooting). I'm not sure this qualifies as a hint, but I find the following trick effective to avoid the problem:

While you can't mount an image from the trash using the Finder, you can trash an image once it is already mounted. I won't go into the technical details of why this is true, but the system has no problem keeping track of the actual image's location. So after you open an image to mount it, you can immediately trash it. You can then install and unmount (or reboot) like normal, and forget about the image file altogether, since it's already trashed.

As an alternative, you can mount an image from the trash from the command line. For example:

open ~/.Trash/MyTrashedImage.dmg
And although the Finder will not empty the image from the trash while it is mounted, you can use the command line to remove the image file altogether after it's mounted, bypassing the trash altogether:
rm ~/Downloads/MyMountedImage.dmg
If the image is actually a sparsebundle, this technique should probably be avoided (some will probably work, some will definitely not, and some might have problems if you empty the trash). However, .dmg installers downloaded off the internet should be fine. However, as with any use of rm, be careful what you delete, and make sure you have a current backup!

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080109092817695