# USB 3 ports



## balanga (Jan 10, 2018)

I have a Thinkpad X220 which has a single USB 3.0 port but it doesn't seem to work any faster than the two USB 2 ports which it also has.

How can I tell whether it is faster than USB 2?


----------



## ronaldlees (Jan 10, 2018)

You could use the dd utility to copy a largish file to a target storage device on each port, and look at the time taken to copy them.  You'd need to have a storage device with better speed than USB2 in order to see the difference - an external SSD drive perhaps.


----------



## Minbari (Jan 10, 2018)

To verify if the usb 3.0 is recognised by OS run: `pciconf -lv |grep xhci`. xhci is the usb 3.0 driver.
To see if usb3.0 module is in the kernel:  `kldstat -v | grep -i xhci`.

As for the transfer speed that depend on the usb flash drive type. So if the usb flash drive is usb 2.0 it will work as a usb 2.0 even if it's in the usb 3.0 port.


----------



## balanga (Jan 11, 2018)

If I have a USB 3.0 microsd card reader, what sort of microsd card should I use, and can I identify what sort of card I'm using? - not by what it says on the card but by what the os is able to tell me about the card.


----------



## balanga (Jan 11, 2018)

ronaldlees said:


> You could use the dd utility to copy a largish file to a target storage device on each port, and look at the time taken to copy them.  You'd need to have a storage device with better speed than USB2 in order to see the difference - an external SSD drive perhaps.



i was thinking of copy a 1GB file from a ram disk.... except I don't know how to create a ram disk


----------



## leebrown66 (Jan 12, 2018)

Don't copy a file, copy from /dev/zero, ie, for a 1GB file:

```
dd if=/dev/zero of=/dev/da99 bs=1m count=1k
```
Replace *da99* with your appropriately named device.


----------



## balanga (Jan 12, 2018)

leebrown66 said:


> Don't copy a file, copy from /dev/zero, ie, for a 1GB file:
> 
> ```
> dd if=/dev/zero of=/dev/da99 bs=1m count=1k
> ...



If I use da0 - the device I booted from, don't I overwrite the first 1GB of the device with zeroes?

I guess using da0p3, my swap partition, would be ok...


----------



## phoenix (Jan 12, 2018)

leebrown66 said:


> Don't copy a file, copy from /dev/zero, ie, for a 1GB file:
> 
> ```
> dd if=/dev/zero of=/dev/da99 bs=1m count=1k
> ...



Don't use /dev/zero, use /dev/random; and don't do the `dd` directly to the target device.  Use `dd` to create a file of a specific size and save it to disk.  Then you can use that file multiple time in your tests.

For example:

```
# dd if=/dev/random of=/home/username/bigfile.1G bs=1M count=1024
time -h cp ~/bigfile.1G /some/mountpoint
time -h cp ~/bigfile.1G /some/other/mountpoint
time -h dd if=~/bigfile.1G of=/dev/whatever bs=1M
```

The reason you don't want to use /dev/zero is that some filessytems have optimisations in place to do special things with "zero-filled" files.  And you don't want to use `dd` directly from a /dev/random to another device is that the random device will be slower than the disk device, so you will be "benchmarking" /dev/random instead of the target disk.  The reason to use random is to prevent in-place compression or dedupe if those are enabled on the target disk/filesystem.


----------



## agm (Feb 11, 2018)

transfer speed depends on the socket and the usb stick, if both provide USB 3.x then you get the higher speed (but the cable and the filesystem options can lower this also)

`sudo camcontrol inquiry da0 -R` will show you the max transfer rate;
pass2: 400.000MB/s transfers
or
pass2: 40.000MB/s transfers

`sudo usbconfig show_ifdrv` output must be filtered, but it is for example
ugen0.7: <Kingston DataTraveler 3.0> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=ON (126mA)
or
ugen0.7: <Kingston DataTraveler 2.0> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (100mA)


----------



## aragats (Feb 11, 2018)

balanga said:


> If I have a USB 3.0 microsd card reader, what sort of microsd card should I use?


Most SD cards speed classes have rates below USB 2 speeds, only Class 90 exceeds.


----------



## CraigHB (Feb 11, 2018)

You have watch out for that.  Memory devices advertise USB 3.0 conformance, but yet they use memory that can't take advantage of the higher speed, blatant gimmick.


----------

