By Casey Liss
Apple Pwn3d my Free Space

It all started when I was ripping a BluRay:

Only 60GB free‽

I have a 1 TB iMac. I should not be running this low on space.

Things were, alarmingly, confirmed in the terminal:

casey@iMac ~> df -h
Filesystem     Size   Used  Avail Capacity
/dev/disk1s1  932Gi  866Gi   65Gi    94%  

Only 65GB free‽ This is a problem.

Whenever I need to diagnose what’s going on with free space, I turn to DaisyDisk. It is my preferred way to drill into where space is being consumed.

Unfortunately, outside of some very large iPhone backups, nothing was out of the ordinary. Until I noticed this:

300GB of 'unreadable'‽

Something is amiss.

Having learned from my HFS+ days, I thought I should try to do First Aid using Disk Utility. I even went so far as rebooting in recovery mode and performing First Aid there. (Old HFS+ habits die hard.)

However, even after a recovery, Disk Utility had no good news for me:

Disk Utility makes me sad

In speaking with the oracle about this, he led me in the right direction: the issue is APFS and its snapshots.

In short, snapshots allow for the entire filesystem’s state to be marked. This could allow a user to easily and quickly throw away subsequent changes and roll back to a prior state. This is particularly useful if an OS update is attempted but fails; you can quickly go back in time to the way things were before the update was attempted.

The way to determine what snapshots are around is to use tmutil. This tool covers more than just snapshots, but with the listlocalsnapshots option, can show us what snapshots are around:

casey@iMac ~> tmutil listlocalsnapshots /
com.apple.TimeMachine.2018-02-17-105420
com.apple.TimeMachine.2018-02-17-115852
com.apple.TimeMachine.2018-02-17-131024
com.apple.TimeMachine.2018-02-17-141820
com.apple.TimeMachine.2018-02-17-152954
com.apple.TimeMachine.2018-02-17-170922
com.apple.TimeMachine.2018-02-17-182143
com.apple.TimeMachine.2018-02-17-201534
com.apple.TimeMachine.2018-02-17-214625
com.apple.TimeMachine.2018-02-17-231950
com.apple.TimeMachine.2018-02-18-015522
com.apple.TimeMachine.2018-02-18-060124
com.apple.TimeMachine.2018-02-18-070848
com.apple.TimeMachine.2018-02-18-093121

That’s… a lot.

Curiously though, Finder showed me some good news:

Finder shows 300GB free‽

What. The. What.

I decided to take a step back and do a little research about the problem online. Eventually that led me to this Apple support document (emphasis is mine):

Snapshots older than 24 hours are automatically deleted. And to make sure that you have storage space when you need it, snapshots are stored only on disks that have plenty of free space. When storage space gets low, additional snapshots are deleted, starting with the oldest. That’s why Finder and Get Info windows don’t include local snapshots in their calculations of the storage space available on a disk. That’s why Finder and Get Info windows don’t include local snapshots in their calculations of the storage space available on a disk.

Aha!

Lesson learned: Do not trust anything but Finder to tell you how much free space you have on an APFS formatted drive.

Given the dates on those snapshots above, I expect they will be cleaned up in the next couple days, and everyone will agree that I have a ton of space remaining.

UPDATED 2018-02-18 8:30 PM: Other than snapshots, there is another kind of free-but-not-really-free space in Sierra and beyond: purgeable space. This is space that has things that may, for example, also exist in iCloud. Should Apple decide your local device needs the room taken up by these local copies, it will automatically (hopefully) delete them. Jason Snell has a great writeup at Six Colors that covers all this.