linux 测试usb带宽

1,925 阅读2分钟
  • 速率(最高)
    • usb 2.0
      480Mbps 即 60MB/s
    • usb 3.0
      5Gbps
  • lsusb
    root@NanoPi-M4v2:~# lsusb
    Bus 006 Device 007: ID 2e03:0001
    Bus 006 Device 006: ID 2109:0817 VIA Labs, Inc.
    Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 005 Device 043: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
    Bus 005 Device 042: ID c0f4:01e0
    Bus 005 Device 041: ID 2109:2817 VIA Labs, Inc.
    Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    
    • 3.0 表示有 usb 3.0
  • lsusb -tv
    root@NanoPi-M4v2:~# lsusb -tv
    /:  Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
        |__ Port 1: Dev 6, If 0, Class=Hub, Driver=hub/4p, 5000M
            |__ Port 4: Dev 7, If 0, Class=Miscellaneous Device, Driver=, 5000M
            |__ Port 4: Dev 7, If 1, Class=Miscellaneous Device, Driver=, 5000M
            |__ Port 4: Dev 7, If 2, Class=Miscellaneous Device, Driver=, 5000M
    /:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
        |__ Port 1: Dev 41, If 0, Class=Hub, Driver=hub/4p, 480M
            |__ Port 2: Dev 42, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 2: Dev 42, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
            |__ Port 3: Dev 43, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    /:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/1p, 12M
    /:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
    /:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/1p, 12M
    /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
    
    • 12M 意味着 USB 1.0 / 1.1的速率是 12Mbit/s
    • 480M 意味着 USB 2.0的速率是 480Mbit/s
  • 测试带宽(用个u盘)
    # 切到u盘目录
    cd /media/pi/ZHOUQINAN  
    # 测试写入
    dd if=/dev/zero of=./largefile bs=8k count=10
    # 测试读取  
    sudo sh -c "sync && echo 3 > /proc/sys/vm/drop_caches"     
    dd if=./largefile of=/dev/null bs=8k