Over a year ago, Apple changed the way that one of the most popular formats of disk image works on APFS. This article re-evaluates the more common general-purpose formats in the light of that change. Now that plain disk images can be highly efficient in their use of disk space, should you make more use of them?
There’s no shortage of different disk image formats. Among the most common are:
- plain disk image, known as a UDIF read/write image, abbreviated to UDRW;
- sparse image, the UDIF variant that has variable size, UDSP;
- sparse bundle, a bundle that has variable size, UDSB;
- CD/DVD master for export to optical media, UDTO;
- plain UDIF read-only disk image, UDRO;
- various compressed read/write formats.
If you want a fuller list,
man hdiutil is the closest that we have to definitive documentation, although as we’ve seen in the recent change in behaviour of UDRW images, that is far from complete or accurate.
The last three of those formats are normally used for specific purposes, for instance UDRO for distributing software. The first three are used for more general purposes as well, and it’s those that I’m concerned with here: how efficient are they in using storage space, how fast do they read and write, and how does the use of encryption affect them?
All tests were performed on an OWC Envoy Pro FX 4 TB external SSD connected to a Mac Studio M1 Max running Ventura 13.1 and APFS. Intel Macs may not perform as well, and older versions of macOS may differ.
To assess how efficiently each of the three formats UDRW, UDSP and UDSB use storage space, I created a 10 GB image in each of those formats and recorded the amount of disk space they took, as reported in the Finder’s Get Info dialog, as I made identical changes to them. The sequence consisted of:
- when first created, adding a 1 GB file, then unmounting;
- mounting, adding a second 1 GB file, unmounting;
- mounting, adding 16 test files totalling about 5.3 GB, unmounting;
- mounting, deleting the first two 1 GB files but leaving the others, unmounting;
- mounting, adding a 1 GB file, unmounting;
- mounting, deleting all the files except that 1 GB file, unmounting;
- mounting, deleting the remaining 1 GB file, and finally unmounting.
Each time they were unmounted, I recorded the space taken on disk according to Get Info. Those figures appear to have been updated correctly throughout, although in some other tests I have seen them report obviously false figures.
The best performer of the three formats was the sparse bundle (UDSB), which remained highly efficient at every step, and took the least space on storage from start to finish. When empty at the end, it fell in space to 0.04 GB without any need to compact the bundle manually.
Almost as good was the UDRW plain read/write format, which typically required just 200 MB more in storage space than UDSB, and returned to an empty space of 0.24 GB.
The sparse disk image performed worst, rising to a space requirement of 7.34 GB and not falling at all when files were deleted, even when it was completely empty at the end.
Write and read performance
I measured transfer speeds using my app Stibium on freshly created 100 GB UDSB and UDRW images, which I unmounted and remounted before testing. Images were stored on an OWC Envoy Pro FX 4 TB SSD, which normally attains native transfer speeds of around 3 GB/s, the maximum for Thunderbolt 3. Results were:
- Sparse bundles (UDSB) were faster, with a read speed of 2.7 GB/s and write of 2.2 GB/s, whether the bundle was unencrypted or encrypted using 128-bit AES.
- Plain read/read (UDRW) were significantly slower writing, with a read speed of 2.8 GB/s and write of 1.0 GB/s, again regardless of the use of encryption.
Although these disk images are still slower to write to than the native file system, they are much quicker than some disk image formats, and unaffected by the use of encryption.
Convenience in use
Plain read/write (UDRW) disk images have the convenience of being single files, but to retain the benefits of their new APFS sparse file format, they must be stored on APFS volumes, and care has to be taken to ensure that they don’t inadvertently explode to full size.
Sparse bundles (UDSB) can be used cross-platform, and are the mandatory format for storing Time Machine backups on networked storage such as NAS. Internally, though, they are complex in structure, and large sparse bundles can use tens or even hundreds of thousands of ‘band’ files for storage.
Long-term efficiency and performance may also differ, as free space inside UDRW files could become more fragmented, and the band files in sparse bundles age. In both cases, it could be wise to perform periodic maintenance by copying the contents to a fresh disk image, a major undertaking when they’re large.
- Unless otherwise limited to using a single file, prefer sparse bundles (UDSB) whenever you want to write to a disk image.
- Where a single file is required, for example in Virtual Machines, plain read/write (UDRW) disk images are almost as efficient, and write speeds are still reasonable for most purposes. Remember to unmount and remount them in the Finder after creation so they’re converted into sparse format.
- Encryption imposes no performance overhead, at least on Apple silicon Macs running Ventura.
- Don’t use sparse images (UDSP), as they’re far less efficient.