How can I disable USB autosuspend on Ubuntu 18.04?
Update, 20201014: Just received validation (see comment from "Blackbird") that this solution continues to work in 20.04. Thanks Blackbird for the useful feedback!
This reference seems to be authoritative on disabling usb autosuspend.
Although the USB autosuspend is a feature designed to preserve battery life, its' 18.04 default is "enabled", whether or not the device Ubuntu is being installed on even has a battery.
Further, in order for autosuspend to be more help than harm, it appears that the USB device's driver needs to support autosuspend. Hence all the posts- yours' included- seeking to disable the "feature".
In 18.04 on my device, I scripted disabling autosuspend persistently in /etc/default/grub
like so:
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="/&usbcore.autosuspend=-1 /' /etc/default/grub
update-grub
systemctl reboot
The sed
expression just prepends "usbcore.autosuspend=-1" with a trailing space after the initial quote mark to ensure it always matches whatever your particular GRUB_CMDLINE_LINUX_DEFAULT options look like.
If you execute cat /sys/module/usbcore/parameters/autosuspend
after a reboot, you'll remark the "-1" preference (disabled) is retained.
Anyhoo, hope this helped you out-
Related videos on Youtube
Paulo Coghi
Linux infrastructure and cloud manager. Full stack developer. Most importantly, my life is defined by the grace of God given to men through Jesus Christ. It is my ambition that everything I do would reflect His glory and point people towards Him.
Updated on September 18, 2022Comments
-
Paulo Coghi over 1 year
How can we disable USB autosuspend on Ubuntu 18.04 for all USB devices and/or specific ones?
Previous questions on this subject are outdated (How can I disable usb-autosuspend for a specific device? and How to disable auto power off of usb devices like usb mouse?)
Edit: This question is completely unrelated to Two USB ports stopped working because my USB ports have not stopped working completely, but apparently and momentarily suspended for just a few (mili)seconds
-
Rael Gugelmin Cunha over 4 yearsPossible duplicate of 2 usb ports stopped working
-
Paulo Coghi over 4 years@RaelGugelminCunha, if possible, please remove the duplicate flag
-
Rael Gugelmin Cunha over 4 years@paulo-coghi-reinstate-monica exactly same issue (disable auto suspend for usb devices), exactly same fix (disable it on grub).
-
-
B. Butz over 4 yearsThis simply did not work for me. My USB device (Yamaha eletric piano) still quits after about 30 seconds. The referenced article, while informative, does not make clear how to disable autosuspend altogether.
-
F1Linux over 4 years@PaulA. I’m using the above solution to disable autosuspend on a Linux router running 18.04. Are you running 18.04?
-
B. Butz over 4 yearsI'm running 18.04, but with the 19,04 backports. Where is the description of the settings for usbcore.autosuspend? The referenced authoritative writeup is from 2013.
-
F1Linux over 4 years@PaulA.Idea: If you've followed my instructions above, to exclude there's nothing funky related to the hardware itself, I'd suggest connecting a USB hard drive to it and seeing if that behaves correctly (doesn't auto-suspend). Also, try the Yamaha and the external hard drive on different USB ports on your Linux host to ensure the port itself is correct and has no faults. Give that a go and let me know the results bud-
-
B. Butz over 4 yearsI tried changing USB sockets but it made no difference. I think I can exclude the hardware as the source of the problem since it works perfectly under Windows 10 on the same dual-boot machine. Furthermore, if I reboot the music comes back again -- for about half a minute. Is there any chance that the 19.04 backports are related? That seems unlikely.
-
B. Butz over 4 yearsI tried attaching a USB drive and it keeps going. So perhaps there's something odd about the piano after all.
-
B. Butz over 4 yearsI think I can exclude the piano as the source of the problem since it works perfectly under Windows 10 on the same dual-boot machine.
-
F1Linux over 4 yearsIf the USB hard drive doesn't power-suspend, then there's something going on with the device itself (or it's driver). Clearly auto-suspend IS disabled as the USB hard drive DOESN'T go into a low-power state during inactivity. So looks like "auto-suspend" was a red-herring. If auto suspend WASN'T being disabled, the USB hard drive would continue to be sent to a low power state after a period of inactivity. IDEA: can you update firmware in the Yamaha? I know absolutely nothing about this peripheral, so might be something you can look at
-
B. Butz over 4 yearsThe fact that the piano works fine in Windows 10 (same machine) and recovers briefly after a reboot certainly indicates that the fault does not lie with the piano. I believe that
autosuspend
can be done selectively -- which might have something to do with the fact that the USB hard drive doesn't autosuspend but the piano apparently does. I also read somewhere that enablement ofautosuspend
was only recently set to default toenabled
. -
Matt Billenstein over 4 yearsAnother wrinkle, GRUB_CMDLINE_LINUX_DEFAULT may be overridden in /etc/default/grub.d -- I had to remove it from 50-curtain ... See bugs.launchpad.net/ubuntu/+source/grub2/+bug/1569567
-
hwak almost 4 yearsthis command helped in my case:
echo -1 >/sys/module/usbcore/parameters/autosuspend
. source: kernel.org/doc/Documentation/usb/power-management.txt -
Blackbird over 3 yearsThis solution also works for Ubuntu 20.04.
-
F1Linux over 3 years@Blackbird I updated my answer to include your feedback. Really appreciate you taking the time to provide useful feedback to improve the answer!
-
Humpity about 3 yearsAnd if I don't use GRUB ?
-
pishpish about 3 years@F1Linux Funny how you immediatelly updated the answer with a positive feedback, but completely ignored the dude who said it didn't work for him. Well, this has no effect on my system either.
-
F1Linux about 3 yearsHi @pishpish- In regards to not responding to Humpity, my answer- the only answer- to this question is GRUB specific. I made no warranties for any other configuration. Humpity wanted an answer for non-GRUB. There's nothing stopping you or somebody else adding a NEW answer for Humpity. Whenever I solve a problem for myself and I feel the solution might benefit a wider audience, I knowledge share to avoid a gazillion folks- OK, 12,000 users at time of writing- all solving the same problem individually.
-
David over 2 yearsGreat glad you found a solution but what about later when that link does not work? If there is information in the link that helps the issue include it in your answer not as a link only.
-
Anton Ryabchenko over 2 yearsTrue. Just create a file for udev like this:
/etc/udev/rules.d/92-usb-input-no-powersave.rules
with content ofACTION=="add", SUBSYSTEM=="input", TEST=="power/control", ATTR{power/control}="on"
-
David over 2 yearsPut that in the answer not as a comment.
-
Admin about 2 years@Genere - hello and welcome to askubuntu; please try to provide more explanation; why run these commands? (and, most importantly, what they are doing) maybe
add some references
:) keep it up!