How to Stop Ubuntu from Automatically Suspending USB Devices

The Disconnected Drive

Ubuntu features aggressive power management, especially on laptops running off battery power. One of the ways it saves energy is by utilizing a kernel feature called USB Autosuspend. If you plug in a USB flash drive or an external hard drive, the system monitors it. If no data is read from or written to the drive for a few seconds, Ubuntu assumes the drive is idle and automatically cuts power to the USB port, effectively suspending the device. If you are running a script that accesses the drive sporadically, or if you simply leave a document open, this autosuspend feature can cause the drive to unmount, resulting in data corruption or input/output errors.

Disabling USB Autosuspend

To ensure your external drives remain continuously powered and accessible, you must stop Ubuntu from automatically suspending USB devices by modifying the bootloader configuration.

Open a terminal window by pressing Ctrl+Alt+T. You need to edit the GRUB bootloader file to pass a parameter to the kernel. Type sudo nano /etc/default/grub and press Enter (provide your administrator password). Locate the line that begins with GRUB_CMDLINE_LINUX_DEFAULT. Inside the quotation marks at the end of that line, add a space and append usbcore.autosuspend=-1. For instance, the line might look like: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1". Press Ctrl+O to save, Enter to confirm, and Ctrl+X to exit the nano editor. Finally, to apply this change, you must update GRUB by typing sudo update-grub and pressing Enter. Reboot your computer for the change to take effect permanently.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.