1

Problem: I hibernate the computer at night and my cat wakes it by stepping on the keyboard. Yes, hibernate a.k.a. suspend to disk, with systemctl hibernate. Not suspend to ram. I used to think that, once completed, hibernation would be indistinguishable from a normal shutdown but apparently that's not the case since the computer doesn't wake on usb after a normal shutdown.

System: Debian 10, motherboard ASUS B450.

What I've tried:

I couldn't find anything on the BIOS.

cat /sys/bus/usb/devices/usb[1-7]/power/wakeup

All return disabled.

There are other "devices" under /sys/bus/usb/devices/ but they all seem to be hubs and don't have the power/wakeup option. They all have names like such: 1-0:1.0.

I would like to solve this by software. I would not like to:

  1. Anything that involves changing my setup, locking the room, selling the cat, etc;
  2. Turn off the power strip. The router is connected to it and other people might want wifi while I'm asleep.

Thanks for the help, in advance.

EDIT:

cat /proc/acpi/wakeup returns:

Device  S-state   Status   Sysfs node
GPP0      S4    *disabled
GPP1      S4    *disabled
GPP3      S4    *disabled
GPP4      S4    *disabled
GPP5      S4    *disabled
GPP6      S4    *disabled
GPP7      S4    *disabled
GPP8      S4    *enabled   pci:0000:00:03.1
X161      S4    *disabled  pci:0000:08:00.0
GPP9      S4    *disabled
X162      S4    *disabled
GPPA      S4    *disabled
GPPB      S4    *disabled
GPPC      S4    *disabled
GPPD      S4    *disabled
GPPE      S4    *disabled
GPPF      S4    *disabled
GP10      S4    *disabled
GP11      S4    *disabled
GP12      S4    *enabled   pci:0000:00:07.1
GP13      S4    *enabled   pci:0000:00:08.1
XHC0      S4    *enabled   pci:0000:0a:00.3
GP30      S4    *enabled   pci:0000:00:08.2
GP31      S4    *enabled   pci:0000:00:08.3
PS2K      S3    *disabled
PS2M      S3    *disabled
GPP2      S4    *enabled   pci:0000:00:01.3
PX11      S4    *disabled
PX12      S4    *disabled
RLAN      S4    *disabled  pci:0000:07:00.0
PTXH      S4    *enabled   pci:0000:01:00.0
  • "Wake" has little to do with the OS running--While "hibernated", the OS is _not even running!_ If your _system BIOS does not have a way to disable wake on USB, then you will have to find an alternative that you do not want, such as... putting the keyboard/mouse where the cat will not step on it, etc. You might also turn off the power in your PC, and not the entire power strip, since "hibernation" actually writes RAM out to the system SWAP space, and shuts the hardware down. – C. M. Jul 30 '21 at 18:15
  • I suspect there is a way to disable this behavior since it doesn't happen with normal shutdown. The operating system is telling the hardware to wake on usb only if I hibernate. – clappy_blappy Jul 30 '21 at 18:42
  • First, I _am_ differentiating between "hibernate" and "sleep" modes. Second, the BIOS ACPI configuration is what controls how and when the hardware wakes _after_ it receives an ACPI S5 shutdown.. That is why it does not trigger during a _normal_ shutdown. But to my knowledge, ACPI S5 shutdown has no way to limit wake events that are not set in the BIOS settings. If your mobo has no such setting, then your mobo does not aupport it, regardless. Sleep mode can, because it actually wakes the OS and resumes it long enough to let the OS decide if it wants to stay awake or go back to sleep. – C. M. Jul 30 '21 at 19:13
  • Correction to the above: ACPI S4 and S5 is what differeniates between a "hibernation shutdown (S4)", and a "full shutdown (S5)" – C. M. Jul 30 '21 at 19:22
  • How can I tell systemd to send an ACPI shutdown S5 when hibernating? – clappy_blappy Jul 30 '21 at 19:28
  • That I am not certain if it can be done or not. That would likely bypass writing out the hibernation data to disk. so it would fully boot next startup instead of resuming from hibernation. You might as well just fully shutdown in that case. Another note I did not think of at first... My wireless keyboard has a power switch, so I can turn it off when not in use.. And has the side effect that, if powered off, it will not send any signals to the hardware to wake it. Perhaps you can find a keyboard with such a switch, or simply unplug it when you hibernate? – C. M. Jul 30 '21 at 19:40
  • Thanks for trying to help! – clappy_blappy Jul 30 '21 at 20:05
  • A candidate for UUOC ? – Paul_Pedant Jul 31 '21 at 09:51
  • Buy a plastic dust-cover for your keyboard? – Jeremy Boden Jul 31 '21 at 12:05
  • @meuh I can see some enabled devices under `/proc/acpi/wakeup` but they all have weird names. How can I disable them? Edited the question to include the output of `cat /proc/acpi/wakeup`. – clappy_blappy Jul 31 '21 at 16:54
  • @meuh Ok I can disable them with `echo disabled > /sys/pci/...` but which ones should I disable? Could any of them be the power button? `XHC0` seems usb related. Also how to make the change permanent? – clappy_blappy Jul 31 '21 at 17:02
  • It just werks™. Thanks a lot everyone. @meuh If you want to write an answer I will accept it. – clappy_blappy Jul 31 '21 at 18:39
  • 1
    This is how to [make it permanent](https://wiki.archlinux.org/title/Systemd#systemd-tmpfiles_-_temporary_files) with systemd. CC @meuh in case you want to include it in the answer. – clappy_blappy Jul 31 '21 at 18:48

1 Answers1

2

There's some background on ACPI states in the kernel doc.

Since the keyboard is presumably a usb device, if it cannot be disabled, you can try to disable the controller. As well as /sys/bus/usb/devices/, there are also devices listed in pseudo file /proc/acpi/wakeup that you can disable. These tend to be on the motherboard, rather than hotplug. The 4 character names are rather obscure, coming from the bios, but some of them are described in this answer. You can toggle one by writing its name into the file, for example:

echo XHC0 >/proc/acpi/wakeup

This should disable your USB 3 controller. You are still dependent on what the bios does, hence suspend-to-ram might be necessary, as C.M. pointed out in the comments.

For a permanent setting, you need to write this everytime you boot, and as you found, the systemd-tmpfiles utility can do this using its general purpose methods. Create a file such as /etc/tmpfiles.d/disable-usb-wake.conf with the lines

#    Path                  Mode UID  GID  Age Argument
w    /proc/acpi/wakeup     -    -    -    -   XHC0

The first line is just a comment. See man tmpfiles.d for the format.

meuh
  • 49,672
  • 2
  • 52
  • 114