Aren’t snapshots purgeable?

Long before APFS, Mac OS X introduced the concept of purgeable space in storage, that currently occupied by files that could, when necessary, be deleted and used as free space. The bulk of this used to be caches and other files that were a convenience not a necessity. When APFS introduced snapshots that are used in Time Machine and other backups, they too were added to purgeable space, and Time Machine automatically purges its own snapshots when they’re more than 24 hours old.

Since High Sierra and APFS snapshots, accounting for purgeable space has been inconsistent and often misleading. I first reported this over eight years ago in Sierra 10.12.6 and High Sierra 10.13.3, and most recently three years ago in Ventura 13.3.1. This article looks at how this is handled now in Tahoe 26.6.2.

Purgeable space

Conventionally, accessible storage Capacity is allocated to one of three categories

  • Available and not currently in use to store data,
  • Used to store data that macOS wants to retain,
  • Purgeable, as it’s currently used to store data that macOS can purge when it needs more free storage.

Then for any given storage device
Capacity = Available + (Used – Purgeable)

There is disappointingly little documentation on space management in macOS, and the closest Apple comes to defining purgeable space is in Disk Utility’s Help pages, where it’s stated to be “space that macOS can free up when needed by removing files from your computer (you can’t manually remove the files that are designated purgeable, but macOS removes them as space is required)”.

On the face of it, that includes cache files but not snapshots, as they can be manually removed in Disk Utility, as I’ve discussed in detail here. This is contradicted when using tmutil localsnapshot to make Time Machine snapshots, which reports that “local snapshots are considered purgeable and may be removed at any time by deleted(8)”, as deleted is the purgeable space and cache management service in macOS.

APFS snapshots can also be created by third-party apps that have the appropriate restricted entitlement. Apple doesn’t explain whether those too can be purged by macOS when additional free space is required.

Demonstration

To demonstrate the purgeability of snapshots, it’s best to perform tests on an external disk formatted in APFS, containing no other data. For this I used the same procedure as previously to assess this in Ventura.

In outline, what this does is create a Time Machine snapshot of a volume containing files so large they almost fill the container, leaving little free space. The files are then deleted, leaving just the snapshot, and its purgeability tested by trying to copy another large file into that volume. That should force the snapshot to be purged to accommodate the new file.

Although you can do this using a single partition including the whole of the disk, it’s simplest to repartition the disk with a relatively small APFS container, such as 100 GB, using Disk Utility.

Add a second volume to your test container, also in plain APFS format. In this case, I have named those two volumes TestVolume1 and TestVolume2. Then write large files to TestVolume1 to almost fill the container. This time I copied across several large IPSW files totalling just over 94 GB. Inspect these using Disk Utility.

The container has a Capacity of 100 GB, with 94.92 GB Used and 5.08 GB Free, which is correct.

TestVolume1 has a Capacity of 100 GB, 5.08 GB Available, 94.8 GB Used, and 549 KB Purgeable, which also appears correct.

TestVolume2 has a Capacity of 100 GB, 5.08 GB Available with 860 KB used, 549 KB purgeable, and Other Volumes have 94.92 GB Used. Everything appears in order.

The next and more complicated step is to turn the current Used space on TestVolume1 into Purgeable space. This requires making a snapshot of at least TestVolume1, then deleting the files making up the 94.8 GB of Used space. One way to do that is to:

  1. Unmount any current Time Machine backup storage, to ensure test files aren’t backed up to it.
  2. Open Time Machine settings and remove TestVolume1 and TestVolume2 from the list of excluded volumes, enabling Time Machine backups of those two volumes.
  3. Open Terminal and enter the command tmutil localsnapshot, which will then make snapshots of all volumes being backed up, including both TestVolume1 and TestVolume2. Note that snapshots made by third-party tools may not behave the same as those of Time Machine, and may not be included in Purgeable space.
  4. Using Disk Utility, confirm that a snapshot has been made of TestVolume1.
  5. Drag the large files in TestVolume1 to the Trash and empty it, leaving both volumes empty.
  6. Restore Time Machine settings by adding the two volumes back to the exclusion list before remounting Time Machine backup storage.

When you now inspect the two volumes in Disk Utility, their status should have changed.

TestVolume1 may now be shown with a Capacity of 100 GB, still only 5.08 GB Available, 94.8 GB Used, and only 549 KB Purgeable. That implies that no files have been deleted yet. It’s not clear why this was shown on some occasions during testing.

At other times, the same volume may be shown with its original capacity, in this case slightly larger at 101.19 GB, all 100.06 GB Available, of which 94.8 GB is Purgeable, but still with 94.8 GB Used. This is more appropriate in representing the purgeable status of the 94.8 GB, although it may appear puzzling.

TestVolume2 now has a Capacity of 100 GB, 5.08 GB Available, Other Volumes have 94.92 GB Used, and only 549 KB Purgeable, which is also correct, as the large purgeable space is in a different volume.

Look in the Finder’s Get Info dialogs for those two volumes, and the figures given make no mention of purgeable space, even when it’s substantial and declared in Disk Utility.

Now try copying a large test file, in this another IPSW file of 12.89 GB, to TestVolume2.

The Finder then reports there isn’t sufficient disk space, and refers the user to the Storage section in System Settings.

Information given in Storage is of no help, and fails to disclose the fact that all the space shown as Used in TestVolume1 is in fact purgeable.

If the user does guess what the cause of this problem is, and tries copying the large file to TestVolume1 rather than TestVolume2, macOS should normally purge the snapshot, and both volumes will have sufficient free space to accommodate that file. That behaviour wasn’t consistent, though: on at least two occasions during testing, macOS apparently failed to recognise the purgeability of the huge snapshot on TestVolume1 and refused to purge it when expected to do so.

Following purging and successful copying of the large file, TestVolume1 has a Capacity of 100 GB, 86.98 GB Available, 12.89 GB Used, and only 573 KB Purgeable.

TestVolume2 now has a Capacity of 100 GB, 86.98 GB Available, Other Volumes have 13.02 GB Used, and its own remaining snapshot of 573 KB is Purgeable.

Conclusions

  • macOS space management remains confusing, and shallow and contradictory documentation only increases confusion.
  • Time Machine snapshots are purgeable, although they may not always be purged reliably. The cause of that unreliability is unknown.
  • The only GUI tool in macOS that may report space consistently is Disk Utility, although even that doesn’t always get it right. The Finder and Storage give figures that are incorrect, by omitting purgeable space.
  • In the three years since I last reported on this, these problems have only got worse.