Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Yukon Jack

macrumors member
Original poster
May 14, 2010
85
2
I have been led to understand that sleep images are pretty important on MacBooks due to power considerations. however, I have a Mac Mini and when I occasionally use WhatSize to perform garbage collection, I always find a sleep image in /private/var/vm that eats up storage.

I also understand that this image is supposed to be trashed when the Mac wakes up but in my case, it isn't. Is there a way to either fix the OS so that the sleep image is trashed on awake or to permanently disable its creation?

Thanks.

late 2012 Mac Min running OS X 10.9
 
Then remove any sleep image with:
Code:
sudo rm -f /var/vm/sleepimage

And unless things have improved, Mavericks will re-create it on the next startup.

A tip I found some time ago that works like a charm goes thusly...
----------------------------------------
Set sleep mode in shell:

sudo pmset -a hibernatemode 0

Remove the image:
sudo rm /private/var/vm/sleepimage

Create a blanked file:
sudo touch /private/var/vm/sleepimage

Make file immutable:
sudo chflags uchg /private/var/vm/sleepimage
-----------------------------------------
The above commands do the necessary housekeeping to remove any existing sleepImage file, and then create a zero-byte locked SleepImage file, one which the operating system will leave untouched.
 
Sorry, but I've never seen any new sleepimage file after setting hibernatemode to 0 (which means plain old sleep to RAM, without any backup to disk).

That is valid across all recent OS X versions I've encountered since Leopard.
 
Right way to disable the "Sleep" image forever:


View the sleep image size
Type in the Terminal: ls -lh /private/var/vm/sleepimage

Disable sleep mode:
Type in the Terminal: sudo pmset -a hibernatemode 0

Remove the image:
Type in the Terminal: sudo rm /private/var/vm/sleepimage

Create a 0-byte file:
Type in the Terminal: sudo touch /private/var/vm/sleepimage

Make the file not writable:
Type in the Terminal: sudo chflags uchg /private/var/vm/sleepimage


Run these commands one by one and reboot. After reboot, re-run the first command to see the sleep image size. It should look like this (0B):

na29.png
 
Last edited:
I had to do the process of creating the locked 0-size sleepimage file under ML and Mavericks, on the same machine. I even had to RE-do it after the in-place upgrade to Mavericks, the upgrade reversed that change.
 
I had to do the process of creating the locked 0-size sleepimage file under ML and Mavericks, on the same machine. I even had to RE-do it after the in-place upgrade to Mavericks, the upgrade reversed that change.

Yes it does, I should have mentioned that fact in my first post #4.
 
I’m on Yosemite. If I follow these steps in Terminal, does this mean that my computer will never go to sleep?

Thanks.
 
Your computer will sleep but it won't go into "safesleep" mode. There's actually another switch I found to disable SafeSleep without messing with the SleepImage file.

In Terminal type the following command

Code:
pmset -g

If you see an entry called "autopoweroff", it should be set to 0 to disable that feature. To set it to 0, type the following

Code:
 sudo pmset autopoweroff 0

Here's a description of the pmset command. Tread lightly...


***The Autopoweroff entry MAY have been introduced in Yosemite, I don't have a Mavericks Mac handy (it's at work).
 
Your computer will sleep but it won't go into "safesleep" mode. There's actually another switch I found to disable SafeSleep without messing with the SleepImage file.

In Terminal type the following command

Code:
pmset -g

If you see an entry called "autopoweroff", it should be set to 0 to disable that feature. To set it to 0, type the following

Code:
 sudo pmset autopoweroff 0

Here's a description of the pmset command. Tread lightly...


***The Autopoweroff entry MAY have been introduced in Yosemite, I don't have a Mavericks Mac handy (it's at work).

Thanks. So should these added commands replace any of the above list of commands from myxomatosis?
 
Thanks. So should these added commands replace any of the above list of commands from myxomatosis?

IF Mavericks has the "autopoweroff" entry, the one to set autopoweroff to 0 should replace the entire process. Again, do this at your own risk. I have set this entry to 0 on my MBP running Yosemite (may have set it in Mavericks when I installed my SSD) and it does not go into Safesleep mode overnight.
 
IF Mavericks has the "autopoweroff" entry, the one to set autopoweroff to 0 should replace the entire process. Again, do this at your own risk. I have set this entry to 0 on my MBP running Yosemite (may have set it in Mavericks when I installed my SSD) and it does not go into Safesleep mode overnight.

Good to know. I’ve used the other set of commands and it’s working so I’ll leave it there for now. Cheers.
 
has anyone tried setting hibernate file to void? please report and share result.

sudo pmset -a hibernatefile /dev/null​
 
Just as an additional solution, I'm running Trim Enabler with my OWC PCIe SSD. The paid version has the option to disable the sleep image. It works consistently and I rely on this now. TE is pretty cheap to purchase.
 
hey i don't mean to bump a 3 year old thread esp in 10.9 forum.

And unless things have improved, Mavericks will re-create it on the next startup.

A tip I found some time ago that works like a charm goes thusly...
----------------------------------------
Set sleep mode in shell:

sudo pmset -a hibernatemode 0

Remove the image:
sudo rm /private/var/vm/sleepimage

Create a blanked file:
sudo touch /private/var/vm/sleepimage

Make file immutable:
sudo chflags uchg /private/var/vm/sleepimage
-----------------------------------------
The above commands do the necessary housekeeping to remove any existing sleepImage file, and then create a zero-byte locked SleepImage file, one which the operating system will leave untouched.

for the record, this worked great on 10.11.6 on an old 2007 MacBook 2,1 (survived a reboot so far)

just wanted to say thanks @jbarley
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.