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.

9 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. 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

  7. 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!

  8. THANKYOU!

    Thankyou so much!

    Andre

  9. Gabe says:

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

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>