我正在使用 Ubuntu 12.04。我想知道是否有任何方法可以通过终端观察 USB 的写入和读取速度。
答案1
我对此很好奇,因为我有一个 SATA 3 SSD,想用它来处理一些视频文件(以使 i/o 等待时间保持在最低限度),但我的系统上只有 SATA 2(3Gbps)端口可用,还有 USB3 端口可用。
您可以使用以下命令确定每个 USB 端口的理论最大速度sudo lsusb -vvv |grep -i -B5 -A5 bcdUSB
bcdUSB 行返回端口的 USB 版本。
来自我的一个系统的一个例子:
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
或者使用快捷简单的替代方法lsusb -t
,提供如下输出:
/: 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
由于 USB3 提供的 5 Gbps 速度与 SATA 3 的额定 6 Gbps 速度非常接近,因此我决定将驱动器连接到那里Bus 004 Device 002
(通过 Asmedia USB3toSATA 适配器)。结果非常令人满意。
资料来源:本页
实验
答案2
该pv
工具允许您查看流经它的数据的吞吐量。安装软件包后,您可以运行以下命令来查看写入速率:
$ cat /dev/zero | pv > /media/some_usb/tmp123
203.1MiB 0:00:02 [100.2MiB/s] [ <=> ]
对于读取,使用新创建的文件执行相反的操作tmp123
:
$ cat /media/some_usb/tmp123 | pv > /dev/null
答案3
您可以使用它rsync
来估计传输速度,但具体速度取决于传输的是小文件还是大文件,以及目标是慢速闪存驱动器还是快速外部硬盘。例如:
rsync -avviu ~/Videos /media/Mik2
sent 874419803 bytes received 149 bytes 4427442.79 bytes/sec
total size is 874312527 speedup is 1.00
(此外,如果您打开tail -f /var/log/kern.log
然后连接设备,您可以查看它是否正在为支持 USB 2 速度的 ehci(增强型主机控制器接口)进行设置。例如,内核日志应显示“新的高速 USB 设备...使用 ehci_hcd”。)
答案4
尝试一下这个:
$ sudo lsusb -vvv
然后,查看名为设备协议和接口协议