How to set up a dynamically resizing disk image

Creating Disk Images in OS X is relatively simple and an easy way to package items either for presentation, portability over electronic media, or encryption to protect data on otherwise unencrypted media.

Creating Disk Images in OS X is relatively simple and an easy way to package items either for presentation, portability over electronic media, or encryption to protect data on otherwise unencrypted media. To create images you will need to use Disk Utility, but in doing so you may find yourself lost among the various options for creating a disk image.

The very first source of confusion may come from clicking the "New Image" button in Disk Utility's toolbar, which will only present you with a limited set of options for creating an image. To be provided with all options, select "New Blank Image" from the File menu (or press Option-Command-N).

Blank Disk Image window
The "Blank Disk Image" dialog box has a number of additional options over clicking the "New Image" button (click for larger view).

With the new image dialog box open, you will be presented with a number of options for creating the image. Here is a rundown of what they do:

  • Name: This is the name of the disk image when it is mounted and shows up in the sidebar in the Finder (not the name of the image file itself, which is set at the top of the dialogue box).

  • Size: This is the maximum size of the volume for the image. Dynamically resizable images will start out smaller than this but get no larger, and fixed-size image files will be the size set here.

  • Format: This is where you pick the volume format such as HFS+ or FAT. For most purposes just use the default "Mac OS Extended (Journaled)," but if you plan on restoring the image to a drive for use in a Windows machine you might consider using FAT or NTFS if you have a supported NTFS driver installed (the free NTFS-3G will work).

  • Encryption: This is where you can select 128-bit, or 256-bit encryption options for security, or none if you do not want encryption. The 128-bit encryption is pretty fast and shows minimal difference in file access time, but 256-bit encryption may sometimes show a small lag when opening or saving files; however, it is still very usable.

  • Partitions: Just like standard hard drives, you can partition a disk image using various partitioning schemes, including GUID and Apple Partition Map. Keep in mind that setting a partition scheme is the only way you can have more than one volume on the disk image for separating your data. You can only set one partition when creating the image, but you can use Disk Utility afterward to create multiple partitions.

  • Image Format: Here is where you set the type of image, such as a standard read/write image, or a CD/DVD master image (for burning to audio or video media), or selecting either sparse or sparse bundle images.

Only Sparse or Sparse Bundle images will dynamically resize, so be sure to select one of those, and then set its size to at least accommodate the files you need, but optionally just make it as large as possible. If the size is greater than the available disk space, OS X will just truncate the available capacity to be the size of the available space on the drive. By doing this, when you add files either to the disk image or to the drive, both the available space in the image and the size of the image will adjust dynamically.

Disk Image size warning
My hard drive only has 120GB available, so the 5TB image is resized by Disk Utility. This is only done on read/write images (click for larger view).

If you want to create a disk image that is exactly the size of the available space on a volume and no more, you can do it with the following trick:

Go to the "New Image" dialog box and ensure the image format is a "read/write" image. Select the location to save it, and then set its size to be "Custom" and give it a value larger than the available space on the drive (i.e., 5TB). Disk Utility will give you an error and will resize the image to be the available space. From here, you can then change the image type to a Sparse or Sparse Bundle image and the size will stick.



Questions? Comments? Have a fix? Post them below or e-mail us!
Be sure to check us out on Twitter and the CNET Mac forums.

About the author

    Topher, an avid Mac user for the past 15 years, has been a contributing author to MacFixIt since the spring of 2008. One of his passions is troubleshooting Mac problems and making the best use of Macs and Apple hardware at home and in the workplace.

     

    Join the discussion

    Conversation powered by Livefyre

    Show Comments Hide Comments