APFS/High Sierra - `tmutil deletelocalsnapshots` not deleting snapshots

Listing local snapshots yields this

> tmutil listlocalsnapshots /
com.apple.TimeMachine.2018-01-30-194719
com.apple.TimeMachine.2018-01-30-211627
com.apple.TimeMachine.2018-01-30-224917
com.apple.TimeMachine.2018-01-30-234619
com.apple.TimeMachine.2018-01-31-014151
com.apple.TimeMachine.2018-01-31-024107
com.apple.TimeMachine.2018-01-31-034442
com.apple.TimeMachine.2018-01-31-044108
com.apple.TimeMachine.2018-01-31-054441
com.apple.TimeMachine.2018-01-31-064120

and i try to delete a local snapshot but running this

> sudo tmutil deletelocalsnapshots 2018-01-30-194719
Deleted local snapshot '2018-01-30-194719'

but listing the local snapshots again showed that the snapshot has not been removed

> tmutil listlocalsnapshots /
com.apple.TimeMachine.2018-01-30-194719
com.apple.TimeMachine.2018-01-30-211627
com.apple.TimeMachine.2018-01-30-224917
com.apple.TimeMachine.2018-01-30-234619
com.apple.TimeMachine.2018-01-31-014151
com.apple.TimeMachine.2018-01-31-024107
com.apple.TimeMachine.2018-01-31-034442
com.apple.TimeMachine.2018-01-31-044108
com.apple.TimeMachine.2018-01-31-054441
com.apple.TimeMachine.2018-01-31-064120

Just for fun i wrote a little bash script to delete them all (which also avoids any typos).

for date in $(tmutil listlocalsnapshots / | perl -pe 's/com.*(2018.*)/\1/'); do echo "deleting $date"; sudo tmutil deletelocalsnapshots "$date";  done

Strangely enough, i can repetitively run that command above and it will always show the same output:

deleting 2018-01-30-194719
Deleted local snapshot '2018-01-30-194719'
deleting 2018-01-30-211627
Deleted local snapshot '2018-01-30-211627'
deleting 2018-01-30-224917
Deleted local snapshot '2018-01-30-224917'
deleting 2018-01-30-234619
Deleted local snapshot '2018-01-30-234619'
deleting 2018-01-31-014151
Deleted local snapshot '2018-01-31-014151'
deleting 2018-01-31-024107
Deleted local snapshot '2018-01-31-024107'
deleting 2018-01-31-034442
Deleted local snapshot '2018-01-31-034442'
deleting 2018-01-31-044108
Deleted local snapshot '2018-01-31-044108'
deleting 2018-01-31-054441
Deleted local snapshot '2018-01-31-054441'
deleting 2018-01-31-064120
Deleted local snapshot '2018-01-31-064120'

Why are my snapshots not deleting? I am quite low on storage space (13gb of space - the snapshots would not even clear when i had 2gb of free space left)


Solution 1:

I think the least-recent time machine snapshots was corrupted - potentially from some system crashes caused by APFS bugs.

I tried running DIsk Utility's first aid, but that froze my computer for over 3 hours (maybe it ran out of space to work with?) - I ended up having to force-restart.

I solved the problem by running first aid booted from an external hard drive install of High Sierra. It removed some old snapshots. I then was able to boot from my normal drive and run tmutil deletelocalsnapshots... which successfully deleted the snapshots and freed up space

Solution 2:

Great solution detecting that the filesystem was corrupt when the normal commands were note working. Also note, you can avoid iterating on the list of snapshots and just direct the system to reclaim space up to and surpassing the limit you choose:

tmutil thinlocalsnapshots / $(echo "5 * 1000000000" | bc) 2

The above command asks for 5 GB of cleaning. I chose the echo math to make it easy to dial up and down without the long string of zeroes getting changed. Feel free to simplify the above command with a number you like that’s larger than your drive if you intend the system clean all possible snapshots.

How to thin your local Time Machine Snapshots on macOS High Sierra