Apple - How to thin your local Time Machine Snapshots on macOS High Sierra
Spoiler: I went from ~50 GBs free to ~277 GBs free, about 227 GBs difference, over the course of this answer.
There's not a tonne of information from the basic tmutil
function but you can call man tmutil
to get more details, specifically on thinlocalsnapshots
:
thinlocalsnapshots mount_point [purge_amount] [urgency]
Thin local Time Machine snapshots for the specified volume.
When purge_amount and urgency are specified, tmutil will attempt (with urgency level 1-4) to reclaim purge_amount in bytes by thinning snapshots.
If urgency is not specified, the default urgency will be used.
A noticeable omission is what the default urgency
actually is and whether 1 is high urgency or 4 is high urgency.
To show you what's happening in real-world usage, here is my starting list of local snapshots:
$ tmutil listlocalsnapshots /
com.apple.TimeMachine.2017-12-14-173102
com.apple.TimeMachine.2017-12-14-212356
com.apple.TimeMachine.2017-12-15-052254
com.apple.TimeMachine.2017-12-15-084940
com.apple.TimeMachine.2017-12-15-094508
com.apple.TimeMachine.2017-12-15-121635
When running without the purge_amount
and urgency
options, it's likely that no local snapshots will be purged:
$ tmutil thinlocalsnapshots /
Thinned local snapshots:
With purge_amount
set to 1000000000
(1 Gigabyte):
$ tmutil thinlocalsnapshots / 1000000000
Thinned local snapshots:
2017-12-14-173102
And if I run that again:
$ tmutil thinlocalsnapshots / 1000000000
Thinned local snapshots:
2017-12-14-212356
Here's what's happened to my local snapshots list:
$ tmutil listlocalsnapshots /
com.apple.TimeMachine.2017-12-15-052254
com.apple.TimeMachine.2017-12-15-084940
com.apple.TimeMachine.2017-12-15-094508
com.apple.TimeMachine.2017-12-15-121635
Let's try running that same command one more time:
$ tmutil thinlocalsnapshots / 1000000000
Thinned local snapshots:
2017-12-15-052254
2017-12-15-084940
$ tmutil listlocalsnapshots /
com.apple.TimeMachine.2017-12-15-094508
com.apple.TimeMachine.2017-12-15-121635
And again:
$ tmutil thinlocalsnapshots / 1000000000
Thinned local snapshots:
2017-12-15-094508
$ tmutil listlocalsnapshots /
com.apple.TimeMachine.2017-12-15-121635
And once more to try and remove that final local snapshot:
$ tmutil thinlocalsnapshots / 1000000000
Thinned local snapshots:
$ tmutil listlocalsnapshots /
com.apple.TimeMachine.2017-12-15-121635
You can see it didn't do anything this time.
Let's try increasing the bytes to 10 GBs:
$ tmutil thinlocalsnapshots / 10000000000
Thinned local snapshots:
Still nothing. Let's try 100 GBs:
$ tmutil thinlocalsnapshots / 100000000000
Thinned local snapshots:
Again, nothing.
So, when it gets to the last local snapshot, it must have to do with the urgency
option rather than the purge_amount
.
Let's go back to just 1 GB for the purge_amount
but try with urgency
set to 1
(another omission in the manual is whether 1
is high or 4
or high, but @Clete2 thinks 4
is high):
$ tmutil thinlocalsnapshots / 1000000000 1
Thinned local snapshots:
2017-12-15-121635
$ tmutil listlocalsnapshots /
com.apple.TimeMachine.2017-12-15-121635 (dataless)
Success!
You can see that it thinned the last remaining local snapshot and now when you listlocalsnapshots
you'll see only the latest one but it is tagged as (dataless)
.
I'm willing to bet that urgency
being set to 1 means "very urgent" and urgency
set to 4 means "meh, whenever".
Over the course of these trials my hard drive has gone from ~50 GBs free to ~277 GBs free. A freeing up of about 227 GBs!
I would assume that these local snapshots would get thinned automatically, especially when additional space is required so you shouldn't have to worry about this too much.
But, I ran into this because
I was wondering how I was losing all my free disk space so suddenly, and;
I was trying to make a Boot Camp partition to run Windows and I didn't have enough space, even tho most of that space was just being taken up by local snapshots.
Going forward, I'm wondering if I should have a cron job run a thinning command every week or so, just to keep things clean. I'll see what happens after a few more days and add anything back here that I find.
Here is the Apple site for more information about how Time Machine's Local Snapshots are used:
https://support.apple.com/en-ca/HT204015
Local snapshots are for using time machine when not connected to your time machine drive. They only last for 24 hours. So you should not have to clear them out. At least this is what Apple claims. Free space doesn't seem to be consistently reported within the OS. In some places it shows the snapshots as taking up real space, other places it is shown as purgeable. The applications think it is taking up real space and it can cause problems.