14

If I try to suspend the system it just wakes up either immediately or after a couple of minutes. I have an excerpt of my system log showing when it entered suspend and exited but I don't know how to upload it here in an easy to read format.

zany130
  • 345

5 Answers5

10

I had the very same problem after upgrading from ubuntu 16.04 to ubuntu 18.04.

I solved by disabling the wakeup option for the device that in my case was enabled.

$ cat /sys/bus/usb/devices/*/power/wakeup
disabled
enabled
disabled
disabled

$ ll /sys/bus/usb/devices/*/power/wakeup -rw-r--r-- 1 root root 4,0K mag 19 11:04 /sys/bus/usb/devices/1-7/power/wakeup -rw-r--r-- 1 root root 4,0K mag 19 11:02 /sys/bus/usb/devices/1-9/power/wakeup <-- the bad guy -rw-r--r-- 1 root root 4,0K mag 19 10:46 /sys/bus/usb/devices/usb1/power/wakeup -rw-r--r-- 1 root root 4,0K mag 19 10:46 /sys/bus/usb/devices/usb2/power/wakeup

But what really helped me to identify the device were its ids.

cat /sys/bus/usb/devices/1-9/idVendor
8087
cat /sys/bus/usb/devices/1-9/idProduct
0a2b

After googling a bit, turns out it's the bluethooth controller.. https://usb-ids.gowdy.us/read/UD/8087/0a2b

Finally disable it

echo "disabled" >  /sys/bus/usb/devices/1-9/power/wakeup

Now my laptop really suspends. Hope this helps you too.

Too make it persistent after reboot:
according to this post

add this command to /etc/rc.local

if this file does not exist, run:

printf '%s\n' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local
sudo chmod +x /etc/rc.local

The file should look something like:

#!/bin/bash
echo "disabled" >  /sys/bus/usb/devices/1-9/power/wakeup
exit 0

Test start the rc.local service with

sudo /etc/rc.local start

and test it with

sudo systemctl status rc-local

Reboot to see changes.

Ali
  • 103
cventr
  • 116
  • 1
    This solution worked beautifully for me but was not persistent. After restart the disabled device became enabled again! Is there any way to make the change persistent? – eli Oct 17 '19 at 15:52
  • @eli tried putting that command on rc.local? if the specific device changes, in this example "1-9" you may script something to detect the new value prior. – VeganEye Jun 03 '20 at 19:24
  • 1
    @cventr I think grep "enabled" /sys/bus/usb/devices/*/power/wakeup pin point the clue easier :) – VeganEye Jun 03 '20 at 19:28
  • btw, I had to use echo "disabled" |sudo -k tee /sys/bus/usb/devices/2-1.2/power/wakeup as it requires root, also to know about the device we just need to use this command lsusb |grep 0e8f:0022 (vendor:product) – VeganEye Jun 04 '20 at 01:31
  • When I used the suspend command, about 10min later it woke up. But when I pressed the power button (configured to suspend) it worked, yes I have all usb set to "disabled". – VeganEye Jun 05 '20 at 19:24
  • @VeganEye I ended up adding a small cron job to continue disabling it every minute. Unfortunately this was not enough and my laptop still does not always enter suspend. Whats worse is that once it fails to suspend, and then I try to login, the system hangs on the login page and the only way out is a hard reset... – eli Jun 06 '20 at 17:27
  • @eli check my answer, the power button seems to work here :) – VeganEye Jun 06 '20 at 19:02
2

This happened to me after an update of Ubuntu 21.04 Hirsute Hippo. The problem was nvidia graphics card and installed CUDA.

To fix the issue, disable CUDA repository in Software Updater. Image of software updater

Update nvidia drivers.

sudo apt install nvidia-driver-[your drive number]

If you don't know your driver number, check your installed drivers.

apt list -i | grep nvidia

Enable these services in systemd.

sudo systemctl enable nvidia-suspend.service
sudo systemctl enable nvidia-hibernate.service
sudo systemctl enable nvidia-resume.service
  • OMG, you are right, some NVIDIA stuff is was interfering with suspend even though I had disabled using the graphic drivers. I purged all NVIDIA packages and then suspend worked! This as part of debugging at: https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-510/+bug/1953674 Final summary at: https://askubuntu.com/questions/1032633/18-04-screen-remains-blank-after-wake-up-from-suspend/1391917#1391917 – Ciro Santilli OurBigBook.com Feb 09 '22 at 10:21
0

What is working for me is to use the power button.
We can configure it on the settings to suspend (instead of shutdown).
(You can always long press tho to force a hard shutdown).

It seems here that the notebook wont remain suspended if I use the suspend application/command from the menu.
I tried changing all usb's wakeup to disabled too but that didnt work here.

I could guess that the power button is working because I am avoiding touching the keyboard. Even disabled, I still can use the keyboard to wakeup tho.

VeganEye
  • 161
0

Simple script to add to bashrc based on cventr's answer:

for path in `sudo ls -l /sys/bus/usb/devices/*/power/wakeup | awk '{print $9}'`;
do
    sudo echo "disabled" >  $path
done

I also use this one:

            for usb in `cat /proc/acpi/wakeup | grep ".*" | cut -f1`;
            do
                    state=`cat /proc/acpi/wakeup | grep $usb | cut -f3 | cut -d' ' -f1 | tr -d '*'`
                    if [ "$state" == "enabled" ]
                    then
                            echo $usb > /proc/acpi/wakeup
                    fi
            done
stackOverlord
  • 97
  • 1
  • 3
0

I would suggest to follow this approach since rc.local is deprecated and mainly there for specific use cases and backward compatibility.

In my case the service under /etc/systemd/system looks like this:

[Unit]
Description=Disables wake-up from keyboard and mouse
# the service runs before the computer goes to sleep
Before=sleep.target

[Service] Type=simple ExecStart=/usr/bin/bash -c "sudo echo disabled > /sys/bus/usb/devices/1-10/power/wakeup & sudo echo disabled > /sys/bus/usb/devices/1-9/power/wakeup"

[Install]

this does the hook to sleep.target

WantedBy=sleep.target

Teested it a couple of times now and it seems to work as expected.

Amuoeba
  • 101