Skip to content

loblab/plug-usb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Software connect/disconnect USB devices

Plug in/out USB devices by software.

  • Platform: Linux (tested on Debian 9.x, kernel 4.9.x)
  • Ver: 0.1
  • Updated: 5/26/2018
  • Created: 4/26/2018
  • Author: loblab

Why?

I use a USB HDD holder (supports 4 disks) connected with a Linux server for daily backup. It is not power saving in idle (21 watt with 2 disks installed). If unplug the device, the power consumption falls down to 6 watt. So we can disconnect the device by software to save power.

Usage

  1. Use lsusb to find VID/PID of your device;
  2. Run "./plug-usb.sh out VID PID" to unplug the device;
  3. Run "./plug-usb.sh in VID PID" to plug the device again.

You may need to add "./plug-usb.sh out ..." to your startup script to unplug the device by default.

How?

Write device ID string to unbind & bind file.

echo '2-1.2' > /sys/bus/usb/drivers/usb/unbind
echo '2-1.2' > /sys/bus/usb/drivers/usb/bind

The number may change after reboot, so I search it by VID & PID in sub directories of /sys/bus/usb/drivers/usb.

References

About

Software plug/unplug USB devices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages