How do I find out USB Speed from a terminal?

65,107

Solution 1

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'.)

Solution 2

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

Solution 3

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

Solution 4

This answer is a little bit off the exact question since I am using ubuntu 20.04, I haven't tested it on other versions, but I think this may also be helpful.

This way is much easier for me:

  1. Run gnome-disks in terminal, open the GUI interface. (You can also just search it in application list.)

  2. Click the disk you want to test -> Device Options -> Benchmark Disk -> Start Benchmark

enter image description here

enter image description here

This shows speed of the USB drive, not that of the USB port.

Solution 5

Try with this:

$ sudo lsusb -vvv

Then, have a look at the entries named bDeviceProtocol and bInterfaceProtocol

Share:
65,107

Related videos on Youtube

mx7
Author by

mx7

LinkedIn Profile: https://in.linkedin.com/in/raja-genupula-05205531 Endorse me If I helped you. Blog : http://thelinuxmen.blogspot.com/ Ubuntu - CentOS - Fedora - Windows - Severs - IIS - FTP - Security Thank you.

Updated on September 18, 2022

Comments

  • mx7
    mx7 over 1 year

    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 .

  • mx7
    mx7 almost 12 years
    " bInterfaceProtocol 80 Bulk-Only " " bDeviceProtocol 0 " means what ? But this answer not suitable to My Question .Thank you ,:)
  • jap1968
    jap1968 almost 12 years
    Did you use the -vvv option? In my computer, there is a description associated to the 0 value: "0 Full speed (or root) hub"
  • mx7
    mx7 almost 12 years
  • jap1968
    jap1968 almost 12 years
    You are right. This information seems to appear only on some devices.
  • Cerin
    Cerin about 9 years
    @Raja, Run sudo lsusb -vvv |grep -i -B5 -A5 bDeviceProtocol. Then look at the entries listed as bDeviceClass Hub.
  • Melab
    Melab about 7 years
    Is there anyway to correlate that information with a device node?
  • Elder Geek
    Elder Geek about 7 years
    @Melab Seems obvious in most cases given the output of commands like lsblk and the content of files like [etc/mtab] If you have a new question, please feel free to ask using the [Ask Question button ](askubuntu.com/questions/ask) in the upper right corner of the page.
  • mc0e
    mc0e about 7 years
    I guess this anticipated the reason for the question, but it didn't answer the question as posed.
  • Elder Geek
    Elder Geek over 6 years
    @Flatron I'm Always eager to help!
  • AjayKumarBasuthkar
    AjayKumarBasuthkar over 4 years
    This approach appears to give measurable & actual run-time results.