15

I have a lot of ports on my computer. I would like to turn off one of them, so when I connect my phone to that port, it only charges. I do want my phone to work with my computer in some occasions though, so I hope other ports are not affected.

I would just like to know how possible this is.

4
  • Possible.. But some hacks are needed to do this..
    – Yuvaraj V
    Mar 9, 2016 at 4:45
  • 2
    Hardware solution: Buy a male to female USB plug and cut/isolate/remove the center lines.
    – 0x2b3bfa0
    Mar 18, 2016 at 10:45
  • @Helio Then why do not I just buy a USB power station...?
    – bfrguci
    Mar 18, 2016 at 16:39
  • 1
    You can purchase USB cables that provide charge only. The data leads aren't wired. Oct 19, 2019 at 20:52

3 Answers 3

6

First, run lsusb.

The output should be like:

Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 2232:1020  
Bus 002 Device 009: ID 0bc2:a013 Seagate RSS LLC 
Bus 002 Device 003: ID 0a5c:219c Broadcom Corp. 

In the output, find the device number of the port to be disabled. For example, the Seagate drive in the example has Device 009 - that is its device number. Then the id will be usb[device number] - such as usb9

Then, disable USB wake-up (do this only once):

Be sure to replace X in usbX with the device number.

echo disabled | sudo tee /sys/bus/usb/devices/usbX/power/wakeup 

Then turn it off:

echo suspend | sudo tee /sys/bus/usb/devices/usbX/power/level

Undo this:

echo enabled | sudo tee /sys/bus/usb/devices/usbX/power/wakeup
echo on | sudo tee /sys/bus/usb/devices/usbX/power/level
7
  • 2
    Attempted the above commands and returned... tee: /sys/bus/usb/devices/usb11/power/wakeup: No such file or directory disabled
    – Seek Truth
    Jan 3, 2018 at 4:05
  • found very helpful information in this thread USB Port Power
    – Seek Truth
    Jan 3, 2018 at 5:31
  • 4
    I get tee: /sys/bus/usb/devices/usbX/power/level: Invalid argument when echo suspend, while echo on no such error.
    – 林果皞
    May 13, 2019 at 20:08
  • @林果皞 Did you replace the X in usbX?
    – user423626
    Jun 12, 2019 at 11:47
  • 2
    Looks like the write error: Invalid argument is because the suspend option is no longer supported, since kernel 2.6.32. See superuser.com/a/371254.
    – arjan
    Jun 3, 2022 at 14:13
3

Here is a plug & play (literally) option:

charge only usb dongle

It's a good idea if you want to avoid pop-up messages and file browsers every time you plug your phone in for charging only.

This is also more fool-proof than the software approach because software that turns off the port for data can be reversed by software that turns it back on. Or it might be reinitialized during suspend/resume or some other process you didn't foresee.

-1

I cut a piece of tape to fit the inner two data pins, and pushed it into place with a toothpick.

This is on my phone charging base so I shouldn't have to redo this tape job.

No more annoying popups, which were getting ridiculous. The last time I plugged in my phone I got 9 different popup windows, all of which had different error messages.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .