sleep related terminal commands
This is not a new thing... it's actually a feature, and it's been around since at least Snow Leopard. Before going to sleep, it makes a copy of current RAM on the hard drive, so if you run out of battery power during sleep, you can recover from the hard drive copy. I believe they call it Hybrid Sleep or Safe Sleep. There's a terminal command that can disable it and bring back quick sleeping. Windows doesn't have this feature, and sleeps right away.
If you just started having this problem now, perhaps you disabled it sometime in the past and the update re-enabled it?
I cannot give credit to those it is due to, as I picked these commands up from various threads on the forum; anyway thanks to those who contributed!
Open a Terminal shell (in the /Applications/Utilities folder)
pmset -g
This command will list all the current power settings/device settings.
Sleep settings
Files
All changes made through pmset are saved in a persistent preferences file (per-system, not per-user) at
/Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist
System Preferences Energy Saver modifies the same file
Scheduled power on/off events are stored separately in
/Library/Preferences/SystemConfiguration/com.apple.AutoWake.plist
Terminal commands: Copy and paste all the commands, starting with "sudo"
Enter your password when prompted, the password you type is not shown, just hit enter.
Display the current settings;
hibernatemode = 0 (binary 0000) by default on supported desktops. The system will not back memory up to persistent storage. The system must wake from the contents of memory; the system will lose context on power loss. This is, historically, plain old sleep.
hibernatemode = 3 (binary 0011) by default on supported portables. The system will store a copy of memory to persistent storage (the disk), and will power memory during sleep. The system will wake from memory, unless a power loss forces it to restore from disk image.
hibernatemode = 25 (binary 0001 1001) is only settable via pmset. The system will store a copy of memory to persistent storage (the disk), and will remove power to memory. The system will restore from disk image. If you want "hibernation" - slower sleeps, slower wakes, and better battery life, you should use this setting.
1. set hibernate mode to 0
sudo pmset -a hibernatemode 0
hibernationmode 0 is normal sleep, data kept in ram, nothing written to disk
2. delete the unnecessary sleep file (since hibernate is disabled) to regain disk space equal to memory (saves the same amount of disk space as your RAM, eg. 8 GBs, valuable on an SSD),
You can use the Go to folder menu to delete the file, found in the /var/vm/ folder, and named sleepimage. Reboot and simply delete that file,. Or use this:
sudo rm /var/vm/sleepimage or sudo rm /private/var/vm/sleepimage
The sleep image file is actually in /Private/var/vm/ but /var/vm/ is a symbolic link to that location.
Optional: Create a blanked zero-byte file so the OS cannot rewrite the file:
sudo touch /private/var/vm/sleepimage
Make file immutable:
sudo chflags uchg /private/var/vm/sleepimage
If pmset -g shows: autopoweroff**1,
disable this automatic hibernation mode (happens even if hibernation mode is set to 0 on the new Mac mini 2012 and iMac)
sudo pmset -a autopoweroff 0
4. set the safe sleep timer (standbydelay) to 20 hours, default is 4200 (1.67 hr)
sudo pmset -a standbydelay 72000
5. sudo pmset -a standby 0
While researching this, I noticed that bit 3 of hibernatemode encourages the dynamic pager to page out inactive pages prior to hibernation. So this appears to be why I have swap used after sleeping (even though my hibernatemode is 0, so bit 3 is off). I disabled this new, possibly buggy behaviour by switching off standby: sudo pmset -a standby 0
View the sleep image size:
ls -lh /private/var/vm/sleepimage