I have a nice little USB light which has no off switch, it is 'on' for the duration of being plugged in.

My question is, is there a way of disabling the USB port so as to turn off the light while it is still plugged in? Preferably, this could be done from the command line, but if it's possible at all that would be really cool regardless. I use Mac and Linux, but am interested to learn if this is possible in any OS, or if physical hardware prevents usage like this.

  • I'm not sure what you mean... do you mean hard drive? How would the hard drive impact the ability to toggle power to the USB port? – Jeff Welling Jul 24 '11 at 14:04
  • 1
    If you want to disable the whole thing, use a device manager type thing (dont know what it is in mc or linux). If you just want to disable the light, it depends o the hardware (USB drive) involved. – soandos Jul 24 '11 at 14:07
  • I only know how to do this in Windows. Are you interested in the Windows way? – Larssend Jul 24 '11 at 16:13
  • Well I don't think I'd have included the sentence at the end of the question otherwise.. ;) – Jeff Welling Jul 24 '11 at 22:41
  • If it shows up in your dev/ folder, try unmounting the device (e.g. unmount /dev/usbdev0 or something similar. – Breakthrough Jul 25 '11 at 0:27

In most cases, USB accessories like fans and lights aren't real USB devices - they just want a little bit of 5v power.

The way USB works for real devices is that they get a little bit of power to start, enough for them to turn on. Then they enumerate with the USB controller and request more power.

Since these fake USB devices aren't actually talking to the computer at all, the only way to turn it off would be to completely unpower that USB port, which as far as I know there is not usually a way to do in software.

  • 1
    Actually the USB 2.0 standard specifies that USB hubs should support either Ganged Power Switching, or even Per Port Switching. Most USB 2.0 chipsets seems to support this. Except that hardly any USB hubs actually have it wired up. There are a few that has but I cannot find any definite list. – Joakim Söderberg Nov 25 '14 at 13:58

I haven't actually tried this myself, but from the research I have done on the topic (to accomplish exactly the same thing as you), you will need:

  • A USB hub which supports "per-port power switching" - not many support this
  • A utility to actually toggle the power

Take a look at http://www.gniibe.org/development/ac-power-control-by-USB-hub/index, he is doing similar things, and includes some background on the topic, a list of supported hubs as well as the C source code to build the utility.

I couldn't find any of the USB hubs he had mentioned in the US, and after getting in touch with me confirmed that the D-Link DUB-H7 will work - you can get it on Amazon for example.

I haven't yet found a way to do this on Windows, but it looks like you're mostly interest in Linux anyways.

  • Awesome answer! The only reason I accepted the other answer was because I was specifically interested in the possibility of disabling it purely from software without additional hardware, but I love how far you took this, it sounds like there's a lot of potential with that DLink DUB-H7 device hehe. Has lots of weekend-project potential :) – Jeff Welling Mar 27 '12 at 16:39
  • I have a D-Link DUB-H4, which doesn't (afaik) support switching, though it presents as a 0451:2046 Texas Instruments, Inc. TUSB2046 Hub and the datasheet for the TUSB2046 does specify the chip is capable of per-port power control. That's not the same as the HUB supporting it though. Also, the link at gniibe.org is no longer active, I have mirrored the .c code at github.com/sfinktah/ac-power-control-by-USB-hub - original article at web.archive.org/web/20150424033015/http://www.gniibe.org/… – Orwellophile Sep 1 at 12:35
  • edit: The D-Link DUB-H4 does support per-port power switching. – Orwellophile Sep 2 at 8:48

7-port USB hub D-Link DUB_H7 revision 2 (black) does NOT have Per-port power switching, it only supports Ganged power switching.

#lsusb -v

output shows twice a 4-port hub, here is the output for Hub Descriptor:

Hub Descriptor:
  bLength               9
  bDescriptorType      41
  nNbrPorts             4
  wHubCharacteristic 0x00e0
    Ganged power switching
    Ganged overcurrent protection
    TT think time 32 FS bits
    Port indicators
  bPwrOn2PwrGood       50 * 2 milli seconds
  bHubContrCurrent    100 milli Ampere
  DeviceRemovable    0x00
  PortPwrCtrlMask    0xff
 Hub Port Status:
   Port 1: 0000.0100 power
   Port 2: 0000.0100 power
   Port 3: 0000.0100 power
   Port 4: 0000.0100 power
  • 1
    So how do I turn off power to all ports in Linux? – Joakim Söderberg Nov 25 '14 at 9:38

Try using http://www.nirsoft.net/utils/usbdeview.zip. This executable displays all USB devices attached to your computer and allows you to disconnect them individually as required.

As noted from the read me:

USBDeview is a small utility that lists all USB devices that currently connected to your computer, as well as all USB devices that you previously used. For each USB device, extended information is displayed: Device name/description, device type, serial number (for mass storage devices), the date/time that device was added, VendorID, ProductID, and more... USBDeview also allows you to uninstall USB devices that you previously used, and disconnect USB devices that are currently connected to your computer. You can also use USBDeview on a remote computer, as long as you login to that computer with admin user.

  • 2
    You should mention this program is for use on Windows. – Joakim Söderberg Nov 25 '14 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.