How do I prevent immediate wake up from suspend and/or hibernation?

This problem was probably caused by strange USB signals. gedit /proc/acpi/wakeup showed me, that wakeup was enabled for USB0 and USB2.

sudo -s
echo USB0 > /proc/acpi/wakeup
echo USB2 > /proc/acpi/wakeup

switched them to disabled (checked by gedit /proc/acpi/wakeup again or refreshing the file-view), and after that, the computer stays in suspend like it should. :-)


I recently had the same symptom on Asus Zenbook Pro UX501 on Ubuntu 15.04. Bazon's exact fix did not work but Vladimir Rutsky's variation did. Specifically:

If running from the terminal cat /proc/acpi/wakeup shows the following lines

EHC1      S3    *enabled  pci:0000:00:xx.x
EHC2      S3    *enabled  pci:0000:00:xx.x
XHC       S3    *enabled  pci:0000:00:xx.x

(pci addresses may be different)

then toggle these three to disabled by issuing the following commands:

sudo -s
echo EHC1 > /proc/acpi/wakeup
echo EHC2 > /proc/acpi/wakeup
echo XHC > /proc/acpi/wakeup

If you know which device wake up your PC go to first step to follow the guide. If you don't, then open terminal and do:

cat /var/log/syslog

And find which device is waking your PC.

So now:

  1. hit in terminal:

    grep . /sys/bus/usb/devices/*/power/wakeup
    

To list all usb ports that wakeup our pc.

sudo su

we have now root privillages.

2.I have 8 USB ports and in this example let's say that I want to disable usb8 ,so:

echo disabled > /sys/bus/usb/devices/usb8/power/wakeup

Go ahead and test it. Now that specific device in USB port 8 won't wake up the PC.

Next step, to make the change permanent after each boot:

3.

sudo nano /etc/rc.local

And we paste the command from step 2. In there (before the exit 0 of course).

That's it.

optional Only if after sleep/wakeup process the USB 8 device , in my example , revert back to enabled.

  1. Write a udev rule too to execute the command after every boot,sleep,wake up.

Open a terminal and do:

lsusb

At your keyboard device id information the 4 first digits are the vendor id and the 4 next digits are the product id screenshot

Next do:

sudo nano /etc/udev/rules.d/10-wakeup.rules

Where "wakeup" enter your desired name of the script. Number 10 is the priority in case you have many other udev rules, the lower the number the 'rule' will be executed before the others.

Copy paste this and replace the vendor id and product id with your own wireless keyboard vendor id and product id.

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="062a", ATTRS{idProduct}=="4101" RUN+="/bin/sh -c 'echo disabled > /sys/bus/usb/devices/usb8/power/wakeup'"

*usb8 for me is my wireless keyboard (you can also see that in the screenshot (Bus 008)), replace it with your own.

Ctrl + O to save , Ctrl + X to exit and reboot.

Tags:

Suspend

Wakeup