Udev Rules Don't Allow Ubuntu/NixOS Sequence USB Resume on Lenovo ThinkPads
If you're running Ubuntu 22.04 LTS on a Lenovo ThinkPad T480 or NixOS on a Lenovo ThinkPad X1 Carbon, and you're experiencing issues with USB resume, you're not alone. This article will provide a detailed explanation of the problem and offer a solution to help you get your USB devices working properly again.
Understanding the Problem
The issue arises from the fact that Udev rules on Linux-based operating systems like Ubuntu and NixOS prevent USB devices from resuming from a suspended state. This is particularly problematic for Lenovo ThinkPad users, as these laptops often have USB devices that support remote wake-up and USB resume.
The problem is caused by the fact that Udev rules are designed to prevent USB devices from resuming from a suspended state in order to conserve power. However, this behavior can be overridden by creating custom Udev rules that allow specific USB devices to resume from a suspended state.
Identifying the USB Device Vendor ID
The first step in solving this problem is to identify the USB device vendor ID. In this case, the vendor ID is 0x36dc. This can be found by running the lsusb command in the terminal:
$ lsusb
Bus 002 Device 002: ID 36dc:0004 Corsair, Inc. Vengeance K60 Keyboard
In this example, the vendor ID is 0x36dc and the product ID is 0004. This information is necessary for creating a custom Udev rule that will allow the USB device to resume from a suspended state.
Creating a Custom Udev Rule
To create a custom Udev rule, you will need to create a new file in the /etc/udev/rules.d/ directory. For example, you could create a file called 99-custom-usb.rules:
sudo nano /etc/udev/rules.d/99-custom-usb.rules
In this file, you will need to add a new rule that matches the USB device vendor ID and product ID. The rule should allow the USB device to resume from a suspended state:
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="36dc", ATTR{idProduct}=="0004", ATTR{power/control}="auto"
In this example, the rule matches the USB device with vendor ID 0x36dc and product ID 0004, and sets the power/control attribute to "auto", which allows the USB device to resume from a suspended state.
Testing the Custom Udev Rule
To test the custom Udev rule, you will need to reload the Udev rules:
sudo udevadm control --reload-rules
After reloading the Udev rules, you can test the USB device by suspending the system and then resuming it. The USB device should now be able to resume from a suspended state.
- Udev rules on Linux-based operating systems like Ubuntu and NixOS prevent USB devices from resuming from a suspended state.
- Lenovo ThinkPad users often experience issues with USB resume due to this behavior.
- To solve this problem, you can create a custom Udev rule that allows specific USB devices to resume from a suspended state.
- To create a custom Udev rule, you will need to identify the USB device vendor ID and product ID, and create a new file in the
/etc/udev/rules.d/directory. - The custom Udev rule should match the USB device vendor ID and product ID, and set the
power/controlattribute to"auto". - After creating the custom Udev rule, you will need to reload the Udev rules and test the USB device by suspending and resuming the system.