How I got Suspend and Hibernate working in Linux (Ubuntu 11.04, Mint 11)

Suspend and hibernate have always been screwed up with Linux. Luckily if you absolutely need this feature there is hope. I got mine working after scouring google. In this tutorial I will share with you what I learned, and how I solved the “linux insomniac” problem for my laptop.

First, here’s what I’m running.
Linux Mint 11 (a derivative of Ubuntu 11.04)
Kernel Version 2.6.39.3
Asus G53SW (Very similar to any ASUS G73/G Series)

If you are running something different than I am above, don’t panic this still have a good chance of working for you. Regardless of what you do I encourage you to test your suspend and hibernate after everything you try. I know, you’ll have to hold the power button down a lot for a cold reset, but it’s worth it.

My Symptoms Before I got it Working

When I sent my computer in Hibernate the computer would look like it was doing what I told it to up until the part where the screen and the CPU fan turn off. I just got a screen of black that would not respond. The hibernate was very similar except there was a white cursor frozen at the top left of the screen. The only option I had was to hold the power button until it turned off.

An Easy Fix for Suspend

I scoured the web looking for something that might help me. I ran into an article which gives instructions on installing a script that may fix the problem. There are dozens of people who have left comment in the article as to whether it worked for them or not and what system they were running. Most of them left comments said that the script worked perfectly well for them.

The Fix
1. Create a new script. The scripts in the sleep.d directory get executed when your computer suspends and hibernates. The “20″ has something to do with the script load order and the name currently _custom-echi_hcd can be changed to anything you like

sudo gedit /etc/pm/sleep.d/20_custom-ehci_hcd 


2. Enter the following script into gedit.

#!/bin/sh
#inspired by http://art.ubuntuforums.org/showpost.php?p=9744970&postcount=19
#...and http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug    
# tidied by tqzzaa :)
# Comments added by chriseiffel.com

VERSION=1.1.1
DEV_LIST=/tmp/usb-dev-list
DRIVERS_DIR=/sys/bus/pci/drivers
DRIVERS="ehci xhci" # ehci_hcd, xhci_hcd
HEX="[[:xdigit:]]"
MAX_BIND_ATTEMPTS=2
BIND_WAIT=0.1

#This function executes when the computer is going
#into sleep/hibernation. It looks for all devices
#in /sys/bus/pci/drivers with the ehci_hcd, etc
#and adds them to the unbind list
unbindDev() {
  echo -n > $DEV_LIST 2>/dev/null
  for driver in $DRIVERS; do
    DDIR=$DRIVERS_DIR/${driver}_hcd
    for dev in `ls $DDIR 2>/dev/null | egrep "^$HEX+:$HEX+:$HEX"`; do
      echo -n "$dev" > $DDIR/unbind
      echo "$driver $dev" >> $DEV_LIST
    done
  done
}

#Executed on a resume/thaw attempts to rebind the stored drivers
bindDev() {
  if [ -s $DEV_LIST ]; then
    while read driver dev; do
      DDIR=$DRIVERS_DIR/${driver}_hcd
      while [ $((MAX_BIND_ATTEMPTS)) -gt 0 ]; do
          echo -n "$dev" > $DDIR/bind
          if [ ! -L "$DDIR/$dev" ]; then
            sleep $BIND_WAIT
          else
            break
          fi
          MAX_BIND_ATTEMPTS=$((MAX_BIND_ATTEMPTS-1))
      done  
    done < $DEV_LIST
  fi
  rm $DEV_LIST 2>/dev/null
}

case "$1" in
  hibernate|suspend) unbindDev;;
  resume|thaw)       bindDev;;
esac

3. You’re done. You shouldn’t need to restart your computer. Try a suspend. Cross your fingers. Remember to check to make sure that your USB devices are still working after a resume/thaw.

Unfortunately for me and some others it didn’t work perfectly. In my case it was bitter sweet, my suspend worked, but my hibernate still didn’t work. However, it did change the way that suspend didn’t work. Now instead of a black screen, the computer just acted as if it was a normal restart. On power up instead of continuing the session it just restarted. If you have this same problem continue on getting article on getting hibernation. working.

The website and the script I originally found are located here.
http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug/

This entry was posted in ASUS G53SW Setup, Everything Penguin Related. Bookmark the permalink.

25 Responses to How I got Suspend and Hibernate working in Linux (Ubuntu 11.04, Mint 11)

  1. Pingback: Step By Step How to get Hibernate Working for Linux (Ubuntu 11.04, Mint 11) | C H R I S | | E I F F E L

  2. John says:

    Chris, great write up and the most informative by far but after days of work I still can’t get my suspend/hibernate to work.

    HP TouchSmart tm2 w/ ATI card using the proprietary driver running Linux Mint 11

    I have a 5GB swap with 4GB of ram that reports it’s working. When I hit either ‘Suspend’ or ‘Hibernate’ I get the following
    ~.5 seconds of screen saver
    Lots of text on a black screen that looks like it’s trying to suspend for about 1 second
    Then it drops me back to the welcome screen for Mint and asks me to log in. If I log in I get a dialog box saying
    “A program is still running, Power Manager is not responding Wait for program to finish…” I can either ‘Lock Screen’ ‘Cancel’ or ‘Log Out Anyway’. Regardless of the one I select a new session is loaded.

    This new session runs SLOW, which I believe implies my old session is still running in the background but I can’t find any evidence of this (such as high ram usage). Also, ‘Suspend’ and ‘Hibernate’ are no longer available under the “Quite” menu.

    The only thing I can do is shut the computer down and lose the session.

    I’ve posted this on the Mint forums but after a month I’ve not gotten a single reply. Any thoughts would be appreciated.

  3. Jean-Daniel Daigle says:

    Hi Chris, tks for your help. I have a G73 with linux mint 11.04 and it’s work for the suspend but just as you, the Hibernation failed. Do you have a solution since the last post?

    tks

  4. Stazzy says:

    Very clear thanks.

    I have a Asus eee pc 1215N and Mint 12.
    After this script the suspend works, the hibernate still not.
    Well, better than nothing…

  5. **** says:

    Thanks a lot! I’ve got a Thinkpad Edge with Linux Mint 12. Suspend to Disk and Ram works now. Resume works for both methods too!

  6. Ian Chapman says:

    I have mint 12 and I leave it on all night. Next morning my mouse wakes it up, I sign in and look up the weather and email. That was fine with mint11 and earlier Ubuntu stuff but with mint12 after sign on it took ages to start working. I’ve fiddled with the system settings, (Screen and Power icons) and now after sign on the screen goes funny or only the top and bottome bars (with the tabs) become funny. My Nvidia driver again no doubt. I usuallyl end up rebooting. Also to get to the sign on screen I NOW may have to hit the power on button, just a dab not holding it and it does not boot only wakes up. The system settings had a better icon for time out and overnight power saver in mint11. Any clues? We need to get the guys to fix this for mint13. Ian.

  7. tommykay says:

    Shazzam! It freaking works!

    Silly me, after owning this laptop for years, I still close the lid and leave. When I return it’s hot as hell. Your little script gave it a sleeping pill. EXCELLENT!

    Wouldn’t it be nice if the ubuntu developers would stop screwing with things that already work, like menus and scroll bars, and fix the broken things like sleep/hibernate?

    THANK YOU!

  8. Saint DanBert says:

    I did the following in addition to the script:

    1. unmounted any SD or other media cards in built-in media readers
    (another little script to remove all /media/* mounts)
    2. unloaded my video driver module
    3. unloaded my wifi driver module
    (You list them in a config file…)

    Never got hibernate working, but now sleep works.

    ~~~ 0;-Dan

  9. Marc says:

    I have got Linux Mint 13 and this script did indeed enable/fix hibernate for me. Thank you very much.

  10. khrysta says:

    i am running ubuntu 10.10 on a hp pavillion g series. and im really new to linux and i put the script in twice and both times it doesnt work. and now i cant get it to turn off. before as long as i had suspense turned off the computer worked fine it would just die quickly and now i cant let the computer go to sleep without it going into suspense. and i dont know how to remove. i really need help. and like i said im new.

  11. Anders says:

    Just reviving this for the next googler to stumble on this post: script seems to work fine on my Compaq 311c (euro version of Mini 311) with Linux Mint 13 Maya. The computer has nVidia NEO and an Atheros WiFi. Thanks!

  12. Anders says:

    Just reviving this for the next googler to stumble on this post: script seems to work fine on my Compaq 311c (euro version of Mini 311) with Linux Mint 13 Maya. The computer has nVidia ION and an Atheros WiFi. Thanks!

  13. THANKYOU!

    Thankyou so much!

    Andre

  14. Gabe says:

    You forgot to add that you need to chmod 755 the script, before it will run on suspend.

  15. Lucia - Elena RO┼×CULETE says:

    Thank you for this. I got it to work with this script and tuxonice.
    However, this method does not lock the current user screen in Linux Mint 13 with Mate. How do I configure it to do that?

    Kind regards,
    Lucia

  16. densel says:

    maybe I’m dense but I couldn’t get it to work at all…
    am I doing something wrong?
    tried
    $ pwd
    /etc/pm/sleep.d
    $sudo chmod +x 20_custom-ehci_hcd
    $./20_custom-ehci_hcd
    $sudo ./20_custom-ehci_hcd
    $sh 20_custom-ehci_hcd
    $sudo sh 20_custom-ehci_hcd

    none do anything at all.

    $tail /var/log/pm-suspend.log
    Running hook /usr/lib/pm-utils/sleep.d/00logging resume suspend:

    /usr/lib/pm-utils/sleep.d/00logging resume suspend: success.
    Running hook /usr/lib/pm-utils/sleep.d/000record-status resume suspend:

    /usr/lib/pm-utils/sleep.d/000record-status resume suspend: success.
    Running hook /usr/lib/pm-utils/sleep.d/000kernel-change resume suspend:

    /usr/lib/pm-utils/sleep.d/000kernel-change resume suspend: success.
    Mon Dec 17 20:35:29 CST 2012: Finished.

    that’s from a couple hours ago, at time of posting:
    $ date Mon Dec 17 23:40:50 CST 2012

  17. ego.abyssi says:

    Great script! I didn’t use it actually, but it proved useful nevertheless. Thanks!

    Instead of what you did, I simply hooked “rmmod ehci_hcd uhci_hcd” and “modprobe ehci_hcd uhci_hcd” to hibernate and resume, respectively. Seems to have done the trick with fewer lines.

  18. Hollis Prehn says:

    It is very fascinating to possess this technology because Asus used lots of new technologies on this specific Notebook. I’m convinced that most people will like this Notebook as it is amazing overall aspect. Since Asus released EEE PC 1005HA-BL many of us were waiting for this particular minute and now it is here, finally we can easily put our hands on new Asus EEE PC Notebook. The newest EEE PC 1005HA-BL Notebook coming from Asus carries on impress everybody featuring fantastic structure, increased overall performance along with incredible flexibility. ,

    My own blog site
    <'http://www.caramoantourpackage.com/

  19. Craig says:

    Thanks for the info…this did the trick and everything works perfectly now!

    ASUS zenbook UX13A – Linux Mint 13 Maya

  20. Jabba says:

    Thanks it worked finally! Another thing I did was update to kernel version 3.9 on ubuntu 13.04

    Cheers

  21. David Nelson says:

    This worked perfectly on an Acer Extensa 4420. Both suspend and hybernate are now working with Linux Mint 15 “olivia” Cinnamon 64-bit edition! Thank you! This is awesome!

    David

  22. ChuckC says:

    Chris – you are awesome! I’ve been all over the web searching for a solution to my Debian (solydX 2013-November updated system) problem. My laptop would not hibernate/restore. Your #3 item above was perfect clear and useful advice and it worked!

    THANKS so much for sharing!

  23. Lin says:

    Thanks for the infomation
    I have ASUS w53sw and the script works fine with RHEL WS 6.4 .

  24. Greg says:

    Wow, working for me too… nothing since ubuntu 9.04! ASUS P5L-1394 mobo, Geforce gt610 video card

    Unlike me, don’t forget to give execute permission or you’ll fail for sure…
    sudo chmod +x /etc/pm/sleep.d/20_custom-ehci_hcd

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>