22

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 .

5 Answers 5

19

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

3
  • Is there anyway to correlate that information with a device node?
    – Melab
    Apr 19, 2017 at 1:37
  • @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.
    – Elder Geek
    Apr 19, 2017 at 13:02
  • 1
    @Flatron I'm Always eager to help!
    – Elder Geek
    Nov 14, 2017 at 20:53
19

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
1
  • This approach appears to give measurable & actual run-time results. Sep 19, 2019 at 13:35
7

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

1
  • I guess this anticipated the reason for the question, but it didn't answer the question as posed.
    – mc0e
    May 16, 2017 at 3:04
3

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.

2

Try with this:

$ sudo lsusb -vvv

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

5
  • 2
    " bInterfaceProtocol 80 Bulk-Only " " bDeviceProtocol 0 " means what ? But this answer not suitable to My Question .Thank you ,:)
    – rɑːdʒɑ
    Jul 11, 2012 at 16:40
  • Did you use the -vvv option? In my computer, there is a description associated to the 0 value: "0 Full speed (or root) hub"
    – jap1968
    Jul 11, 2012 at 16:44
  • pastebin.com/z2ESbyZL
    – rɑːdʒɑ
    Jul 11, 2012 at 16:46
  • You are right. This information seems to appear only on some devices.
    – jap1968
    Jul 11, 2012 at 16:54
  • 1
    @Raja, Run sudo lsusb -vvv |grep -i -B5 -A5 bDeviceProtocol. Then look at the entries listed as bDeviceClass Hub.
    – Cerin
    Mar 17, 2015 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.