0

I think I'm missing something on this case. I wanna disable all the USB ports of a machine (to avoid somebody plugs a mouse or a keyboard and ruin everything in it) As I saw on other topics, for Kernel above 2.6.38, I have to use this :

echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend_delay_ms" 
echo "auto" > "/sys/bus/usb/devices/usbX/power/control"

The script is technically working, settings are good in those files but my ports are still working as well. What am I missing ?

Thank you !

AnouarZ
  • 1,087
  • 8
  • 23
  • Well usbX was just for the example, i made one line for usb1, one line for usb 2, one line for usb3. – Antoine VEYLON Nov 10 '17 at 10:55
  • are you using the device id, for example be sure that the device "id" you are using is correct : `dmesg | grep "usb"` and use the number after "usb", for example: `usb 2-4.4: SerialNumber: A0848020` you will use: `/sys/bus/usb/devices/2-4.4/power/....` And be sure that the device is not in use – AnouarZ Nov 10 '17 at 10:59
  • check the answers here, there is also a way to disable at once https://stackoverflow.com/questions/4702216/controlling-a-usb-power-supply-on-off-with-linux/12675749#12675749 – AnouarZ Nov 10 '17 at 11:05
  • I'm very close to find it, thank you very much ! – Antoine VEYLON Nov 10 '17 at 13:03
  • Wait a minute, I can't see the port anymore when i disconnect what was on it. – Antoine VEYLON Nov 10 '17 at 13:41
  • what works for you, what was the cmd you used to disconnect the port ? – AnouarZ Nov 10 '17 at 14:08
  • it finally still doesnt work rofl. I used what u told me, I used the ID of the device. But anyway the problem is that I have to use it in a script without any devices connected on the machine. And when i hav no devices connected i cant have access to the ports ... It says me that the path isn't valid. – Antoine VEYLON Nov 10 '17 at 15:19

1 Answers1

1

Are you using the device id? for example be sure that the device "id" you are using is correct : dmesg | grep "usb" and use the number after "usb", for example: usb 2-4.4: SerialNumber: A0848020 you will use: /sys/bus/usb/devices/2-4.4/power/.... And be sure that the device is not in use

The autosuspend feature is here merely to enable idling devices to enter a low-power state (where it might appear turned off), only to be resumed later when it's needed, either by the host or some external event. That happens (or should happen) automatically. The port itself is actually never truly turned off.

However if you want You can disable USB storage device, where only root users can only enable it. refer to this link

Also check this user friendly tool PowerTOP

Check as well this way with BIND keep in mind as well bind/unbind doesn't poweroff the USB port regardless the chipset. The device still gets power.

AnouarZ
  • 1,087
  • 8
  • 23