最後更新: 2021-09-19
目錄
- 情況 1 - USB Disk
- 情況 2 - 同一個 Hub 上有多個 Device
情況 1
Step 0: 查看 USB Disk Info
lsusb
Bus 004 Device 002: ID 152d:9561 JMicron Technology Corp. / JMicron USA Technology Corp. JMS56x Series ...
lsusb -t
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=uas, 5000M ...
Step 1: Verify hub info.
cd /sys/bus/usb/drivers/usb
ls -l
# Bus 04 的 Port 1 4-1 -> ../../../../devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb4/4-1/
cat 4-1/{idVendor,idProduct}
152d
9561
Step 2: To turn off power on all USB ports of a hub
# bind – enable the Root Hub
# unbind – disable the Root Hub
# 在 /sys/bus/usb/drivers/usb 內
# Format: Bus:Port
echo "4-1" > unbind
Step 3: To turn power back on - you may bind it back using
echo "4-1" > bind
情況 2 - 同一個 Hub 上有多個 Device
# 查看情況
lsusb -t
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M |__ Port 4: Dev 8, If 0, Class=Mass Storage, Driver=uas, 480M |__ Port 6: Dev 9, If 0, Class=Hub, Driver=hub/6p, 480M
ls /sys/bus/usb/drivers/usb
lrwxrwxrwx 1 root root 0 Jun 9 13:25 1-1 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1 lrwxrwxrwx 1 root root 0 Jun 9 13:25 1-1.4 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4 lrwxrwxrwx 1 root root 0 Jun 9 13:25 1-1.6 -> ../../../../devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.6
reset Hub 上其中一個 device
cd /sys/bus/usb/drivers/usb
# "1-1.4" 的 soft-link 會消失
echo "1-1.4" > unbind
整個 Hub reset
# "1-1", "1-1.4", "1-1.6" 的 soft-link 會消失
echo "1-1" > unbind