How to disable OS X from creating "sleep image?"

Discussion in 'OS X Mavericks (10.9)' started by Yukon Jack, Dec 16, 2013.

  1. Yukon Jack macrumors member

    Joined:
    May 14, 2010
    #1
    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
     
  2. w0lf macrumors 65816

    w0lf

    Joined:
    Feb 16, 2013
    Location:
    USA
    #2
    Pretty sure this is it.
    Code:
    sudo pmset -a hibernatemode 0
     
  3. RV-ABZ macrumors 6502

    Joined:
    Apr 11, 2013
    #3
    Then remove any sleep image with:
    Code:
    sudo rm -f /var/vm/sleepimage
     
  4. jbarley macrumors 68030

    jbarley

    Joined:
    Jul 1, 2006
    Location:
    Vancouver Island
    #4
    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.
     
  5. RV-ABZ macrumors 6502

    Joined:
    Apr 11, 2013
    #5
    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.
     
  6. jbarley macrumors 68030

    jbarley

    Joined:
    Jul 1, 2006
    Location:
    Vancouver Island
    #6
  7. myxomatosis, Dec 18, 2013
    Last edited: Dec 18, 2013

    myxomatosis macrumors member

    myxomatosis

    Joined:
    Nov 28, 2012
    Location:
    Montréal
    #7
    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):

    [​IMG]
     
  8. hallux macrumors 68020

    hallux

    Joined:
    Apr 25, 2012
    #8
    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.
     
  9. jbarley macrumors 68030

    jbarley

    Joined:
    Jul 1, 2006
    Location:
    Vancouver Island
    #9
    Yes it does, I should have mentioned that fact in my first post #4.
     
  10. Upgrader macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
    #10
    I’m on Yosemite. If I follow these steps in Terminal, does this mean that my computer will never go to sleep?

    Thanks.
     
  11. hallux macrumors 68020

    hallux

    Joined:
    Apr 25, 2012
    #11
    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).
     
  12. Upgrader macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
    #12
    Thanks. So should these added commands replace any of the above list of commands from myxomatosis?
     
  13. hallux macrumors 68020

    hallux

    Joined:
    Apr 25, 2012
    #13
    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.
     
  14. Upgrader macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
    #14
    Good to know. I’ve used the other set of commands and it’s working so I’ll leave it there for now. Cheers.
     
  15. khoan macrumors newbie

    Joined:
    Jan 12, 2015
    #15
    has anyone tried setting hibernate file to void? please report and share result.

    sudo pmset -a hibernatefile /dev/null​
     
  16. Upgrader macrumors regular

    Upgrader

    Joined:
    Nov 23, 2014
    #16
    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.
     

Share This Page