How do I get suspend working on an HP DV4T?

Suspend doesn't work on my laptop. When the laptop tries to suspend, the screen turns off briefly, some system-looking text appears for a bit, the screen turns off again, then the screen turns back on and I am at a locked-screen prompt.

I tried:

  1. The suspend button on the unity menu
  2. sudo pm-suspend
  3. sudo acpitool -s
  4. dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
  5. Deleting /etc/pm/sleep.d (as suggested here)
  6. sudo modprobe -r tpm_tis
  7. Modfying /proc/acpi/wakeup to switch everything but the power button to disabled.
  8. Putting SUSPEND_MODULES="alx" into /etc/pm/config.d/modules
  9. Writing a script that forces the graphic card to reboot itself using a "kick" from chvt1 and chvt7 and putting it in /etc/pm/sleep.d/20_custom-ehci_hcd (@Sushantp606's answer below)
  10. Trying the same thing as #9 in a different way (the third part of @Sushantp606's answer below)
  11. sudo s2ram

    This kernel doesn't have KMS support. Machine is unknown. This machine can be identified by: sys_vendor = "Hewlett-Packard" sys_product = "HP Pavilion dv4 Notebook PC" sys_version = "F.24" bios_version = "F.24"

None of these solved the problem. #9 changed the behavior a little (it cycled more quickly between trying to go to sleep and waking up).

Any suggestions what I can look at doing next?


Solution 1:

This page may help: https://help.ubuntu.com/community/SwapFaq

Hibernation (suspend-to-disk) The hibernation feature (suspend-to-disk) writes out the contents of RAM to the swap partition before turning off the machine. Therefore, your swap partition should be at least as big as your RAM size. The hibernation implementation currently used in Ubuntu, swsusp, needs a swap or suspend partition. It cannot use a swap file on an active file system.

Solution 2:

Now as you have tried almost everything,it worth an good and effective anser . Well this issue is some how related to Graphic Card , it does not goes to suspend and thats why nothing works.So there are to solutions I have mentioned to concur that try it one by one.

Create a file modules under /etc/pm/config.d by -

sudo gedit /etc/pm/config.d/modules

and paste the following command into it -

SUSPEND_MODULES="alx"

This will force the alx module to be unloaded and reloaded with suspend , and your problem will be solved by this , if not delete that line and go to the next part.

This one will work for sure . as it forces the graphic card to reboot itself using a good old kick from chvt1 and chvt7.So lets start it by starting with 20_custom-ehci_hcd as follows -

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

provide you password and paste the following into gedit

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

Save it and then Provide the permission by -

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

Reboot by-

sudo reboot

and now check. it will work for sure but if your kernel refuses for that script then replace the entire code with the following -

#!/bin/sh
# File: "/etc/pm/sleep.d/20_custom-ehci_hcd".
TMPLIST=/tmp/ehci-dev-list
case "${1}" in
hibernate|suspend)
;;
resume|thaw)
chvt 1
chvt 7
;;
esac

your suspend would be working by now, this answer is gathered from UbuntuForum.

Last Work Arround for this you need to install a small application that is uswsusp , install it by following command-

sudo apt-get install uswsusp

After Installation Completes check it suspend by the following -

sudo s2ram

Your PC must goes to suspend by now.

And for hibernation -

sudo s2disk

Now if it works then remove the previously default Scripts and commands by following but before doing anything make backup by-

sudo cp /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux.bak

sudo cp /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux.bak

Now lets replace the old files and commands by-

hal-system-power-suspend-linux
hal-system-power-hibernate-linux

then

sudo nano /usr/lib/hal/scripts/linux/hal-system-power-suspend-linux

and paste the following into it -

#!/bin/sh
/sbin/s2ram –force

and for hibernate-

sudo nano /usr/lib/hal/scripts/linux/hal-system-power-hibernate-linux

and paste the following into it -

#!/bin/sh
/sbin/s2disk

Hope this time it helped you.

Solution 3:

Ubuntu community help page suggests the following to enable Hibernation with encrypted swap partition:

Preparation:

  1. Your computer must already be set up for encryption. If not, follow instructions in Post Installation Encryption first.

  2. Think of a password (or passphrase) for your swap partition. You can use the same as your log-in — but don't do that if other people have accounts on your computer!

  3. Find out which is your encrypted swap partition.

     swapon --summary
    

    You should see output similar to:

     Filename                        Type            Size    Used    Priority
     /dev/mapper/cryptswap1          partition       1998844 0       -1
    

    If you do not see cryptswap1, the partition is either unencrypted or is not encrypted to Ubuntu's standard,

  4. Now,

     sudo cryptsetup status cryptswap1
    

    Output should be similar to

     /dev/mapper/cryptswap1 is active and is in use.
       type:    PLAIN
       cipher:  aes-cbc-essiv:sha256
       keysize: 256 bits
       device:  /dev/sda1
       offset:  0 sectors
       size:    3997696 sectors
       mode:    read/write
    

    Make a note of the device. The one in the example says /dev/sda1but yours could be something else, e.g. /dev/sdb3.

  5. Back up.

How to Set Up Hibernation

  1. Turn off swap.

     sudo swapoff /dev/mapper/cryptswap1
    
  2. Undo the existing mapping.

     sudo cryptsetup luksClose /dev/mapper/cryptswap1
    
  3. Set up swap again, but this time with your chosen passphrase. The command will prompt you, twice, for your passphrase. Replace /dev/sdXN with the device from Preparation point 4. (The following command wraps on the browser screen, but it is a single command that you need to type.)

     sudo cryptsetup luksFormat --cipher aes-cbc-essiv:sha256 --verify-passphrase --key-size 256 /dev/sdXN
    

    Output should be:

     WARNING!
     ========
     This will overwrite data on /dev/sda1 irrevocably.
     Are you sure? (Type uppercase yes):
     Enter LUKS passphrase:
     Verify passphrase:
    

    Type YES and enter your passphrase twice as prompted.

  4. Re-map the swap. Replace /dev/sdXN with the device from Preparation point 4.

      sudo cryptsetup luksOpen /dev/sdXN cryptswap1
    
  5. Set up the partition as swap.

     sudo mkswap /dev/mapper/cryptswap1
    
  6. Turn on the swap (so it starts working again).

     sudo swapon --all
    
  7. Check that it is working.

     swapon --summary
    

    You should see output similar to this (the numbers may differ).

     Filename                        Type            Size    Used    Priority
     /dev/mapper/cryptswap1          partition       1996796 0       -1
    
  8. Using gksudo with your favourite editor (the default for Ubuntu is gedit), edit the file /etc/crypttab (e.g. run gksudo gedit /etc/crypttab). Comment out the existing line by adding # to the front (or just delete the line), and add the following line. Replace /dev/sdXN with the device from Preparation point 4.

     cryptswap1   /dev/sdXN   none   luks
    
  9. Edit the file /usr/share/initramfs-tools/scripts/local-top/cryptroot. Search for the following line (should be line 288, but this could change over time):

     message "cryptsetup: unknown error setting up device mapping"
    

    Skip to the next blank line (should be 291, before FSTYPE=''), and insert the following line. Replace /dev/sdXN with the device from Preparation point 4.

     /sbin/cryptsetup luksOpen /dev/sdXN cryptswap1
    
  10. Edit the file /etc/acpi/hibernate.sh. At the first blank line, insert the following line.

     DEVICE='/dev/mapper/cryptswap1'
    

    Edit the file /etc/initramfs-tools/conf.d/resume. Replace the existing RESUME line with the following line.

     RESUME=/dev/mapper/cryptswap1
    

    Register these changes.

     sudo update-initramfs -u -k all
    

    Ubuntu disables the Hibernate option in the menu. Restore it as follows. Create (using gksudo with your favorite editor) the file: /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla (e.g. run gksudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla)

    Fill the file with the following text and save.

     [Re-enable hibernate by default]
     Identity=unix-user:*
     Action=org.freedesktop.upower.hibernate
     ResultActive=yes
    
  11. Reboot the machine.

Solution 4:

Modify /proc/acpi/wakeup

Change everything to disabled except for PWRB (or equivelent) so that the only thing that can wake up your PC is the power button.

Enjoy