How to Stop Ubuntu from Automatically Unmounting USB Drives When Suspended

The Abrupt Disconnection

When you close the lid of your Ubuntu laptop or manually trigger a suspend state to save power, the operating system aggressively powers down hardware components. By default, this power-saving protocol includes entirely cutting the power to the USB bus. If you have an external hard drive or a USB thumb drive plugged in, Ubuntu will abruptly unmount the filesystem and power off the drive. While this saves battery, it can lead to severe data corruption if a background process was quietly writing to the drive right as the laptop went to sleep, and it forces you to wait for the drive to remount when you wake the system.

Configuring the Power Manager

To ensure your external storage remains safely connected and powered even while the rest of the laptop sleeps, you must tweak the power management rules to exclude the USB controllers from the suspend protocol.

Open your terminal (Ctrl+Alt+T). You need to edit the default GRUB bootloader configuration to pass a specific kernel parameter that prevents USB autosuspend. Type sudo nano /etc/default/grub and press Enter. Look for the line that begins with GRUB_CMDLINE_LINUX_DEFAULT. Inside the quotation marks at the end of that line, add a space and then append this exact string: usbcore.autosuspend=-1. Press Ctrl+O then Enter to save the file, and Ctrl+X to exit the nano editor. Finally, you must regenerate the bootloader configuration by typing sudo update-grub and pressing Enter. Reboot your laptop to apply the changes. Your USB drives will now remain continuously mounted even when the system is suspended.

Get the best tech tips delivered straight to your inbox.

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