Software & AppsOperating SystemLinux

How To Disable USB Autosuspend for a Specific Device in Ubuntu?

Ubuntu 8

In this article, we will guide you through the process of disabling USB autosuspend for a specific device in Ubuntu. This is a useful technique for those who want to prevent their system from automatically suspending a particular USB device to save power.

Quick Answer

To disable USB autosuspend for a specific device in Ubuntu, you can use TLP (for Ubuntu 16.04 and later), laptop-mode-tools (for Ubuntu 14.04), udev rules, or PowerTOP (temporary solution). Each method involves identifying the device’s ID or product ID and making the necessary changes in the configuration files or running specific commands.

What is USB Autosuspend?

USB autosuspend is a feature in Linux-based systems like Ubuntu that automatically suspends a USB device when it is not in use. This is done to conserve power, especially in laptops. However, there may be instances where you do not want a specific USB device to be suspended, such as a USB Wi-Fi adapter or an external hard drive.

Method 1: Using TLP (For Ubuntu 16.04 and later)

TLP is a power management tool for Linux that comes with a default configuration optimized for battery life. Here’s how you can use it to disable USB autosuspend for a specific device:

  1. Install TLP by running the following command in the terminal:
    sudo apt install tlp
  2. Identify the ID of your USB device by running:
    sudo lsusb
    This command will output a list of connected USB devices, each with an ID that looks like 1234:5678.
  3. Edit the TLP configuration file by running:
    sudo vi /etc/default/tlp
    This opens the TLP configuration file in the vi text editor. You can replace vi with your preferred text editor.
  4. Add your device’s ID to the USB_BLACKLIST parameter by adding the following line:
    USB_BLACKLIST="1234:5678"
    Replace 1234:5678 with the ID of your device.
  5. Save the file and exit the editor. The changes will take effect immediately.

Method 2: Using laptop-mode-tools (For Ubuntu 14.04)

For older versions of Ubuntu, you can use laptop-mode-tools to achieve the same result:

  1. Identify the device IDs of the USB devices you want to disable autosuspend for by running lsusb.
  2. Open the usb-autosuspend.conf (or runtime-pm.conf for Ubuntu 14.04) configuration file by running:
    sudo vi /etc/laptop-mode/conf.d/usb-autosuspend.conf
  3. Add the device IDs to the AUTOSUSPEND_USBID_BLACKLIST parameter following the format specified in the file.
  4. Save the file and exit the editor. The changes will take effect immediately.

Method 3: Using udev rules

udev is a device manager for the Linux kernel. You can use it to create rules that trigger actions when a device is added or removed. Here’s how to use udev rules to disable USB autosuspend for a specific device:

  1. Identify the device’s product ID by running:
    udevadm info -a --path /sys/bus/usb/devices/N-N
    Replace N-N with the appropriate device path.
  2. Create a udev rule file by running:
    sudo vi /etc/udev/rules.d/10-usb-device.rules
  3. Add the following rule to the file, replacing the idVendor, idProduct, and product values with the appropriate ones for your device:
    ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", ATTR{product}=="Your Device Name", TEST=="power/control", ATTR{power/control}:="on"
  4. Save the file and exit the editor. The changes will take effect immediately.

Method 4: Using PowerTOP (Temporary Solution)

PowerTOP is a Linux utility that can provide a snapshot of the current power usage of a system. It can also provide recommendations for improving power efficiency.

Please note that this is a temporary solution and the changes won’t survive a reboot.

  1. Run PowerTOP and toggle USB autosuspend off for the specific device.
  2. PowerTOP will display the command to disable autosuspend from the command line, such as:
    echo 'on' > '/sys/bus/usb/devices/3-10/power/control'
  3. You can manually run this command, but remember it won’t survive a reboot.

Conclusion

Disabling USB autosuspend for a specific device should not significantly affect the battery life of your notebook unless the device is constantly consuming power. The changes made will only apply to the specific device you blacklisted or disabled autosuspend for.

Remember to replace the example device IDs and names with the actual ones for your specific device. By following the steps in this article, you should be able to disable USB autosuspend for a specific device in Ubuntu.

What is the purpose of USB autosuspend?

USB autosuspend is a feature in Linux-based systems like Ubuntu that automatically suspends a USB device when it is not in use. This is done to conserve power, especially in laptops.

Why would I want to disable USB autosuspend for a specific device?

There may be instances where you do not want a specific USB device to be suspended, such as a USB Wi-Fi adapter or an external hard drive. Disabling USB autosuspend allows the device to remain active even when it is not in use.

How can I identify the ID of my USB device?

You can identify the ID of your USB device by running the command sudo lsusb in the terminal. This command will output a list of connected USB devices, each with an ID that looks like 1234:5678.

Can I disable USB autosuspend for multiple devices?

Yes, you can disable USB autosuspend for multiple devices by adding their IDs to the appropriate configuration files or udev rules. Simply follow the instructions provided in the article for each device you want to disable autosuspend for.

Will disabling USB autosuspend affect the battery life of my laptop?

Disabling USB autosuspend for a specific device should not significantly affect the battery life of your notebook unless the device is constantly consuming power. The changes made will only apply to the specific device you blacklisted or disabled autosuspend for.

Are the changes permanent or do I need to reapply them after each reboot?

The changes made using TLP, laptop-mode-tools, and udev rules are permanent and will persist even after a reboot. However, the changes made using PowerTOP are temporary and will need to be reapplied after each reboot.

Can I re-enable USB autosuspend for a specific device if I change my mind?

Yes, you can re-enable USB autosuspend for a specific device by removing the device’s ID from the appropriate configuration files or udev rules. Simply follow the instructions provided in the article to make the necessary changes.

Leave a Comment

Your email address will not be published. Required fields are marked *