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.

7 comments:

  1. I had the exact same issue after upgrading to 8 gigs of aftermarket RAM on my early 2011 13" MPB. Thanks for the fix!

    ReplyDelete
    Replies
    1. I'm really glad it worked out for you. I actually ended up having continued problems even after this fix, it turns out it had something to do with VMWare fusion, whenever it was being used and the machine lost battery power the sleep image file would become corrupt. I learned that after a full power off/power on that the sleep image file would be re-written the next time there was a hibernate event, so recreating the sleepimage file became less necessary. Now, though, unfortunately I just avoid letting the battery die if I have my VMWare Fusion VM up and running (Windows 7 64bit, visual studio 2010, sql server developer, etc, lots of ram in use). Anyhow, I hope your story ends well also :)

      Delete
  2. Were you on OSX Lion?

    I tried this but after

    sudo pmset -a hibernatemode 1

    I got this message:
    Warning: Idle sleep timings for "Battery Power" may not behave as expected.
    - Disk sleep should be non-zero whenever system sleep is non-zero.

    And it wouldn't safesleep

    ReplyDelete
    Replies
    1. Hi Matt, sorry for the delay - work has been crazy. Yes, I was running Lion 10.7.2 when I posted this. Did you try going to http://www.macworld.com/article/53471/2006/10/sleepmode.html ? This is where I gathered my info. I hope you got it figured out.

      Regards,
      Bryan

      Delete
  3. You just made my day.
    I was having the same issue when i upgraded my Mac from Lion to Mountain Lion.
    I though my RAM were the issue since I upgraded from 4GB to 8GB as well.

    Thank you for your post :)

    ReplyDelete
  4. Hi Bryan!

    I have the same problem and it is still not working. I left my MBP late 2011 with AC plugged (so the battery never dies) and hibernate mode = 3 and, I don't know why, the computer goes to sleep mode. When I open the lid, it beeps. I noticed that it happens when I lock my computer and put into sleep mode. I disabled the disk sleep and it didn't solve either.
    What is strange is that hibernate mode = 1 will make the computer wake up from sleepimage file while hibernate mode = 3 will retrieve from memory. Only with power loss it would recover from sleep image.

    I will try hibernate mode = 1. Let's see if it works.

    Thanks for the post!
    Cheers,
    Sérgio

    ReplyDelete
  5. Hi Bryan,

    I faced same problem, but your advice didn't help me. I found that my 3 beeps during booting were solved by switching on a swap file. Seems when system goes to sleep it writes something to the swap file and during boot it tries to restore this. This caused 3 beeps in my case. Now I switched on a swap file and I'm no longer observing this problem.

    Thanks!
    Alexander

    ReplyDelete