Jump to content

Sparse image

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 2pem (talk | contribs) at 14:38, 21 January 2013 (Limitations: Added references to resizing a sparse disk image (edited with ProveIt)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Sparse Disk Image
Filename extension
.sparseimage
Internet media typeapplication/octet-stream
Uniform Type Identifier (UTI)com.apple.disk-image-sparse
UTI conformationcom.apple.disk-image
Developed byApple Inc.
Type of formatdisk image
Container forfile system objects

A sparse image is a type of disk image file that can be created under Mac OS X using Disk Utility. Encrypted sparse image files are used to secure a user's home directory by the FileVault feature in Mac OS X Snow Leopard and earlier.

Unlike a full image file (.dmg), which takes up as much actual space as the real disk it represents (regardless of the amount of unused space), a sparse image file (.sparseimage) takes up only as much actual disk space as the data contained within, up to a maximum of the capacity assigned during creating.[1]

Limitations

Two limitations are therefore worth noting regarding the use of this image file format:

  1. A customized ".sparseimage" image file can be assigned a larger total capacity than the physical volume (or HD partition) on which it originally resides. While the virtual volume will seem to make that capacity available, attempting to exceed the physical capacity of the underlying volume will result in a disk error: "ran out of space". The .sparseimage file must first be moved to a larger physical disk or partition.
  2. As noted above, while mounted .sparseimage image files automatically expand to their preassigned limit when data is added, they cannot be arbitrarily resized without the use of Disk Utility, hdiutil, or other such software.[2][3]

Resizing disk images

When the sparseimage file is not mounted, the .sparseimage file may be resized using Disk Utility’s Resize Image function. Sparseimages may also be resized from the Terminal. The following example resizes a .sparseimage so that it can expand to a maximum size of 50 gigabytes:

hdiutil resize -size 50g MyFile.sparseimage

Similarly, a .sparseimage file that has expanded in size but then had files deleted, can be "compacted" to a smaller size with the following command:

hdiutil compact MyFile.sparseimage

Additional information about the hdiutil command may be seen by typing the following in the Terminal:

man hdiutil

If it doesn't match, it means you have a disk image with a partition map.

  1. Unmount / eject disk
  2. Select the disk image (the .sparsebundle / .sparseimage) in Disk Utility
  3. Select the Partition tab
  4. Drag the corner to enlarge partiton to the desired size
  5. Apply

Sparse bundle disk images

Mac OS X v10.5 (Leopard) introduced the concept of the sparse bundle.[4] Instead of a monolithic file, a sparse bundle is a bundle (directory) containing a number of files called bands, each in the order of 8 MB in size. This means even though to the end user the sparse bundle appears as a single file, it is composed of smaller files. As of Mac OS X 10.8, the bands are 8.4 MB each. When the content of the image changes, one or more band files is changed, created, or deleted. This allows backup software (such as Time Machine) to operate more efficiently. You may use a tool such as rsync to keep your disk image(s) consistent across various systems.[5]

References

  1. ^ "Disk Utility 12.x: Disk image formats". Apple. Retrieved January 21, 2013.
  2. ^ "Disk Utility 12.x: Resize a disk image". Apple. Retrieved January 21, 2013.
  3. ^ "hdiutil(1) OS X Manual Page". Mac Developer Library. Apple. Retrieved January 21, 2013.
  4. ^ ScottW (November 5th, 2007). "Live FileVault and Sparse Bundle Backups in Leopard". http://macosx.com. Retrieved January 21, 2013. {{cite web}}: Check date values in: |date= (help); External link in |work= (help)
  5. ^ "Backing up Sparse Bundle Images Over SSH". LBackup. Retrieved January 21, 2013.