How to Fix Suspend Problem on Ubuntu 12.04

Hello Linux Geeksters.

If you can’t suspend your Ubuntu 12.04 Precise Pangolin operating system, i may have a fix for you.

Do this for fixing the suspend problem on Ubuntu 12.04:

Create the /etc/pm/sleep.d/20_custom-ehci_hcd file:

$ sudo touch /etc/pm/sleep.d/20_custom-ehci_hcd

Open the newly created file:

$ gksudo gedit /etc/pm/sleep.d/20_custom-ehci_hcd

Paste this script:

#!/bin/sh
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
#for bus in $EHCI_BUSES; do
echo -n $bus > /sys/bus/pci/drivers/ehci_hcd/unbind
# done
done
}
bindDev() {
if [ -s $DEV_LIST ]; then
while read driver dev; do
DDIR=$DRIVERS_DIR/${driver}_hcd
#for bus in $EHCI_BUSES; do
echo -n $bus > /sys/bus/pci/drivers/ehci_hcd/bind
#done
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
chvt 1
chvt 7
}
EHCI_BUSES="0000:00:1a.0 0000:00:1d.0"
case "$1" in
hibernate|suspend)
unbindDev;;
resume|thaw)
bindDev;;
esac

Set 755 permissions on the script:

$ sudo chmod 755 /etc/pm/sleep.d/20_custom-ehci_hcd

Tagged with: , , , , ,
Posted in The Linux and Unix Articles!
One comment on “How to Fix Suspend Problem on Ubuntu 12.04
  1. Inderjit Singh Bedi says:

    I started facing this issue after I plugged a bluetooth mouse, now my Ubuntu 12.04 is not getting suspended and once if try to suspend it ir returns to the login screes but after that the bluetooth won’t turn on.

    Let me know if this script will resolve my issue?

Leave a Reply

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

*

Subscribe

  

Subscribe to get the latest Linux news and how to guides directly on your e-mail!