It’s true that Ubuntu (or GNU/Linux in general) is getting better and better at managing power usage under different hardware platforms. For instance, when comparing with older versions, 12.04 Precise Pangolin manages power consumption really well in my Dell Vostro V131 laptop (Intel Sandy Bridge based notebook), and I get a battery life similar to under Windows 7 that came pre-installed with it.
However, after installing Ubuntu, I usually install another tool called ‘Laptop-Mode-Tools‘, a set of utilities (configuration files) that try to minimize the unnecessary power consumptions of your computer’s hardware. And ‘LMT’ further reduces like 0.8 Watts to 1.3Watts of power consumption from my system, which again helps to enhance the battery life, a bit more.
But one issue that I have when installing LMT under Ubuntu 12.04 is that, it disables my USB optical mouse. This is because, LMT adjusts various hardware related power consumption settings, including USB devices which uses a feature called ‘usb-autosuspend’. And as you could guess from its name, it’s designed to put USB devices into a ‘sleep’ status when not used for a certain period, for reducing power usage.
But for some reason, after going into lower power mode, my USB optical mouse refuses to ‘wake-up’.
So the easiest solution is to disable the ‘usb-autosuspend’ feature, but, that will disable the power down features of all the USB devices in general. So it’s not the ideal solution.
However, if you’re too having the same issue, then you can easily fix it by ‘backlisting’ only the USB device ID of your mouse using that configuration file, so all other USB devices will still powered down, except for the USB mouse. Please follow the below steps for achieving that.
Step 1: First, open your Terminal window and enter the below command to backup the original configuration file (just in case).
cp /etc/laptop-mode/conf.d/usb-autosuspend.conf /home/gayan
Replace ‘gayan’ with your user name.
Step 2: Now, before we can edit the configuration file, we have to know the device ID of your USB mouse. For that, enter the below command in your Terminal and look for something that says ‘optical mouse’ or ‘mouse’ etc.
lsusb
Step 3: Then copy the device ID using your mouse, located between the ‘ID’ and device name (as shown above).
Step 4: Then, enter the below command to edit the ‘usb-autosuspend’ configuration file (you’ll need ‘sudo’ privileges).
gksudo gedit /etc/laptop-mode/conf.d/usb-autosuspend.conf
Step 5: Now press ‘Ctrl’ + ‘f’ keys to launch the searching box or, manually locate the the below code in the configuration file.
AUTOSUSPEND_USBID_BLACKLIST
Step 6: Then as shown below, between the ‘ ‘ marks, paste the copied device ID of your USB mouse, and click on the ‘Save’ button then close its window.
That’s it. Now reboot your PC, and the automatic mouse disabling issue should be gone :).
Update: Actually you don’t have to restart the PC, just restarting the ‘laptop-mode-tools’ main service should do the trick. For that, use the below command in your Terminal window (a thanks goes to ‘eero’ — comments below, for the tip!).
sudo service laptop-mode restart
Special note : When idle, if you find the HDD to be spinning down a bit aggressively after installing LMT (default value is ’20’ seconds), then enter the below command to adjust the HDD spinning down time.
gksudo gedit /etc/laptop-mode/laptop-mode.conf
Step 2: Then search for the two text codes shown below using the text editor.
LM_AC_HD_IDLE_TIMEOUT_SECONDS
LM_BATT_HD_IDLE_TIMEOUT_SECONDS
Once you find them, replace the value ’20’ of both these options (one is for using ‘AC’ and the other for while using the battery) with the number of seconds that you want your HDD to wait before spinning down (anything between 60 to 80 seconds might be pretty decent). Then click on the ‘Save’ and the ‘Close’ buttons to finish things up.
That’s should fix that too. Good luck.
34 Comments
Thank's for this article 🙂
You are welcome 'Karim'.
Thanks a lot! Very straightforward and precise. Keep it up!
I'll try my best, thanks 'Ethan'! :).
Thanks man! Solved my problem. 🙂
No problem mate :).
Great to see a step by step writeup for this common problem. If i remember I’ll add a link to this on my Linux Mint forum signature. As it’s a common problem that doesn’t always get a straight answer.
One question:
Do the device ID’s remain static when unplugged and pluged back in, or is it dependant on the usb port?
Hi ‘MikeP’,
First of all you are welcome :).
As for your question, the ‘device ID’ is a set of numbers that are unique to every device and they are static. And the USB port has nothing to do with it. Hope this clarifies it for you.
i am not using laptop mode tools, powertop or powernap, but my internet connection using a Huawei USB modem keeps getting disconnected. How do i disable USB autosuspend so my broadband wont get disconnected repeatedly?
I’d appreciate your help on this, I’m new to Ubuntu (using Xubuntu 12.04)
Hi August,
I cannot guarantee results, but I can try.
Luckily, I too have a Huawei USB modem, I don’t use it anymore, but used to use it and worked with Ubuntu flawlessely. If it also supports reading a memory card, and you have one insert into it also, then that might be the main reason why Ubuntu is suspending it (I’ll save the details :D).
Anyhow, plugin your USB modem and enter the below command to get a list of current USB devices of your computer.
Note: For this to work, you will have to keep that USB modem plugged into that particular USB port all the time. If you change it, then this will not work.
Now, send me the output that command gives you, and I’ll try to come up with a solution (again, I cannot gurantee results though).
Great tip! Helped me! Pls publish this on Ubuntu official forums!
Thanks ‘Emil’.
/etc/init.d/laptop-mode restart is enoght, no need to reboot computer.
Thanks mate, I updated the post.
Thank you! This worked perfectly!
You’re welcome!.
Thanks for the strait tip and fix !
I sill wonder when this laptop-mode-tool package got installed. As a dependency I guess… or is it default in lubuntu 13.04 ?
You’re welcome. Coming back to the question, no, ‘laptop-mode-tools’ does not come installed by default, but as you guessed, it must had been installed as a dependency :).
Thank you! It’s very useful and very well explained 😉
You’re welcome :).
Worked for me on a : Logitech, Inc. M90/M100 Optical Mouse
Thank You for your clear instructions.
You’re welcome dan.
Amazing and simple! Thank you so much!
It worked!!! 😀
(Elementary OS Luna with ‘Laptop-Mode-Tools’)
You’re welcome Hugh :).
Excellent, both tips worked perfectly on my Asus EEEpc 1015pn
You’re welcome Juan.
Muchas Gracias!
Thank you very much.
I have exactly the same mouse.
If this problem happend with all optical mouses then we need to tell that LMT package add this bug fix from newest versions 😀
tks a lot!
german:)
You’re welcome 🙂 .
My laptop have Ubuntu 14.04 LTS. If USB optical mouse connect before ON / restart the system its work fine. But, after “ON” if connect the USB optical mouse, then it is not work. Also in windows OS working fine.
Have you tried my fix?
Gayan,
on my Ubuntu 16.04 you tweak works —
but after a restart it does not .. I have to disconnect the mouse and start/stop the service, reconnect the mouse ..
Why isn’t it working after a reboot?
Any help would be appreciated.
Hi Carlos,
First of all, I’m so sorry that it took me this long to reply to your comment (it was basically in my SPAM folder, it happens once every while). Anyhow, the answer to your question simple. With recent versions, laptop-mode-tools utility has moved the configuration file for blacklisting USB files to a different configuration file. It’s full path is: /etc/laptop-mode/conf.d/runtime-pm.conf
There you should see an entry for USB Blacklisting (you can search for something like USB to find it easily). There you should add it (make sure to uncomment it first). Again, I apologize for the delay in response.
i can ‘t find usb-autosuspend.conf file after install laptop-mode-tools
please help ;(
Hi,
It’s been moved to /etc/laptop-mode/conf.d/runtime-pm.conf file. Once opened that file, there is a section for adding the USB Blacklist function (first make sure to uncomment it).