It sounds like you are making a bootable image. In that case, you'll want to use one of these:
If those satisfy your needs, you can stop reading. If not, read on!
If you are simply storing a lot of Mac files and you want to do it using a Mac-native filesystem, you should use a sparse bundle. The man page for hdiutil
helps explain this:
As of Mac OS X 10.5, a more reliable, efficient, and scalable sparse
format, UDSB (SPARSEBUNDLE), is recommended for persistent sparse
images as long as a backing bundle (directory) is acceptable.
Take note of that "backing bundle" statement -- it means that the file system on which your sparse bundle is stored must support directories with a large number of files (those are the bands of the sparse bundle). Remember, you have external hard drive disk itself to format before you place the sparse bundle image onto that disk.
The man page also gives the (huge) max size for a sparse bundle:
..the maximum [size] for SPARSEBUNDLE is just under 8 exabytes (2^63 - 512
bytes)
You can format the disk itself however you'd like, as long as the format supports the large number of files sparse bundles make in a single directory. Format your sparse bundle as HFS+
and then convert it to APFS
in the future. The reason for this is there are still a few bugs in APFS
, specifically regarding sparse bundles, cf. this well-explained bug report and video:
I noticed that an APFS-formatted sparsebundle disk image volume showed
ample free space, despite that the underlying disk was completely
full.
(2019 update: macOS Mojave resolved the free space issue above. Using an APFS
sparse bundle on Mojave and newer can be safely recommended).
You can use Disk Utility to create your sparse bundle. If you are doing a lot of deleting from the sparse bundle, periodically run this command to remove unused bands and reclaim the space:
hdiutil compact /path/name.sparsebundle
Note that hdiutil compact
only removes completely unused bands. So, deleting 10GB of data from your sparsebundle may only result in, say, 6GB of bands deleted when you compact
. Reducing band size generally will make compact
operations free up more space.