I use my laptop basically like a desktop machine. 90% of the time it sits on my desk and monitor, speakers, mouse etc. are plugin in (either via a USB hub or directly).
I’m also using external hard drives, backlit keyboard, and an USB external sound card. Everything works great while the laptop is running. However, for suspend/hibernate the laptop “powers down”, but the USB devices are still powered (hard drive still spinning, LEDs on sound card on, keyboard backlit).
Is there a way to “cut off” power for the USB ports on suspend and hibernate?
Remove your battery when it’s at 50% charge and store it in a desk drawer (=cool, dark, dry place) and only charge it a few hours before you’re going to use the laptop as a laptop. If you don’t do that, the battery will be dead after 3 years because it gets charged and charged and charged until it dies of exhaustion.
Thank you, this looks like what I was looking for, unfortunately I couldn’t figure out how to implement it. I tried but I got stuck with the script to turn off the USB power echo '0' > /sys/bus/usb/devices/usb1/power/control results in Permission denied (same with sudo)
With sudo sh -c "echo '0' > /sys/bus/usb/devices/usb1/power/control" I get line 1: echo: write error: Invalid argument
I tried it with zsh (what I use normally) but I got the same result.
If I’m reading that correctly, one can either use $interface/driver/unbind
An unbound interface device is suspended by default.
or power/pm_qos_no_power_off to power off
A more aggressive userspace policy is to enable USB port power off for all ports (set <hubdev-portX>/power/pm_qos_no_power_off to 0) when some external factor indicates the user has stopped interacting with the system. For example, a distro may want to enable power off all USB ports when the screen blanks, and re-power them when the screen becomes active. Smart phones and tablets may want to power off USB ports when the user pushes the power button.
echo "0" | sudo tee /sys/bus/usb/devices/usb1/power/control gives me tee: /sys/bus/usb/devices/usb1/power/control: Invalid argument
But like freggel.doe said this value has to be auto according to
With the help and pointers in this threat tried the other option:
echo '3-2' | sudo tee /sys/bus/usb/drivers/usb/unbind works in the sense that all the devices on the USB hub/soundcard are not working anymore, but I annoyingly bright LEDs are still on.
The devices connected to the hub work again with echo '3-2' |sudo tee /sys/bus/usb/drivers/usb/bind, but since it does not turn off the LEDs, it it pointless.
I haven’t figured out how to use
power/pm_qos_no_power_off to power off
That’s what was planning to try next.
PS: For other people with similar issues, lsusb is a useful command to find out more about the connected USB devices
Ok @stingray21 … I grabbed now my laptop and tested it myself.
In battery mode my usb devices are off anyway when set to “auto”. That depends how you UEFI firmware works.
Here is what I have…
$ P=("autosuspend" "autosuspend_delay_ms" "control" "level"); for x in ${P[@]}; do echo "$x : $(cat /sys/bus/usb/devices/usb1/power/${x})"; done
autosuspend : 0
autosuspend_delay_ms : 0
control : auto
level : auto
There auto suspending works like expected. Even if in AC mode, USB is still suspended, but the HUB have to support this, otherwise it will be always on.
If I want to force it to turn it on, I type:
echo "on" | sudo tee -a /sys/bus/usb/devices/usb1/power/control
and the USB Flash Drive gets power. The LED turns on.
I can turn it off by typing:
echo "auto" | sudo tee -a /sys/bus/usb/devices/usb1/power/control
When I unplug and plugin again, the flash drive will not turn on.
So conclusion: The only way to disable usb is suspending it and that works only in “auto” mode and the hub have to support this behavior. And of course there are USB HUBs (most old ones) which don’t have this functionality.
A more radical way, would be unloading the usbcore module, but I don’t recommend this.
So check yourself, if your internal HUBs can do “autosuspend”…
P=("autosuspend" "autosuspend_delay_ms" "control" "level"); for x in ${P[@]}; do echo "$x : $(cat /sys/bus/usb/devices/usb1/power/${x})"; done
autosuspend : 0
autosuspend_delay_ms : 0
control : auto
level : auto
Some of my USB devices do turn off when I suspend the laptop, but not all e.g. the USB soundcard/HUB and the external hard drives.
I bought the soundcard/HUB a couple weeks ago, so it’s not old (but maybe the product is on the market for a long time). It was pretty cheap after all.
PS: I ran the script for many devices (usb1 to 4, and also 3-2.3, which is the soundcard/HUB)
P=("autosuspend" "autosuspend_delay_ms" "control" "level"); for x in ${P[@]}; do echo "$x : $(cat /sys/bus/usb/devices/3-2.3/power/${x})"; done
autosuspend : 0
autosuspend_delay_ms : 0
control : auto
level : auto
The reason for this behavior is that it must be ejected/unmounted, so not in use. Otherwise it will not suspend. There is no “power off” action that forces to turn off usb power. I guess this works like that, to avoid damages on the devices.
Sounds reasonable. When I unmount the external drive it keeps spinning, but when “safely remove drive” it stops. It makes sense to not “power off” the hard drive while it maybe still in use.
What irritates me a little is that when I tried the unbind approach, I was not able to select the external sound card any more and the mouse (which is plugged in that hub) was not working. But the LEDs indicating the volume are still on. Since there is no “power off” button on the device, I should be able to handle unplugging while in use, I would think.
Therefore, I’ve marked this answer as the solution to your question as it is by far the best answer you’ll get.
However, if you disagree with my choice, please feel free to take any other answer as the solution to your question or even remove the solution altogether: You are in control! (If you disagree with my choice, just send me a personal message and explain why I shouldn’t have done this or or if you agree)
P.S. In the future, please don’t forget to come back to your question after your issue has been solved and click the 3 dots below the answer to mark a solution like this below the answer that helped you most:
so that the next person that has the exact same problem you just had will benefit from your post as well as your question will now be in the “solved” status.