Running out of disk space is never fun, and drive space comes at a premium for those of us with smaller SSD drives like the MacBook Air with a 64GB or 128GB drive. These tricks are fairly advanced and thus aimed at the pro segment of SSD users who are comfortable modifying system functions and files through the command line with potentially risky commands like ‘rm -rf’ and wildcards – if that does not describe your skill set, then this article is not for you and you should use these easy tips instead.
Also, some of these tricks disable certain system functions and may have side effects that would be considered undesirable to the average user, so be sure to understand that before using them on a given Mac. If in doubt about a specific trick or command syntax, it’s safer to avoid it completely and rely on more traditional methods offered here of reclaiming disk space when things get tight on a Mac.
WAIT! Advanced users only! Seriously. If you’re a newcomer to OS X this is not for you. One minor typo could result in file loss and damage to core OS files due to the destructive nature of the ‘sudo rm’ command. Do not use copy and paste, and be sure you have the precise path set before executing the command. You have been warned, so proceed at your own risk.
1: Disable SafeSleep Hibernation Mode
Space freed: 4GB – 16GB
This turns off OS X’s native hibernation function, known as SafeSleep. Essentially, hibernation dumps the contents of RAM to a sleepimage file on the hard disk when a Mac is put to sleep or runs out of battery. That hibernation file is the same size as your total RAM, meaning a Mac with 4GB of RAM will have a 4GB hibernation file, 8GB RAM will be an 8GB file, etc. Turning this feature off will that file from being created, thereby freeing up system RAM. The downside to this is that if a Mac runs out of battery life, you will not be able to resume instantly where things left off – in other words, keep Auto-Save enabled and save your documents when you’re nearing the end of battery life.
Open Terminal and enter the following command:
sudo pmset -a hibernatemode 0
Next go to /private/var/vm/ to delete the existing sleep image file:
cd /private/var/vm/
Remove the sleep image file with the following string:
sudo rm sleepimage
Still in /private/var/vm/ we must now prevent OS X from creating the file, so we’ll make a dummy and prevent write access to it:
touch sleepimage
Finally let’s prevent access:
chmod 000 /private/var/vm/sleepimage
This will prevent sleepimage from being created and hibernation mode from working at all. This can lead to data loss if your battery runs out and you have not saved a file recently, so be sure to keep on top of your important documents once battery life gets low.
This can be undone by deleting the new sleepimage file again, then restoring hibernatemode to “3″:
sudo pmset -a hibernatemode 3; sudo rm /private/var/vm/sleepimage
This is an advanced trick and should be treated accordingly.
2: Remove Speech Voices
Space freed: 500MB – 3GB+
Don’t use text-to-speech and don’t care about all the fancy voices included with OS X? You can reclaim a significant amount of disk space by trashing them, the total space saved depends on how many voices have been installed.
Back at a Terminal window, enter the following command:
cd /System/Library/Speech/
Now to delete the entire Voices directory:
sudo rm -rf Voices/*
Do note that text to speech will no longer function at all if you do this. It’s also possible to delete all voices using the above method, then manually add a single one if you’d prefer to retain some voice capabilities in Mac OS X.
3: Delete All System Logs in OS X
Freed space: 100MB-2GB
Log files build up over time, though ultimately how much disk space they take up depends on a variety of things like your individual computer usage, errors, what services are running, and many other things. You’ll lose the contents of apps like Console by doing this, but if you’re not interested in reading OS X log files for debugging and troubleshooting purposes this isn’t much of a loss:
sudo rm -rf /private/var/log/*
Log files will continue to generate over time, so you may want to repeat this on occasion. You could technically prevent their creation by using the same chmod approach used to block sleepimage files, but that is not recommended.
4: Delete QuickLook Caches
Freed space: 100MB-300MB
Quick Look is that fancy file preview ability in OS X that is summoned by selecting any file in the Finder or an Open/Save dialog and hitting the spacebar. Unsurprisingly, QuickLook relies on caching to behave quickly, and those cache files can add up. Here’s how to trash them:
sudo rm -rf /private/var/folders/
5: Remove Emacs
Freed space: 60MB+
Don’t use emacs? Don’t even know what it is? You probably don’t need it then (It’s a command line text editor, for those unfamiliar). You’re not going to save GB’s with this one, but every MB helps on a small SSD:
sudo rm -rf /usr/share/emacs/
No more emacs, but don’t worry CLI users, you will still have vi and nano.
6: Delete tmp Files
Space freed: 500MB-5GB
/private/var/tmp/ is a system cache, and though it should clear itself after a reboot, it doesn’t always happen. Plus, if you have a 40 day uptime and don’t reboot often it won’t clear itself either, thus you can do it yourself. This can have unintended consequences, so this is best done freshly after a reboot, or when you quit all open applications and have no apps open or running. You’ll want to aim at the temporary files themselves that start with “TM” and not the entire directory, thus the command would be:
cd /private/var/tmp/; rm -rf TM*
Again, this can have unintended consequences, so do not do this while apps are running.
7: Trash the Cache
Space freed: 1GB-10GB+
Caches can be everything from web browsing history, to temporary app metadata, to apps very own scratch disks. Ultimately how large these user caches get depend on what apps are run, how often the Mac is rebooted, and general user activity, thus the size of these files can have a wide range. It’s not just power user apps that can grow large though, many streaming radio apps can create huge cache files that sit around for an eternity. Just like deleting tmp files, this is best done after a reboot or after quitting all open apps and thus have nothing running at the moment, or else unintended consequences could occur, resulting in strange behavior for open apps.
cd ~/Library/Caches/; rm -rf ~/Library/Caches/*
A safer approach to this is available here, which uses the Finder to delete user caches manually, thus removing the risks of using rm -rf with a wildcard.
Thanks to Fernando Almeida for providing five of these tricks! Got some awesome tips you want to share with us and the world? Hit us up on Twitter, Facebook, Google+, or email – comments are temporarily disabled