MacOS – APFS/High Sierra – `tmutil deletelocalsnapshots` not deleting snapshots

apfsmacostime-machine

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)

Best Answer

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