Skip to content

Instantly share code, notes, and snippets.

@slok
Created June 26, 2011 17:52
Show Gist options
  • Save slok/1047799 to your computer and use it in GitHub Desktop.
Save slok/1047799 to your computer and use it in GitHub Desktop.
The configuration/script files to a proper hibernation/suspend for laptops like Asus U30Jc
#!/bin/sh
#
# File: "/etc/pm/sleep.d/20_custom-ehci_hcd".
#
#This script is for some laptops like Asus U30Jc, and make the laptop
#hibernate and suspend without errors (hang or freeze the system)
#Fist we have to pick the devices to bind and unbind. To select them we have
#to do a command:
# ls -la /sys/bus/pci/drivers/ehci_hcd/
#And pick the devices that have this style: "XXXX:XX:XX.X" For example in this case
#are: "0000:00:1a.0" and "0000:00:1d.0". After this we have to put for each one selected
#an unbind and bind, like in the case below, we see that for each one we have put in
#hibernate/suspend and resme/thaw
#
# THIS FILE NEEDS EXEC PERMISSION (chmod a+x...)
#Also if we want to use hibernate for example with grub we have to add the "resume" option
#in this way: resume=/path/to/swap/partition
#for example:
# title Slackware Linux
# root (hd0,2)
# kernel /boot/vmlinuz root=/dev/sda3 resume=/dev/sda9 vga=773 ro
#
#Commands to suspend/hibernate (You have to be root):
# suspend: pm-suspend
# Hibernate: pm-hibernate
#
#Or if you have upower (better and you don't have to be root) us the scripts(https://gist.github.com/1047799)
case "${1}" in
hibernate|suspend)
# Unbind ehci_hcd for first device 0000:00:1a.0:
echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci_hcd/unbind
# Unbind ehci_hcd for second device 0000:00:1d.0:
echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/unbind
;;
resume|thaw)
# Bind ehci_hcd for first device 0000:00:1a.0:
echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci_hcd/bind
# Bind ehci_hcd for second device 0000:00:1d.0:
echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/bind
;;
esac
#!/bin/bash
#You need upower to execute this: http://upower.freedesktop.org/
#
#This script hibernates the computer with upower, this has advantages over pm-hibernate
#because pm-utils need root access, this doesn't need and also doesnt use HAL
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
#!/bin/bash
#You need upower to execute this: http://upower.freedesktop.org/
#
#This script suspends the computer with upower, this has advantages over pm-suspend
#because pm-utils need root access, this doesn't need and also doesnt use HAL
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
#File: "/etc/pm/config.d/usb3-suspend-workaround".
SUSPEND_MODULES="xhci"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment