writing to external USB SSD is too slow

Hi,

I’m using a USB to SATA HDD dock with an intel 1TB SSD, but the write speed is too low (40MB/s) as if the dock works in USB2.0 mode (while it’s not, ‘dd’ command shows the read can be up to 270MB/s).

$ dd if=/dev/zero of=tmpfile bs=8M count=1024
1024+0 records in
1024+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 204.334 s, 42.0 MB/s

$ dd if=/dev/zero of=tmpfile_bs1m bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 25.6433 s, 41.9 MB/s

sudo sysctl -w vm.drop_caches=3 vm.drop_caches = 3 dd if=tmpfile_bs1m of=/dev/null bs=1M
8192+0 records in
8192+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 31.1697 s, 276 MB/s

sudo sysctl -w vm.drop_caches=3 vm.drop_caches = 3 dd if=tmpfile of=/dev/null bs=8M
1024+0 records in
1024+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 31.74 s, 271 MB/s

Working directory is on the external SSD. By configuring a samba server on nano, I got a little bit slower write speed (less than 40MB/s). However, by running fio with a benchmark script, I got the following results:


script: https://gist.github.com/i3v/99f8ef6c757a5b8e9046b8a47f3a9d5b

Configuration: Size:1024m Loops:5 Write Only Zeroes:0
Running Benchmark, please wait…

Results:

Sequential Read: 563MB/s IOPS=0
Sequential Write: 346MB/s IOPS=0

512KB Read: 662MB/s IOPS=1325
512KB Write: 358MB/s IOPS=716

Sequential Q32T1 Read: 598MB/s IOPS=18
Sequential Q32T1 Write: 353MB/s IOPS=11

4KB Read: 77MB/s IOPS=19901
4KB Write: 31MB/s IOPS=8085

4KB Q32T1 Read: 75MB/s IOPS=19441
4KB Q32T1 Write: 31MB/s IOPS=8112

4KB Q8T8 Read: 176MB/s IOPS=45224
4KB Q8T8 Write: 22MB/s IOPS=5651

Here’s the syslog when mounting the external SSD:

kernel: [10518.675715] usb 2-1.4: new SuperSpeed USB device number 5 using tegra-xusb
kernel: [10518.700249] usb 2-1.4: New USB device found, idVendor=152d, idProduct=0561
kernel: [10518.700336] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=5
kernel: [10518.700390] usb 2-1.4: Product: USB 3.0 Device
kernel: [10518.700441] usb 2-1.4: Manufacturer: USB 3.0 Device
kernel: [10518.700486] usb 2-1.4: SerialNumber: xxxxxxxxxxxxx
kernel: [10518.710824] scsi host0: uas
kernel: [10518.713776] scsi 0:0:0:0: Direct-Access 0105 PQ: 0 ANSI: 6
kernel: [10518.759548] sd 0:0:0:0: [sda] 2000409264 512-byte logical blocks: (1.02 TB/954 GiB)
kernel: [10518.768670] sd 0:0:0:0: [sda] Write Protect is off
kernel: [10518.773517] sd 0:0:0:0: [sda] Mode Sense: 67 00 10 08
kernel: [10518.774066] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
kernel: [10518.790819] sda: sda1 sda2
kernel: [10518.794524] sd 0:0:0:0: [sda] Attached SCSI disk
mtp-probe: checking bus 2, device 5: “/sys/devices/70090000.xusb/usb2/2-1/2-1.4”
mtp-probe: bus: 2, device: 5 was not an MTP device
ntfs-3g[9251]: Version 2017.3.23 integrated FUSE 28
ntfs-3g[9251]: Mounted /dev/sda2 (Read-Write, label “New Volume”, NTFS 3.1)
ntfs-3g[9251]: Cmdline options: rw
ntfs-3g[9251]: Mount options: rw,allow_other,nonempty,relatime,fsname=/dev/sda2,blkdev,blksize=4096
ntfs-3g[9251]: Ownership and permissions disabled, configuration type 7

By attaching the dock to a Win10 laptop, I can get 360MB/s (read) and 280MB/s (write) speed.

Can anyone help me with this? Thanks.

Sorry guys.

I just realized that maybe it’s because the partition is not properly aligned to physical sectors, so I re-created the partitions, and it works fine now.