Thursday, May 27, 2010

Making my macbook hibernate

This is just a quick guide on how to make your macbook or macbook pro hibernate. Now me personally i dont like to waste my battery life, especially when i'm traveling to different places. Ok enough babbling from me lets get to it. For those that dont know here are the different states of the macbook/macbook pro.

* On – Computer is awake, screen is on, battery is being consumed based on your power settings
* Off – Computer is using no power from the battery
* Sleep – Computer has turned off the screen and has suspended the operating system to RAM (volatile memory).
* Hibernation – Computer has turned off most hardware and has suspended the operating system to the harddrive


When you closed the lib on your macbook/macbook pro it will go to sleep and wake up quickly. However while your laptop is sleeping it is still consuming the battery life.

When the battery reaches a certain low level, the Macbook/macbook pro will automatically switch to hibernation mode and basically shut off so you don’t lose any of your work. Sleep is great for when you’re actively using your computer, but when you want to stretch out battery life for as long as possible, you want to hibernate. Also to note is that it appears that the newer Macbook Pros also write information to the harddrive when sleeping so that when the battery drops to dangerous levels it can jump instantly into hibernation. Apple calls this “Safe Sleep”.


In Terminal/iTerm/etc run the following command to determine your current sleep mode:
pmset -g | grep hibernate

This should return one of the following:

* 0 – Legacy sleep mode. It will save everything to RAM upon sleeping but does not support “Safe Sleep”. Very fast sleep.
* 1 – Legacy “Safe Sleep”. This is the “Safe Sleep”. Everything your laptop goes into sleep, it will save everything to harddisk. Slow on Sleep and Startup.
* 3 – Default. As described above, when sleeping, contents are saved to RAM. When battery runs out, hibernate occurs.
* 5 – Behaves as 1 but applicable only for modern Mac that uses “Secure virtual memory”.
* 7 – Behaves as 3 but applicable only for modern Mac that uses “Secure virtual memory”.

Now edit and save your /Users/username/.bash_profile in most cases, However im a ksh kind of geek so i save my alias in my /Users/unixboy/.kshrc file with the following lines:

alias hibernateon="sudo pmset -a hibernatemode 5"
alias hibernateoff="sudo pmset -a hibernatemode 0"

hibernateon and hibernateoff can be any text you want, you just need to remember what you used


Now you have a handy little command that will let you enable and disable instant hibernation on a whim. Whenever you want your machine to hibernate when you close the lid, just drop to a terminal window and type “hibernateon”. When you’d prefer your laptop to just sleep, type “hibernateoff”.

1 comment:

  1. 0 down vote


    This is a great article. You should also check out low battery saver if you want to have even more control over when your computer sleeps. It's an app that makes sure your Mac sleeps before the battery completely runs out and let's you set a warning to alert you that the computer is about to sleep (lowbatterysaver.com/appstore.html) It won't fix your battery problems but at least you won't lose your work, have to restart your computer etc.

    ReplyDelete

Cracking Kerberos Service Tickets (TGS) Using Kerberoasting

As of late I've been spending a lot of time researching and learning different techniques when it comes to attacking Active Directory En...