Wednesday, January 11, 2012

[Solved] Ubuntu Hibernate not working

For some laptop models, ubuntu installations show up by not hibernate in expected way. I have dug up in google about this issue and found some solutions.

this post.was the most relevant one thanks to the author,

make a script under /etc/pm/sleep.d/. 

sudo gedit /etc/pm/sleep.d/20_custom-ehci_hcd
paste the following code into the file you have just created:

#!/bin/sh
#inspired by http://art.ubuntuforums.org/showpost.php?p=9744970&postcount=19
#...and www.ubutnusolved.blogspot.com    


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
save the file and exit back to terminal.
Give execution permission:
sudo chmod 755 /etc/pm/sleep.d/20_custom-ehci_hcd
Now your system must work well with hibernate option.


4 comments:

  1. I have vaio FZ340 problim is still 'NotSolved'

    ReplyDelete
    Replies
    1. I am working on it. Sounds like problem is wid your hardware. Use the link given below to report this issue to ubuntu. Thaanks

      Delete
  2. Most of the machines will get fixed by the above solution. You can report your problem in launchpad[https://bugs.launchpad.net/ubuntu/+filebug]. Or give me some time to research on your hardware.

    ReplyDelete
  3. Well, i just looked at '/sys/bus/pci/drivers' folder on my system and it doesn't have the 'xchi' folder -- see line 4 of the script above. Instead, there are 'ohci' and 'uhci' in addition to 'ehci'.
    Does that have any impact on the how the script will work?
    My system is a Sony Vaio VPCEB1E0E.

    This is the listing I got from ls /sys/bus/pci/drivers:
    agpgart-amdk7 ata_generic HDA Intel mei pcieport uhci_hcd
    agpgart-intel ata_piix i915 ohci_hcd pci-stub
    agpgart-nvidia ath9k imsttfb parport_pc pdc_adma
    agpgart-via ce4100_i2c intel ips pata_acpi sdhci-pci
    ahci ce4100_spi ioapic pata_sis serial
    asiliantfb ehci_hcd langwell_gpio pci_eisa sky2

    ReplyDelete