How do I find out USB Speed from a terminal?
I am using Ubuntu 12.04 . I am here to know is there any way to observe Writing & Reading Speed of the USB through the terminal .
The pv
tool allows you to view the throughput of the data flowing through it. After installing the package, you could run a command like the following to see the write rate:
$ cat /dev/zero | pv > /media/some_usb/tmp123
203.1MiB 0:00:02 [100.2MiB/s] [ <=> ]
For reading, perform the opposite operation using the newly-created tmp123
file:
$ cat /media/some_usb/tmp123 | pv > /dev/null
I was curious about this as I had a SATA 3 SSD I wanted to use for processing some video files (to keep i/o waits at a minimum) but I had only SATA 2 (3Gbps) ports available on the system, but also a USB3 port available.
You can determine the theoretical maximum speed of the port for each USB port with the command sudo lsusb -vvv |grep -i -B5 -A5 bcdUSB
The bcdUSB line returns the USB version of the port.
An example from one of my systems:
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 1 Single TT
bMaxPacketSize0 64
idVendor 0x8087 Intel Corp.
--
Port 7: 0000.0100 power
Port 8: 0000.0100 power
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 0 Full speed (or root) hub
bMaxPacketSize0 64
bNumConfigurations 1
--
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 0 Full speed (or root) hub
bMaxPacketSize0 64
idVendor 0x1d6b Linux Foundation
--
Bus 001 Device 003: ID 10d5:5a08 Uni Class Technology Co., Ltd
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x10d5 Uni Class Technology Co., Ltd
--
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 1 Single TT
bMaxPacketSize0 64
idVendor 0x8087 Intel Corp.
--
Port 5: 0000.0100 power
Port 6: 0000.0303 lowspeed power enable connect
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 0 Full speed (or root) hub
bMaxPacketSize0 64
bNumConfigurations 1
--
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 0 Full speed (or root) hub
bMaxPacketSize0 64
idVendor 0x1d6b Linux Foundation
--
Bus 004 Device 002: ID 174c:5106 ASMedia Technology Inc. Transcend StoreJet 25M3
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 3.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 9
idVendor 0x174c ASMedia Technology Inc.
--
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 3.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 3
bMaxPacketSize0 9
idVendor 0x1d6b Linux Foundation
--
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 9 Hub
bDeviceSubClass 0 Unused
bDeviceProtocol 1 Single TT
bMaxPacketSize0 64
idVendor 0x1d6b Linux Foundation
Or the quick and easy alternative of lsusb -t
which provides output like this:
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
|__ Port 4: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
/: 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 6: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 6: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
Since the 5 Gbps available via USB3 was far closer to the 6 Gbps that SATA 3 is rated at I decided to connect the drive there on Bus 004 Device 002
(via Asmedia USB3toSATA adapter). The results were quite satisfying.
Sources: This page
Experimentation
https://en.wikipedia.org/wiki/USB
https://en.wikipedia.org/wiki/Serial_ATA How to find USB hub speed
You can use rsync
to give an approximation of your transfer speed, although it will vary depending on whether small or large files are being transferred and whether the destination is a slow flash drive or a fast external hard disk. For example:
rsync -avviu ~/Videos /media/Mik2
sent 874419803 bytes received 149 bytes 4427442.79 bytes/sec
total size is 874312527 speedup is 1.00
(Also, if you open tail -f /var/log/kern.log
and then connect your device you can see whether it is being set up for ehci (enhanced host controller interface), which supports USB 2 speeds. For example, the kernel log should state 'new high-speed USB device...using ehci_hcd'.)