6

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?

JoshuaD
  • 537
  • 1
  • 7
  • 21
  • Could you please post the output of cat /proc/meminfo | grep MemTotal and sudo fdisk -l | grep swap. That would prove helpful for others to answer your question... – rusty Dec 07 '13 at 16:58
  • your comment to Moshen's: "...the problem is with suspend as well...", please be kind enough to elaborate that... – rusty Dec 07 '13 at 17:32
  • @ajThapa: cat /proc/meminfo | grep MemTotal returned "MemTotal: 4046840kb fdisk -l returned "Disk /dev/mapper/ubunto--vg-root doesn't contain a valid partition table, "Disk /dev/mapper/ubuntu--vg-swap_1 doesn't contain a valid partition table", "Disk /dev/mapper/ubuntu--vg-swap_1: 4290 MB, 4290772992 bytes" – JoshuaD Dec 07 '13 at 23:59
  • If it's encrypted swap partition that you have, I've posted what Ubuntu community documentation suggests. Hope it helps. – rusty Dec 08 '13 at 04:07
  • Which Ubuntu version are you using with what kernel version? – falconer Dec 11 '13 at 10:38

5 Answers5

2

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.

Mohsen
  • 29
  • 1
  • Thanks for the info. Unfortunately the problem is with suspend as well, so I don't think this is the problem. – JoshuaD Dec 01 '13 at 01:39
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.

Sukupa91
  • 3,037
  • 2
  • 20
  • 33
  • Question, why would it be more effective to write a bash script to process and control what can resume/thaw the system, rather than to use the already available control array contained within /proc/acpi/wakeup as suggested by my answer? I'm not bashing your answer, it will work, but it seems overly complex and essentially adding a function that is already available thus using more disk space for itself and wasting disk space by making the original function obsolete when it's perfectly functional. I could have very well missed something here... I'm by no means a Linus T. prodigy... – DeeJayh Dec 06 '13 at 17:38
  • Actually yeah it can be done in that way too , but it seems its the issue with kernel which is not letting the Graphic Card to suspend or kernel cant. In your answer you are trying to change the default content of /proc/acpi/wakeup , where is here it is just a script for force suspend Graphic Card at a click. It will not depreciate or waste any noticeable disk space . Well finally I am not the creator of everything , I am the one who has submerged the answer to be easily used by everyone. And checked it myself on my laptop. – Sukupa91 Dec 06 '13 at 17:47
  • Thanks for your response. None of these solutions worked. The second solution sped up things up, but everything still brings me back immediately to a lock screen. – JoshuaD Dec 07 '13 at 04:13
  • @JoshuaD Have you tried both the scripts one by one , each after two reboots?? – Sukupa91 Dec 07 '13 at 04:47
  • Each after two reboots? Nope. I rebooted once between each. I will try rebooting twice between each now. – JoshuaD Dec 07 '13 at 05:48
  • Two reboots between each option, one at a time, no success. – JoshuaD Dec 07 '13 at 06:35
  • use this "sudo modprobe -r tpm_tis" to unbind tpm_tis driver..mandrobe is mainly used to add or remove modules from kernel. – Sukupa91 Dec 07 '13 at 07:43
  • Thanks for all of your effort Sushant, that also didn't work. – JoshuaD Dec 07 '13 at 16:48
  • 1
    Check the updated answer. Last hope from my side . Sorry. – Sukupa91 Dec 07 '13 at 17:00
  • "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" " I wish I could upvote your post twice, thanks for all of your effort. Hopefully it'll help someone else even though it didn't happen to solve my problem. – JoshuaD Dec 07 '13 at 17:07
  • "NVIDIA GeForce 9200M GS (512MB)" using NVidia's drivers (propriety, tested), which I installed using Ubuntu's Software and Updates graphical interface. – JoshuaD Dec 07 '13 at 17:17
  • output of "s2ram -n" , to check if your pc is in whitelist and see "sudo s2ram -f" works... – Sukupa91 Dec 07 '13 at 17:20
  • Machine 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" – JoshuaD Dec 07 '13 at 17:23
  • sudo s2ram -f This kernel doesn't have KMS support. s2ram_do: Input/output error – JoshuaD Dec 07 '13 at 17:24
  • The fact is Kernel ModeSetting(KMS) is by default enabled in every latest kernel , somehow due to any reason its not there. Well without wasting your time and energy any more ,re-install Ubuntu and go for latest version . hopefully it will work . and I am not suggesting you to do any more work around on this s2ram, because of the fact that it might cause physical damage. – Sukupa91 Dec 07 '13 at 17:28
2

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.

rusty
  • 16,327
1

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

DeeJayh
  • 378
  • 1
  • 4
  • 17
  • Allow me to elaborate, I believe the issue is a kernel bug that hasn't been squashed yet... If you find your /proc/acpi/wakeup reverting back to the original after a power-off or restart, simply create a bash script to modify wakeup the way you want it and have that script run on startup until the issue has been permanently addressed. – DeeJayh Dec 05 '13 at 21:06
  • Thanks for your answer. Something weird is going on with my wakeup, so I can't test if this solution works. I can't edit it or remove it. I have tried sudo vi wakeup, but when I try to save my changes, it tells me the file has changed and doesn't let me overwrite it. If I try to sudo rm Wakeup, it says Operation not permitted. I tried copying it to my home directory, modifying it there, and then sudo cp'ing it back to /proc/acpi, but it immediately reverts to its previous state. Any ideas? – JoshuaD Dec 07 '13 at 03:41
  • This is what vi says: ""/proc/acpi/wakeup" WARNING: The file has been changed since reading it!!! Do you really want to write to it (y/n)?y "/proc/acpi/wakeup" E667: Fsync failed WARNING: Original file may be lost or damaged don't quit the editor until the file is successfully written! Press ENTER or type command to continue – JoshuaD Dec 07 '13 at 03:58
  • Ok, so trying to edit it directly doesn't work. Apparently it's not a normal file. Doing "echo UHC1 > wakeup" does let me toggle them, trying that now. – JoshuaD Dec 07 '13 at 04:38
  • Toggling them all to off didn't make a difference. – JoshuaD Dec 07 '13 at 05:48
  • I'm going to chalk it up to hardware then, even with the bug in the kernel, this answer should have provided you a solution... Check your keyboard for soda spillage and your power button for the sticky remembrance of someone's bubblegum fingers, because at this point it's got to be hardware waking up the system. I'd be willing to place a wager that if you disconnected everything but the laptops screen and booted it up, ssh'd in from another pc, and sent a suspend, it would work fine. On a shot in the dark check your BIOS settings and make sure nothing there is allowed to wake up the pc. – DeeJayh Dec 07 '13 at 17:53
  • Even if you think "X" thing wouldnt wake it up, disable it's ability to anyway... Remember the issue with anything in /proc is that they really AREN'T files, but peepholes into the kernel itself, although in the spirit of linux "Everything is a file... Files are files, folders are files, even devices are files" – DeeJayh Dec 07 '13 at 17:55
1

check your kernel there is a bug in kernels(https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1133835) previous to I think it is 3.11 which causes this problem. You can update the kernel without up dating the system How to update kernel to the latest mainline version without any Distro-upgrade?

matpol
  • 111