Fix Ubuntu (or Linux) Suspend/Hibernate Not Working Bug

I own an Asus N73JQ laptop, the spec is top notch. Since Windows has been long gone from my candidate OS, I installed Ubuntu 10.10 right away. So far the result is quite amazing. Smooth, reliable, and it feels just right. Although the OS itself is very impressive, I have 2 major issues with the hardware: (1) Function key that switches to external monitor does not work; (an update on the external monitor issue can be found here) (2) Suspend/Hibernate does not work. I have not found a solution for (1), which remains unsolved. I have, however, found a solution for (2). I am going to share this share this solution with those who having the same problem.

By googling around, I found this post. It seems that it will also work for other laptops that have similiar problem in Ubuntu 10.10. The credit belongs to the original poster and all others who contributed to that solution. Though I have thoroughly tested the script and it works for me, I do not guarantee it will work for you. So use it at your risk.

Step 1

Create a script under /etc/pm/sleep.d/. It can be any name, but to ensure the load order, use the prefix 20_.

Follow either Step 2 or Step 2 Old, but not both. The script in Step 2 appears to be more stable than the one in Step 2 Old.

Step 2

Note that if you use the code from "Step 2 Old" below, please skip this step. This script is contributed by commenter Danne.

Insert the following code into the file you have just created:

Step 2 Old

Note that if you use the code from "Step 2" above, please skip this step.

Insert the following code into the file you have just created:

Step 3

Add executable permission:

Result

Your suspend/hibernate should be now working as expected. Suggestions on improving this script are welcome.

Other Thoughts

If this script has worked for you, please post the make/model, Ubuntu distribution, related hardware information of your laptop below.

Updated 2012/03/02

Making sure you have enough space for your swap partition, otherwise hibernate will not work. I have recently upgraded my RAM. In my case, I have 12GB of RAM, but only 6GB of swap space. After the upgrade, hibernation stop working. However, after following this guide (see "Making the swap partition work for hibernate" section), hibernation becomes functional again.

I create a 30GB swap partition, and instruct Ubuntu to use this partition. Hibernation works like a charm again. To verify your system is using the swap, do

Or

Update 2011/11/10

If this has been working for you, but stop working after upgrading to Ubuntu 11.10, you may try this method:
http://turbulentsky.com/resume-from-hibernate-failed-on-ubuntu.html

Other Tips:
This might give you some clues on the suspend/hibernate issue:

Related Posts

Switch to External Monitor Connected via HDMI/VGA port in Ubuntu
Ubuntu 11.10 Look Overhaul

652 Comments Fix Ubuntu (or Linux) Suspend/Hibernate Not Working Bug

  1. Sven

    Does not work for my 11" lenovo thinkpad edge amd.

    Does enter sleep but will not wake up, does not enter hibernate completely, fan stays on, then does not wake up, blinking cursor on black screen.

  2. nathan

    You know, it's not so much that hibernate/suspend don't work in *nix, it's that I don't know if they work. Maybe I don't understand the electrical theory, but I'm always concerned that my processor is running some null or zombie call up into 90 degrees centrigrade without a fan and that my disks heads are in 'neutral' while I happily walk around with it in a bag thinking "It's in suspend". Maybe it's different with these low-power nettop CPUs and SSDs or I'm living in the 1980s (cue Killing Joke single), but still.

    Hibernate obviously works, but swap is so slow I could save, leave a plaintext note, write out a post-it with instructions and power down and be pretty much in the same boat as if I shut down. Oh, yeah, it makes my uptime look awesome... it's a laptop, it's portable, I don't expect my uptime to ever get into the weeks let alone nerd nirvana like two-years.

  3. blau

    nathan, you could get an SSD drive for quick hibernate and restore. I would not recommend carrying around a suspended laptop anyway.

    The script works on my second laptop as well, a rebranded Airis/Progress Intel Core i5 with an nvidia geforce gt 335 m

  4. Cuong

    The point of hibernation is to gain the ability to quickly resume the working state you were in previously. Let's say you have a word processor, a browser window, and a few other applications opened, and you want to turn the laptop off and on because you need to move to another location, hibernation is idle for this situation.

    I have SSD, cold boot/cold shut down takes about the same time as hibernation.

  5. Janne

    I have a HP 6730b and the computer froze on hibernation mode. I patched BIOS to the latest version and made âthe changes âaccording to instructions shown on this page. The computer resume faster and seems to work. Thank you very much

  6. Daniel

    Working for both suspend and hibernate on a DELL E6400 with Ubuntu 11.04!

    Superb!

    Daniel

  7. orzech

    On MSI U270 on Ubuntu 11.04 instead of suspend I get hibernate operation. Better this than nothing...

  8. Christoph

    Great work, this helped to put a Asus X53E-SX107V with Ubuntu Natty 11.04 to sleep. Before that i only got a black screen and the notebook crashed.

  9. Janne

    At first I was happy and thought this was a happy solution. Unfortunately, after a few days I saw that it did not work. Noticed this after the computer had been on for about 4 - 5 hours, then the computer froze again.

    I have a Hp 6730B

  10. Pingback: Impresii despre Ubuntu 11.04 | Ovidiu's Box

  11. cryogenicT

    Solution for black screen:
    This most likely related to the video card.
    When you hibernate, don't use the GUI. It uses pm-hibernate without any options. Instead, in a terminal, log in as ROOT and issue:

    pm-hibernate --store-quirks-as-lkw

    In the manual of pm-hibernate, this option is described as follows:

    Save the quirks the video adaptor required by pm-suspend or pm-suspend-hybrid as an .quirkdb file that is specific to this system. The file will be saved in /var/cache/pm-utils/last_known_working.quirkdb. This parameter will only save the actual quirks that were used to successfully suspend/resume a system, and will be specific to the exact configuration of that system, including the video hardware, video driver, and whether or not kernel modesetting was used. If the system configuration changes, like after a kernel upgrade, this file will be overwritten.

    So technically is saves the successful configuration. Note, when your machine wakes up, it won't show you a log in screen, simply because you hibernated as root.

  12. Dim

    I've tried for a week to find a solution to suspend - hibernate on a new Toshiba Satellite U500, running Arch x86_64 (kernel 2.6.38.6-2).
    It's hard to believe that this fix has solved my problems!!
    It works fine for both suspend & hibernate.
    Thanks.

  13. Ryan

    Ah, got my hopes up that I would finally be able to put the lappy to sleep but alas it doesn't work. Same problem as before, it suspends but when it comes back again the screen isn't on. booerns.

    Running an Acer Aspire with an AMD E350 APU on 64bit 10.10.

  14. drex

    May thanks for the tips, that worked on a desktop computer with an Asus P5QL-Pro motherboard (without usb3 and bios up to date). Arch Linux 64bit too.

  15. Okan

    I do not have any hope left to suspend my laptop.
    Actually it suspends (well i think) but cannot wakeup.
    Blank screen, nothing appears, and strangly the fan starts in 2-3 seconds. Have to force shutdown by pressing the power button.
    This laptop comes with Microsoft Vista. It suspends and wakes in vista well. But no luck for ANY Linux OS's.
    Thanks to you. But that didn't work for me either. :(
    Have a nice day.
    Packard Bell BU45-O-020
    Ubuntu 11.04, 2.6.38-8-generic kernel.

  16. Mark

    This script didn't work for me but reading one of the comments here I tried updating my BIOS as it is about 5 years old and this solved the suspend problem.

  17. Penguin Geek

    Dell Inspiron 1521, running Arch Linux. Suspend worked perfectly. Hibernate, not so much. It just boots as normal.

  18. Jefferson

    Great! Simply great.
    Both sleep and hibernate working perfectly on an Asus N53S running Ubuntu 11.04.

  19. frapi25

    suspend works.
    hibernate doesn't work.

    Asus N53SN Ubuntu 11.04 64-Bit 2.6.38-8-generic
    using bumblebee (Optimus support for Linux)

  20. Samuel

    It's perfect for me, i'm looking for this since few month.
    ASUS30JC
    Ubuntu 11.04 64 bits Unity

  21. Heffernan

    Unfortunately, no luck on a Packard Bell Easynote MV35-002 with Ubuntu 10.10.
    Suspend works, but on wakeup the screen stays black and nothing works. Forced reboot required.
    On Hibernate the system doesn't even turn off.
    Screen just goes blank, but can be reactivated by moving the mouse.

  22. Danne

    Works quite on ASUS U31JG. Sometimes (guessing 1 in 20) resuming fails with a black but switched-on screen. I do not know why yet, but did some modifications to the suspend/resume script to retry binding if it fails for some reason (not powered on yet?). I think it works better now.

    #!/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 :)

    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

    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
    }

    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
    done
    done /dev/null
    }

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

  23. Danne

    Works quite on ASUS U31JG. Sometimes (guessing 1 in 20) resuming fails with a black but switched-on screen. I do not know why yet, but did some modifications to the suspend/resume script to retry binding if it fails for some reason (not powered on yet?). I think it works better now.

    Modified script: http://pastebin.com/ayvLzgh8

  24. Alec

    Hi !

    Original script works perfect on an ASUS X52J (K52JR) with UBUNTU 11.04

    Thanks a lot

  25. blackmoon

    @Danne
    With your script usb devices no longer works after resume.

    @Danne,
    @Coung
    With both script after resume the wifi led is off even if the wifi card is tourned on.

    Someone else con canfirm this?

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 class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">