zoukankan      html  css  js  c++  java
  • Power OFF and ON USB device in linux (ubuntu)

    Power OFF and ON USB device in linux (ubuntu)

    http://loginroot.com/power-off-and-on-usb-device-in-linux-ubuntu/

    There are two methods of doing this. So first method is for kernels after 2.6.32, and second for older ones.

    To view kernel version, simply enter:

    find Your USB device, no mather what it is USB flash drive, Yubikey, USB disk drive:


    Our target is:

    Which is located at 2-1.1 (tree part where device 5 is located)
    First method (newer kernel)

    To turn it off simply echo address:

    here is result from syslog:

    Unfortunately this device was still visible in lsusb, so I turned off whole usb hub there (2-1), and voila, usb device gone.

    To enable it, echo same address to “bind” part, for example:

    Second method (older kernel)
    You need to go to devices:

    Addressess will be listed similar:

    So go to in our example 2-1.1/power (full path /sys/bus/usb/devices2-1.1/power)

    to turn off device:

    to turn on:

    Comments (7)

    1. AnonymousSeptember 28, 2014 at 4:01 pm

      ~ $ sudo echo ‘1-1.2’ > /sys/bus/usb/drivers/usb/unbind
      -bash: /sys/bus/usb/drivers/usb/unbind: Permission denied

      Reply ↓
    2. NiekoNovember 4, 2014 at 11:59 am

      Thanks, finally got it working! :)

      Anonymous: your command executes “echo ‘1-1.2′” under sudo, and then tries to write that to /sys/bus/usb/drivers/usb/unbind as the normal user again. Try this: echo ‘1-1.2″ | sudo tee /sys/bus/usb/drivers/usb/unbind

      Reply ↓
    3. SantosNovember 8, 2014 at 2:25 am

      You could also use a switchable USB hub.

      Something like this https://www.yepkit.com/products/ykush

      but it’s more expensive :)

      Reply ↓
      1. nsc(Post author)November 8, 2014 at 9:47 am

        Smart way of leaving a backlink.
        I encourage doing opensource projects :)

        Usually the budget depends on what are the requirements. For a simple “faulty” usb emergency device reset I would use my way (I wouldn’t expect something to break, would I?).

        But for day to day planned switch off/on I’d consider such device.
        Thanks for sharing Your product.
        That’s pretty useful thing, it should have more reliable switching capability and it’s more powerful than a server usb port.

        You should consider making a bigger hub, as it seems to be possible to use it as a powersource for usb devices (2Amps of current).
        For example external usb 2.5 hdd would already take 2 ports, leaving only one free.
        Or make an usb controlled power source switcher with relays, it would perfectly go as a combo with this usb hub device :)

        Reply ↓
        1. SantosNovember 8, 2014 at 1:58 pm

          Fully agree with you, the best approach depends of the requirements.

          Those are cool ideas for improving the product.

          Cheers

          Reply ↓
    4. Pingback: » Linux: Turning off power to usb port. Or turn off power to entire usb subsystem

    5. Pingback: Raspberry Pi + L-02C でバッチリ安定する多機能 LTE ルータをつくったメモ – 怠惰の形而上学

    Leave a Reply

  • 相关阅读:
    Class类与Java反射《java从入门到精通》第十六章
    maven配置,Java环境变量配置,电脑系统重装之后需要环境配置(大概每年都要一次重装系统)
    Docker部分--尚硅谷2020微服务分布式电商项目《谷粒商城》(没给学习文档,在这做笔记)
    centOS7下载安装(阿里云镜像下载,速度10M/s),(好用免费的工具VirtualBox,FinalShell比xshell更舒服)
    从程序员到项目经理:为什么要当项目经理
    状态图(Statechart Diagram)
    ServiceLoader实现原理
    Java8 lambda表达式10个示例
    Java8函数之旅(四) --四大函数接口
    Java8特性详解 lambda表达式 Stream
  • 原文地址:https://www.cnblogs.com/LiuYanYGZ/p/7656203.html
Copyright © 2011-2022 走看看