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
Those are APFS local snapshots that use copy on write, so they take no space overhead to a first approximation.
I wouldn’t even bother removing them unless you have measurable file extent fragmentation since you can roll back changes like software updates with these as well as the system cleans them automatically if you run into storage pressure and the external drive connects to get a second backup after a few days time.
If you want to force one backup and then force deletion of all the snapshots here are the commands. I would be sure the first one completes without error, though.
tmutil startbackup --block
tmutil listlocalsnapshotdates / | grep -v dates | xargs -I date tmutil deletelocalsnapshots date
Note: the tmutil startbackup
reports success on the command line (exit 0) no matter what, so be sure you see actual data copies and not zero values and a pop up error in notifications if you are logged in to the Mac console.
Best Answer
I also had problems with running out of disk space due to Time Machine/APFS local snapshots and the macOS disk purging system not working quickly enough -- I didn't find a way of disabling local snapshots, but I did find the following commands can help, if making management a little more manual.
If you want to delete all local snapshots, the following command will work -- but it's possible the next Time Machine update will take longer as it will have to work out the differences between the last Time Machine backup and the current state of the drive.
If you just want to delete some local snapshots, you can try the following command, the numbers I've used are completely arbitrary, I was just trying to force it to free up some space:
The first value is the purge amount (1 GB in this case) you'd like
tmutil
to try and reclaim, the second value is the urgency, which can be from 1 to 4. I've no idea which is more urgent, 1 or 4, it doesn't seem to be documented. If you use this command repeatedly it will delete more snapshots each time, until they're all deleted.