Disable USB autosuspend on Linux
Are you running Linux and your mobile phone won’t charge when plugged into your laptop? Or your mouse suddenly stops moving until you press a mouse button? Chances are it is USB autosuspend that is to blame. USB autosuspend is a power-saving feature in recent Linux kernels that powers off USB devices if the kernel thinks that those devices aren’t needed right now. Unfortunately, if you are trying to charge your iPhone, you are usually not using it with your computer, so chances are that your kernel will switch off power - making charging rather difficult. It can also cause problems with some USB mice which will stop responding after a short while until you press a mouse button to tell them to power on again.
The following instructions have been tested on OpenSuSE, but should not be too distro-specific. You find all your plugged-in USB devices in the virtual filesystem /sys/bus/usb/devices
. In this folder, you will find one folder per device and in each per-device folder you will find the file power/control
. If you want to review the current setting, you can output it like this:
cat /sys/bus/usb/devices/<your device>/power/control
Valid values are auto
for automatic autosuspend and on
for disabling autosuspend (keeping your device on
all the time). If you have problems, you want to set this value to on
like this:
echo on > /sys/bus/usb/devices/<your device>/power/control
If you do not want to go through the hassle of finding the right device folder (which you can find using lsusb
, by the way, see this useful post and you do not need the power-boost (e.g. because you are connected to a power supply), you can also disable autosuspend for all your USB devices with the following shell script:
#!/bin/bash
for dev in /sys/bus/usb/devices/*/power/control; do
echo $dev
echo on > $dev
done
Note that this command needs to be called every time after you plug-in the device (and every time after you reboot your computer). For a permanent solution, you need to use specific USB management tools or the solution given here.
Comments
You can comment on this post on Mastodon.
If you want to comment with your Mastodon account at another instance, you can use the remote interaction buttons on mstdn.io or copy this URL into the search bar at your Mastodon instance to load the relevant toot: