Monday, October 31, 2011

Corrupt sleepimage file causing 3 beeps on macbook pro boot up





I ran into an issue with my wife's MacBook Pro (Early 2011, 2.0 i7) where anytime it would go into safe sleep (i.e. the battery went completely dead while the computer was asleep, causing it to resume from the sleep image file when power was plugged in) when I would bring it out of safe sleep it would make it 50% through the resume process and then I would get 3 tones/beeps separated by about 5 seconds and then repeating the same sequence.  During that time the front LED would flash at the same pattern.


Because I had replaced the RAM (came with 4, wanted 8, but didn't want to pay the Apple price, so instead I bought from Crucial.com - they are amazing) I had suspected that maybe the RAM was bad or that it wasn't seated properly.  I proceeded to re-seat the RAM and run a RAM diagnostics test ("rember" from Kelley Computing, http://kelleycomputing.net/rember/), the test passed.  I called Apple to schedule a visit with my local Apple authorized technician, jett.net in Redding, CA).  The technician booted up the laptop using the special Apple network diagnostics and all of the hardware "checked out" as just fine.


I decided that instead of calling Apple back, I would try fixing this myself since it appeared to be a software issue not a hardware issue.  Because of the unique situation where the computer would start to resume just fine and then get the 3 tones, it seemed related to the safe sleep file (/private/var/vm/sleepimage).  I had read that any time you put your mac to sleep the sleepimage file will get created, if it doesn't exist already.  I decided to delete the file so that it would get re-created the next time the Mac was put to sleep.  Now, I needed the Mac to go into "safe sleep" which is challenging, because normally this would only happen if the battery was completely depleated.  I learned a new terminal command to force the computer to always go into safe sleep.


 "sudo pmset -a hibernatemode 1"


Where, setting hibernatemode to 1 tells your mac to always go into safe sleep.  By doing this I was able to force safe sleep to happen without waiting for the battery to be drained.  After putting it to sleep and making sure the LED in the front of the computer was NOT pulsing (i.e. the power is truly off) I turned the computer on and it started to resume from safe sleep and it was able to finish booting as it should, no beeping occurred and all was well.


So, in summary


1) when resuming from safe sleep, computer would beep three times every five seconds
2) I used "sudo rm /private/var/vm/sleepimage" to delete the sleepimage file
3) I used "sudo pmset -a hibernatemode 1" to force safe sleep when I close the lid and/or choose sleep from the apple menu
4) Booted from safe sleep and confirmed it was working as expected.
5) To go back to regular safe sleep mode (i.e. do not engage safe sleep unless the battery goes dead) using "sudo pmset -a hibernatemode 3"


Here is a link to the pmset commands that I used. 
http://www.macworld.com/article/53471/2006/10/sleepmode.html


Computer information:
MacBook Pro 15", Early 2011, i7 2.0Ghz, 8GB RAM
OS X 10.7.2 Lion


I hope this can help someone out there.