Can’t Remove Purgeable Disk Space
When trying to install Bootcamp on my MacBook Pro, I had to delete a lot of files to get enough space to be able to accommodate for a Bootcamp partition on the drive. But even after removing around 60 GB of storage, MacOS Sierra could still not make a large enough partition for Windows. When checking with Disk Utility, it showed that indeed I had enough space, but there was a part called Purgeable that was impossible to move. No tools from Apple are available to handle this, but here’s how I fixed it.
Optimize Disk Storage
Apple added a feature called “Optimize Disk Storage” in MacOS Sierra. The idea is quite good. This feature isn’t well-implemented, though. If you have it enabled in System Preferences under iCloud/iCloud Drive settings (which I think is on by default), you essentially have two different values of how much disk space you have available. One “real,” that shows exactly how much there is, and then you have the Purgeable part, that includes software that can be uninstalled on the fly and later restored if enough space is available.
My problem was that MacOS Sierra refused to remove the Purgeable part of the partition, so when I tried to install Bootcamp, It only showed the “real” free disk space. The issue is, I manually deleted stuff like iMovie and GarageBand with the associated files by hand using OmniDiskSweeper, which is a free and excellent application for finding and removing large unused files on your disk. But for some reason, MacOS Sierra refused to recognize that I had the free disk space. After searching the net, I couldn’t find a good solution. But after a quick hack, I’ve created an easy way of forcing MacOS to remove the “Purgeable” disk space.
How to remove Purgeable Disk Space
First, I created a 20 GB file using the Terminal application. It’s easy enough thanks to MacOS Unix underpinnings. Open the Terminal app, found in the Utility folder in Applications. Don’t let the sparse interface scare you; this thing has superpowers!
Enter the following:
dd if=/dev/zero of=~/stupidfile.crap bs=20m
The command creates a file named stupidfile.crap using a device available on Unix/Linux, called /dev/zero which sends zeros which we use to create a large file.
You could do a periodic “Get Info” in the Finder to check on how large the file is. Another is to install Brew and use it to install the great tool watch by entering the command
brew install watch
If you do, open a new Terminal window and enter:
watch ls -alh ~/stupidfile.crap
Now we can see how large the file is. When the data is about 10-20GB in size, press ctrl-c in the first window to stop creating a file. You can now quit the Terminal application.
Large file, let’s fill the disk!
So now we have a large file. No need to use the /dev/random function to make a larger file, because it’s faster to duplicate the stupidfile.crap we just created. So go to your home directory, select the file stupidfile.crap and press cmd-d to duplicate the file. Just keep making several duplicates at the same time to speed things up. Now we will make a lot of copies of the file in your home directory. What we are aiming for, is to fill the disk, so the OS starts purging (hence, eating into the “Purgeable” part.)
Sooner or later you’re going to hit the magic wall, and you’ll get messages that the disk is full. Wait a while and see if it has removed parts of the Purgeable section using /Applications/Utilities/Disk Utility. If the system allocates more free space, keep duplicating our dummy file to fill up the disk. Sooner or later, you will have a full disk with either a very small or nonexistent “Purgeable” section on it.
Time To Turn Off “Optimize Mac Storage”
Now you can turn off that pesky Optimize Mac Storage function. So go to System Preferences/iCloud, press the iCloud Drive Options button to get to the setting. Deselect “Optimize Mac Storage.”
Now you can remove all the dummy files we created to fill up the disk, and Voilà!, we now have access to all the empty disk space without that stupid Purgeable part there.
So now I could make a more substantial partition for Windows. Why a larger partition for Windows? Games of course!