Skip to content

Instantly share code, notes, and snippets.

@bdkjones
Created November 12, 2012 00:00
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdkjones/4056796 to your computer and use it in GitHub Desktop.
Save bdkjones/4056796 to your computer and use it in GitHub Desktop.
Disabling Safe Sleep After November, 2012
In early November, 2012, Apple issued a graphics update for all mid-2012 MacBooks. In a continued streak of stupidity, however, this update forces your Mac to use "Safe Sleep". This means that the entire contents of your RAM is written to your disk every time you put your Mac to sleep.
This is retarded on the scale of the Titanic's navigational plan for two reasons:
1) Your Mac likely has 8 or 16GB of RAM. This is a ton of wasted disk space; especially on MacBook Airs that ship with only 256GB SSDs to begin with.
2) SSDs wear out as you write to them. Each cell of a SSD can only be written to a certain number of times before it becomes read-only. If you put your computer to sleep many times a day, OS X is slowly but surely destroying your SSD with unneeded write cycles.
Worst of all, the graphics update makes it IMPOSSIBLE to turn off safe sleep using the standard approach you'll find on Google:
$ sudo pmset -a hibernatemode 0
$ sudo nvram "use-nvramrc?"=false
The "safesleep" file will still regenerate in /var/vm after running those commands at the terminal. But fear not: we can bash OS X in the face with a spiked bat and FORCE it to stop being an idiot. To do this, run the following commands:
$ cd /var/vm
$ sudo rm sleepimage
$ sudo ln -s /null/nullvalue sleepimage
This will remove the "safesleep" file (which frees up disk space equal to the amount of RAM in your Mac). The third line creates a symbolic link to a path that does not exist. This way, when OS X attempts to write a new "sleepimage" file, it will fail.
My thanks to MacRumors user "PaulMoscow" for the above tip! And if you're the Apple engineer who added this "feature" to the graphics update: please find the nearest fire and jump in.
@shanegriffiths
Copy link

This is perfect timing thanks for this. I have a late 2011 MBP but recently upgraded to 16GB of RAM. With only a 128GB SSD I soon realised about this mysterious "sleepfile" taking all my hard disk space.

If I run the command this will delete the image. Are there any side effects I should know about?

I don't usually put my machine into sleep mode but is there any other drawbacks I should know about doing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment