A sparse image is a type of disk image file used on macOS that grows in size as the user adds data to the image, taking up only as much disk space as stored in it. 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. Sparse images can be created using Disk Utility.

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

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 creation.

Limitations

edit

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.[citation needed]
  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.[1][2]

Sparse bundle disk images

edit

Mac OS X Leopard introduced the concept of the sparse bundle.[3] Instead of a single big file, a sparse bundle is a bundle (directory) containing a number of files called bands, each on 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 MiB (8 × 10242 byte) each. When the content of the image changes, one or more band files is changed, created, or deleted. This allows easier shrinking of the amount of space used on the underlying filesystem when a large amount of data is deleted inside the disk image, as long as the code supporting the filesystem inside the image notifies the kernel of the "releasing" of blocks, as happens in filesystems that support SSD "trim" operations to be triggered automatically for de-allocated filesystem blocks.

Sparse bundle advantages over non-diskimage backup for Time Machine:

  • the backup destination no longer needs to be an HFS+/HFSX volume (for the hard links to work and to preserve metadata), but can be any shared folder, on any server, connected using any protocol and using any file system to store the actual files
  • the entire sparse bundle is replicable from one location to another; this is particularly useful when upgrading the backup storage and when the on-site backup storage needs to be replicated to an off-site backup storage. A tool such as rsync may be used to keep one or more disk images consistent across various systems.[4]

References

edit
  1. ^ "Create a disk image using Disk Utility on Mac". Apple. Retrieved August 13, 2020.
  2. ^ "hdiutil(1) OS X Manual Page". Mac Developer Library. Apple. Retrieved January 21, 2013.
  3. ^ ScottW (November 5, 2007). "Live FileVault and Sparse Bundle Backups in Leopard". macosx.com. Archived from the original on October 29, 2013. Retrieved January 21, 2013.
  4. ^ "Backing up Sparse Bundle Images Over SSH". LBackup. Retrieved January 21, 2013.
edit