Reclaiming drive space by thinning Apple File System snapshot backups

As part of a recent clean-up of my Apple File System-formatted (APFS) boot drive, I deleted a number of files. However, I noticed that deleting files did not free up nearly as much space as I thought it should. When I investigated, I noticed that my boot drive had a number of Time Machine snapshots stored on it.

A quick way to reclaim space from a particular snapshot immediately would be to delete the snapshot using the tmutil command line tool, using the command shown below:

tmutil deletelocalsnapshots snapshot-name-here

However, I didn’t want to delete backups if I could avoid it since I might need something stored in one of them. After some research, I was able to find a tmutil command that did what I needed. For more details, please see below the jump:

The tmutil command line tool on macOS High Sierra includes a thinlocalsnapshots function, which has the options shown below:

tmutil thinlocalsnapshots mount_point [purge_amount] [urgency]

Purge amounts are represented as bytes, so specifying 20 gigabytes of space would be represented by the number below:

21474836480

Urgency levels are 1 through 4, with the default urgency setting being 1.

Urgency level 4

Most urgent: Any current backup processes are stopped and thinning is performed immediately. The largest available backup will be the first thinned, with thinning proceeding through the next largest backups.

Urgency level 1

Least urgent: Current backup processes will be completed before the thinning process begins. The oldest available backup will be thinned first, with thinning proceeding through the next oldest backups.

To free up 20 gigabytes of space from the snapshots stored on the boot drive at maximum urgency, you would use the command shown below:

tmutil thinlocalsnapshots / 21474836480 4

The command may take a while to run, depending on what would need to be done to free up the requested space.

Note: The thinning process may actually free up more than the requested space, but it should free up the requested space as a minimum if the stored snapshots are taking up at least that amount of drive space.

Like this:

Related

Thanks for the info. I imaged a customers iMac to my MacBook before working on it and stored the 340GB disk image on my MacBook. Got back to the office and copied the image to my backup server and deleted the file. Then I had an issue between Finder and the OS showing different free space numbers and only 8% free under diskutil. Took me a bit to track it down – but it was the local snapshots. I will probably be doing this again some time in the future and it’s frustrating that I cannot turn off local snapshots now – you use to be able to do this.

I’m confused. I’m not an Apple user, but if I think all that ‘thinlocalsnapshots’ command is doing is automatically choosing *which snapshots* to delete? So, your comment, “However, I didn’t want to delete backups if I could avoid it since I might need something stored in one of them. After some research, I was able to find a tmutil command that did what I needed,” doesn’t seem to make a lot of sense?

Aren’t you still deleting stuff? Either stuff is occupying your disk, or it isn’t. There’s generally not a way of getting free space without deleting something (except for compression, which this does not appear to be)?

So you have no idea what exactly gets “thinned” out of a local snapshot, as opposed to deleting the snapshot altogether? I highly doubt Apple support is going to be able to answer that question, but thanks anyway!!

Please forgive my pestering you today. Your blog is an incredible resource, so the last thingI want to do is be critical. The time and energy you have put in to this site, since 2003(!) is unbelievable, and hugely appreciated by all who come here, I’m sure.

I cannot find any direct Apple reference to the exact definition of what thinlocalsnapshots does – but – I can tell you what it usually means to ‘thin’ within backup programs generally.
If you have 5 backups and all of them contain the same file in each backup – when you thin out the backups it creates a new backup from the 5 that you have and makes sure that the new backup only contains each file once. It keeps the most recent version of the file and discards all the other copies of the same file found in each backup. The original 5 backups are deleted on completion.

This command saved my day. Apple’s blissful ignorance in admitting APFS related failures is getting to the point of insanity, thank heavens there are people like you saving us from going mad!
Absolutely appreciated. Thank you rtrouton!

APFS is a completely different monster when compared to other disk formats. It’s meant to “save the world”, while accomplishing to destroy people’s data… Try encrypting a whole drive and then decrypting it and you will see what I mean… My photos were all corrupted, along with my music. Thank God for the cloud! I was able to recover the files, but now I have two versions of each file. One with the partially corrupted file and another with the perfect file, downloaded from the cloud. And all duplicate check/delete apps I’ve tried cannot get rid of the corrupted files either, since essentially they are different from the non-corrupted files. I’d totally go back to HFS+ if I could. Unfortunately that’s not an option when running purely SSDs and Mojave…