- How do I find out USB Speed from a terminal?
- 5 Answers 5
- Test read/write speed of usb and ssd drives with dd command on Linux
- Test Method — The dd command
- SSD Drive
- USB Pen drives
- Sony 4GB USB 2.0 Drive
- Strontium USB 2.0 16GB Pen drive
- SanDisk Cruzer Blade 32GB USB Flash Drive
- Sandisk Ultra CZ48 USB 3.0 16 GB Pen Drive
- Motherboard USB Port vs CPU case USB Port — Big Difference!
- Resources
- 6 Comments
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 .
5 Answers 5
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, Driver=xhci_hcd/4p, 5000M |__ Port 4: Dev 2, If 0, Storage, Driver=usb-storage, 5000M /: Bus 03.Port 1: Dev 1, Driver=xhci_hcd/4p, 480M /: Bus 02.Port 1: Dev 1, Driver=ehci-pci/2p, 480M |__ Port 1: Dev 2, If 0, Driver=hub/8p, 480M /: Bus 01.Port 1: Dev 1, Driver=ehci-pci/2p, 480M |__ Port 1: Dev 2, If 0, Driver=hub/6p, 480M |__ Port 6: Dev 3, If 0, Interface Device, Driver=usbhid, 1.5M |__ Port 6: Dev 3, If 1, 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.
Test read/write speed of usb and ssd drives with dd command on Linux
The speed of a drive is measured in terms of how much data it can read or write in unit time. The dd command is a simple command line tool that can be used to read and write arbitrary blocks of data to a drive and measure the speed at which the data transfer took place.
In this post we shall use the dd command to test and read and write speed of usb and ssd drives using the dd command.
The data transfer speed does not depend solely on the drive, but also on the interface it is connected to. For example a usb 2.0 port has a maximum operational speed limit of 35 Mbytes/s, so even if you were to plug a high speed usb 3 pen drive into a usb 2 port, the speed would be capped to the lower limit.
The same applies to SSD. SSD connect via SATA ports which have different versions. Sata 2.0 has a maximum theoretical speed limit of 3Gbits/s which is roughly 375 Mbytes/s. Whereas Sata 3.0 supports twice that speed.
Test Method — The dd command
Mount the drive and navigate into it from the terminal. Then use the dd command to first write a file using fixed sized blocks. Then read the same file out using the same block site.
The general syntax of the dd command looks like this
dd if=path/to/input_file of=/path/to/output_file bs=block_size count=number_of_blocks
When writing to the drive, we simply read from /dev/zero which is a source of infinite useless bytes. And when read from the drive, we read the file written earlier and send it to /dev/null which is nowhere. In the whole process, dd keeps track of the speed with which the transfer takes place and reports it.
SSD Drive
The SSD that we are using is a «Samsung Evo 120GB» ssd. It is a beginner level ssd that comes within a decent budget and is also my first SSD. It is also one of the best performing ssds, in the market.
In this test the ssd is connected to a sata 2.0 port.
Lets first write to the ssd
$ dd if=/dev/zero of=./largefile bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 4.82364 s, 223 MB/s
Block size is actually quite large. You can try with smaller sizes like 64k or even 4k.
Now read back the same file. However, first clear the memory cache to ensure that the file is actually read from drive.
Run the following command to clear the memory cache
$ sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"
$ dd if=./largefile of=/dev/null bs=4k 165118+0 records in 165118+0 records out 676323328 bytes (676 MB) copied, 3.0114 s, 225 MB/s
The Arch Linux wiki has a page full of information about the read/write speed of various SSDs from different vendors like Intel, Samsung, Sandisk etc. Check it out at the following url.
USB Pen drives
In this test we shall measure the read and write speed of ordinary usb/pen drives. The drives are plugged to standard usb 2 ports. The first one is a sony 4gb usb drive and the second is a strontium 16gb drive.
First plug the drive into the port and mount it, so that it is readable. Then navigate into the mount directory from the command line.
Sony 4GB USB 2.0 Drive
In this test, the dd command is used to write 10,000 chunks of 8 Kbyte each to a single file on the drive.
# dd if=/dev/zero of=./largefile bs=8k count=10000 10000+0 records in 10000+0 records out 81920000 bytes (82 MB) copied, 11.0626 s, 7.4 MB/s
So the write speed is around 7.5 MBytes/s. This is a low figure.
The same file is read back to test the read speed. Run the following command to clear the memory cache
$ sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"
Now read the file using the dd command
# dd if=./largefile of=/dev/null bs=8k 8000+0 records in 8000+0 records out 65536000 bytes (66 MB) copied, 2.65218 s, 24.7 MB/s
The read speed comes out around 25 Mbytes/s which is a more or less the standard for cheap usb drives.
USB 2.0 has a theoretical maximum signaling rate of 480 Mbits/s or 60 Mbytes/s. However due to various constraints the maximum throughput is restricted to around 280 Mbit/s or 35 Mbytes/s. Beyond this the actual speed achieved depends on the quality of the pen drives and other factors too.
And the above usb drive was plugged inside a USB 2.0 port and it achieved a read speed of 24.7 Mbytes/s which is not very bad. But the write speed lags much behind
Strontium USB 2.0 16GB Pen drive
Now lets do the same test with a Strontium 16gb drive. Strontium is another very cheapy brand, although usb drives are reliable.
# dd if=/dev/zero of=./largefile bs=64k count=1000 1000+0 records in 1000+0 records out 65536000 bytes (66 MB) copied, 8.3834 s, 7.8 MB/s
Strontium 16gb read speed
# sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches" # dd if=./largefile of=/dev/null bs=8k 8000+0 records in 8000+0 records out 65536000 bytes (66 MB) copied, 2.90366 s, 22.6 MB/s
The read speed is lower than the Sony drive.
SanDisk Cruzer Blade 32GB USB Flash Drive
This is a popular cheap USB 2.0 drive available on amazon.in
Lets test its read and write speed.
Read Speed — CPU Case USB Port
Reading a simple iso file present on the drive using the dd command.
$ dd if=./ubuntu.iso of=/dev/null bs=8k 90355+1 records in 90355+1 records out 740195568 bytes (740 MB, 706 MiB) copied, 27.0821 s, 27.3 MB/s
The read speed is about 27.3 MB/s
Write Speed — CPU Case USB Port
Now lets test the write speed
$ dd if=~/ubuntu-16.04.5-desktop-i386.iso of=./ubuntu-16.04.5-desktop-i386.iso bs=1M 1587+1 records in 1587+1 records out 1664614400 bytes (1.7 GB, 1.6 GiB) copied, 374.269 s, 4.4 MB/s
The write speed is quite low at 4.4 MB/s.
Sandisk Ultra CZ48 USB 3.0 16 GB Pen Drive
Read speed — Motherboard USB Port
$ dd if=./backup.rar of=/dev/null bs=8k 51108+1 records in 51108+1 records out 418678907 bytes (419 MB, 399 MiB) copied, 4.82621 s, 86.8 MB/s
This one has a decent read speed.
Write speed — Motherboard USB Port
Lets copy the same ubuntu iso file from disk to the usb drive
$ dd if=~/ubuntu-16.04.5-desktop-i386.iso of=./ubuntu-16.04.5-desktop-i386.iso bs=1M 1587+1 records in 1587+1 records out 1664614400 bytes (1.7 GB, 1.6 GiB) copied, 128.624 s, 12.9 MB/s
The write speed this time is better than the earlier Sandisk USB 2.0 drive.
Motherboard USB Port vs CPU case USB Port — Big Difference!
The speed also depends on whether you connect the USB drive to the front ports on your cpu case or directly on the motherboard usb ports. As you might be able to guess already, the speed on motherboard usb ports is significantly higher.
Front of CPU Case — Sony USB 3.1 Gen 16GB — Read Speed
$ dd if=./ubuntu.iso of=/dev/null bs=8k 90355+1 records in 90355+1 records out 740195568 bytes (740 MB, 706 MiB) copied, 17.6587 s, 41.9 MB/s
Motherboard USB Port — Sony USB 3.1 Gen 16GB — Read Speed
$ dd if=./ubuntu.iso of=/dev/null bs=8k 90355+1 records in 90355+1 records out 740195568 bytes (740 MB, 706 MiB) copied, 6.11666 s, 121 MB/s
So the motherboard usb port speed is almost 3X higher than the cpu case usb ports. So if you are planning to do heavy data transfer, then it would be a better idea to make the extra effort of connecting the usb drive to the back of your CPU.
Motherboard USB Port — Sony USB 3.1 Gen 16GB — Write Speed
$ dd if=~/ubuntu-16.04.5-desktop-i386.iso of=./ubuntu-16.04.5-desktop-i386.iso bs=1M 1587+1 records in 1587+1 records out 1664614400 bytes (1.7 GB, 1.6 GiB) copied, 176.581 s, 9.4 MB/s
The write speed of this Sony USB 3.1 drive is lower than the Sandisk Ultra USB 3.0 Drive. Both of them were tested on motherboard usb ports.
Resources
A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected] .
6 Comments
- kokozcal March 4, 2022 at 10:10 am Usb 3: dd if=/dev/zero of=largefile bs=8k count=10000
10000+0 records in
10000+0 records out
81920000 bytes (82 MB, 78 MiB) copied, 0.0344905 s, 2.4 GB/s Bus 004 Device 002: ID 0781:5583 SanDisk Corp. Ultra Fit