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.
Table of Contents
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_.
0 1 2 3 4 |
gksudo gedit /etc/pm/sleep.d/20_custom-ehci_hcd #or the way you would normally do when creating a file as superuser |
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:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
#!/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 :) VERSION=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 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 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 |
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:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#!/bin/sh TMPLIST_E=/tmp/ehci-dev-list TMPLIST_X=/tmp/xhci-dev-list E_DIR=/sys/bus/pci/drivers/ehci_hcd X_DIR=/sys/bus/pci/drivers/xhci_hcd E_BIND=$E_DIR""/bind E_UNBIND=$E_DIR""/unbind X_BIND=$X_DIR""/bind X_UNBIND=$X_DIR""/unbind #param1 = temp file, param2 = device dir, param3 = unbind unbindDev (){ #inspired by http://art.ubuntuforums.org/showpost.php?p=9744970&postcount=19 echo -n '' > $1 for i in `ls $2 | egrep '[0-9a-z]+\:[0-9a-z]+\:.*$'`; do echo -n "$i" | tee $3 echo "$i" >> $1 done } #param1 = tem file, param2 = bind bindDev(){ [ -f $1 ] || return for i in `cat $1`; do echo -n "$i" | tee $2 done rm $1 } case "${1}" in hibernate|suspend) unbindDev $TMPLIST_E $E_DIR $E_UNBIND unbindDev $TMPLIST_X $X_DIR $X_UNBIND ;; resume|thaw) bindDev $TMPLIST_E $E_BIND bindDev $TMPLIST_X $X_BIND ;; esac |
Step 3
Add executable permission:
0 1 2 |
sudo chmod 755 /etc/pm/sleep.d/20_custom-ehci_hcd |
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
0 1 2 |
free -m |
Or
0 1 2 |
top |
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:
0 1 2 |
gedit /var/log/pm-suspend.log |
Related Posts
Switch to External Monitor Connected via HDMI/VGA port in UbuntuUbuntu 11.10 Look Overhaul
Pingback: Suspend/hibernate doesn’t work on an Asus laptop | Some Ubuntu Questions and Answers
Thinkpad T420, Ubuntu 14.04.
Suspend worked fine until I added a USB3 card. It uses xhci_hcd driver. Used the script but changed the driver to xhci_hcd, and it suspends again.
Thank you for sharing superb information. Your web-site is so cool. I’m impressed by the details that you have on this web site. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for more articles.
Ok, I think I can do this. No…wait…I KNOW I can do this. Just a few days ago I went thrift shopping and came out with three dress shirts for work and 1 pair of pants. It can be done. Agree on the undergarments stuff. I’m in!
Its excellent as your other content : D, appreciate it for putting up. “As experience widens, one begins to see how much upon a level all human things are.” by Joseph Farrell.
Mein Gott, sind die goldig!!!!!! Noch 3 Tage...ich glaube, dann gibts bei WoJ nen absoluten Einkaufsboom*g.Ihr werdet Euch vor Bestellungen nicht retten können!LGHeide
Lenovo Yoga 12 woks to
Thanks
....oh sorry g
With Ubuntu 16.04
Compaq Presario F500
Ubuntu 14.04.
So happy this works :)
I installed instead of 16.04 because of this issue and a video driver issue.
Laptop now works with this script for sleep/hibernate and Gnome shell for Graphics issues :)
Unity doesn't load.
It's a shame you don't have a donate button! I'd certainly
donate to this superb blog! I guess for now i'll settle for
bookmarking and adding your RSS feed to
my Google account. I look forward to new updates and will talk about this site with my Facebook
group. Talk soon!
Great, thanks for sharing this article.
Dell XPS 1640/ ubuntu 16.14
The suspend was working perfectly before,two day ago I have notice spinning fan while lid cover is closed.
Thanks a lo, it was very clear TUT even for a newbie like me.
Is there a way to make this all into a .sh file? Would simply making an executable file and running it using the info in Step 2 work or does it have to be in that location?
Linux Mint 18 Cinnamon