USB 3.0 pendrive

Ok, I connected my Sandisk extreme 3.0 32gb usb drive and mounted it using this command:

sudo mount -t vfat /dev/sde1 /mnt/32ex -o uid=1000,gid=1000,utf8,dmask=027,fmask=137

I then opened an ssh -X session and ran:

sudo nautilus

I then copied a large file from an ext4 formatted partition (mounted inside my USB hard drive enclosure) and pasted it on the Sandisk Extreme 3.0 usb pendrive. It was writing at about 100MB/sec! But then the system crashed for some reason before finishing, so I’m going to try again.
ntfs-3g is part of my problem with the ntfs formatted drives, but I expected the ext4 drives to be faster. At least vfat seems to work in this case, and obviously the read speed from the ext4 partition was reaching 100MB/sec as well.

EDIT:
Repeating the above steps it was successful moving a 2.7GB test file from the ext4 partition to the pendrive and maintained about 100MB/sec transfer rate. I then copied the test file from the pen drive to a sub-folder on the same drive and it transferred at a speed of only 35-40MB/sec.

EDIT:
Further testing:
I copied the test file from the Sandisk Extreme usb drive to the ext4 drive inside the USB hard drive enclosure and saw transfer speeds of about 55MB/sec.
Taking the same test file and copying from the ext4 hard drive to a subfolder on the same drive saw transfer speeds of 35-38MB/sec.

This command does not give any special abilities to the kernel to achieve such speed. There must be other reason why you managed to speed up the copying process. Maybe cache was used in your tests or Linux GUI has given some advanced control over the buses.

For me it should work out-of-the-box in console mode.

Yes, I don’t know how it achieved it, but it shows it is possible. Interesting that it only transferred at those speeds under very certain conditions. Copying a file to and from the same drive still had abysmal speeds. I would really like to figure this issue out since it won’t work for me as a file server with the speed so slow.

I ran ‘sudo dmsg |grep usb’ and here is the output if this helps. It is showing xhci_hcd, so I think it should be ok there too, but maybe there is something else in there I’m not aware of:

rock@RockSvr:/var/log$ sudo dmesg |grep usb
[ 1.526977] usbcore: registered new interface driver usbfs
[ 1.527503] usbcore: registered new interface driver hub
[ 1.528043] usbcore: registered new device driver usb
[ 1.654320] phy phy-ff770000.syscon:usb2-phy@e450.0: Looking up phy-supply from device tree
[ 1.654424] vcc5v0_host: could not add device link phy-ff770000.syscon:usb2-phy@e450.0 err -2
[ 1.654785] phy phy-ff770000.syscon:usb2-phy@e450.1: Looking up phy-supply from device tree
[ 1.654797] phy phy-ff770000.syscon:usb2-phy@e450.1: Looking up phy-supply property in node /syscon@ff770000/usb2-phy@e450/otg-port failed
[ 1.655021] phy phy-ff770000.syscon:usb2-phy@e450.1: Looking up vbus-supply from device tree
[ 1.655032] phy phy-ff770000.syscon:usb2-phy@e450.1: Looking up vbus-supply property in node /syscon@ff770000/usb2-phy@e450/otg-port failed
[ 1.655045] phy phy-ff770000.syscon:usb2-phy@e450.1: Failed to get VBUS supply regulator
[ 1.656487] phy phy-ff770000.syscon:usb2-phy@e460.2: Looking up phy-supply from device tree
[ 1.656543] vcc5v0_host: could not add device link phy-ff770000.syscon:usb2-phy@e460.2 err -2
[ 1.656803] phy phy-ff770000.syscon:usb2-phy@e460.3: Looking up phy-supply from device tree
[ 1.656814] phy phy-ff770000.syscon:usb2-phy@e460.3: Looking up phy-supply property in node /syscon@ff770000/usb2-phy@e460/otg-port failed
[ 1.657028] phy phy-ff770000.syscon:usb2-phy@e460.3: Looking up vbus-supply from device tree
[ 1.657039] phy phy-ff770000.syscon:usb2-phy@e460.3: Looking up vbus-supply property in node /syscon@ff770000/usb2-phy@e460/otg-port failed
[ 1.657051] phy phy-ff770000.syscon:usb2-phy@e460.3: Failed to get VBUS supply regulator
[ 1.659876] phy phy-ff7c0000.phy.6: Looking up phy-supply property in node /phy@ff7c0000/usb3-port failed
[ 1.660400] phy phy-ff800000.phy.8: Looking up phy-supply property in node /phy@ff800000/usb3-port failed
[ 2.357150] usbcore: registered new interface driver cdc_ether
[ 2.357715] usbcore: registered new interface driver rndis_host
[ 2.364579] rockchip-dwc3 usb0: fail to get drvdata hcd
[ 2.370382] rockchip-dwc3 usb1: fail to get drvdata hcd
[ 2.377131] ehci-platform fe380000.usb: EHCI Host Controller
[ 2.377788] ehci-platform fe380000.usb: new USB bus registered, assigned bus number 1
[ 2.378732] ehci-platform fe380000.usb: irq 28, io mem 0xfe380000
[ 2.390599] ehci-platform fe380000.usb: USB 2.0 started, EHCI 1.00
[ 2.391469] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[ 2.392077] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 2.392717] usb usb1: Product: EHCI Host Controller
[ 2.393152] usb usb1: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 ehci_hcd
[ 2.393803] usb usb1: SerialNumber: fe380000.usb
[ 2.399803] ehci-platform fe3c0000.usb: EHCI Host Controller
[ 2.400465] ehci-platform fe3c0000.usb: new USB bus registered, assigned bus number 2
[ 2.401238] ehci-platform fe3c0000.usb: irq 30, io mem 0xfe3c0000
[ 2.410575] ehci-platform fe3c0000.usb: USB 2.0 started, EHCI 1.00
[ 2.411272] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002
[ 2.411871] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 2.412513] usb usb2: Product: EHCI Host Controller
[ 2.412947] usb usb2: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 ehci_hcd
[ 2.413588] usb usb2: SerialNumber: fe3c0000.usb
[ 2.417049] ohci-platform fe3a0000.usb: Generic Platform OHCI controller
[ 2.417800] ohci-platform fe3a0000.usb: new USB bus registered, assigned bus number 3
[ 2.418594] ohci-platform fe3a0000.usb: irq 29, io mem 0xfe3a0000
[ 2.478708] usb usb3: New USB device found, idVendor=1d6b, idProduct=0001
[ 2.479307] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 2.479938] usb usb3: Product: Generic Platform OHCI controller
[ 2.480465] usb usb3: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 ohci_hcd
[ 2.481107] usb usb3: SerialNumber: fe3a0000.usb
[ 2.483557] ohci-platform fe3e0000.usb: Generic Platform OHCI controller
[ 2.484407] ohci-platform fe3e0000.usb: new USB bus registered, assigned bus number 4
[ 2.485222] ohci-platform fe3e0000.usb: irq 31, io mem 0xfe3e0000
[ 2.542760] usb usb4: New USB device found, idVendor=1d6b, idProduct=0001
[ 2.543369] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 2.544009] usb usb4: Product: Generic Platform OHCI controller
[ 2.544536] usb usb4: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 ohci_hcd
[ 2.545187] usb usb4: SerialNumber: fe3e0000.usb
[ 2.549076] usbcore: registered new interface driver iforce
[ 2.549643] usbcore: registered new interface driver xpad
[ 2.550605] usbcore: registered new interface driver usbtouchscreen
[ 3.188839] usbcore: registered new interface driver uvcvideo
[ 3.199989] usbcore: registered new interface driver bfusb
[ 3.200553] usbcore: registered new interface driver btusb
[ 3.306801] usbcore: registered new interface driver usbhid
[ 3.307294] usbhid: USB HID core driver
[ 3.314649] usbcore: registered new interface driver snd-usb-audio
[ 4.078383] usb usb5: New USB device found, idVendor=1d6b, idProduct=0002
[ 4.079042] usb usb5: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 4.079688] usb usb5: Product: xHCI Host Controller
[ 4.080133] usb usb5: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 xhci-hcd
[ 4.080793] usb usb5: SerialNumber: xhci-hcd.8.auto
[ 4.084246] usb usb6: We don’t know the algorithms for LPM for this host, disabling LPM.
[ 4.085064] usb usb6: New USB device found, idVendor=1d6b, idProduct=0003
[ 4.085668] usb usb6: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 4.086306] usb usb6: Product: xHCI Host Controller
[ 4.086762] usb usb6: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 xhci-hcd
[ 4.087410] usb usb6: SerialNumber: xhci-hcd.8.auto
[ 4.091163] usb usb6: USB disconnect, device number 1
[ 4.113355] usb usb5: USB disconnect, device number 1
[ 4.122888] usb usb5: New USB device found, idVendor=1d6b, idProduct=0002
[ 4.123490] usb usb5: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 4.124125] usb usb5: Product: xHCI Host Controller
[ 4.124555] usb usb5: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 xhci-hcd
[ 4.125201] usb usb5: SerialNumber: xhci-hcd.9.auto
[ 4.128503] usb usb6: We don’t know the algorithms for LPM for this host, disabling LPM.
[ 4.129323] usb usb6: New USB device found, idVendor=1d6b, idProduct=0003
[ 4.129934] usb usb6: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 4.130603] usb usb6: Product: xHCI Host Controller
[ 4.131033] usb usb6: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 xhci-hcd
[ 4.131679] usb usb6: SerialNumber: xhci-hcd.9.auto
[ 4.136427] usb usb7: New USB device found, idVendor=1d6b, idProduct=0002
[ 4.137029] usb usb7: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 4.137663] usb usb7: Product: xHCI Host Controller
[ 4.138094] usb usb7: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 xhci-hcd
[ 4.138759] usb usb7: SerialNumber: xhci-hcd.8.auto
[ 4.141861] usb usb8: We don’t know the algorithms for LPM for this host, disabling LPM.
[ 4.142711] usb usb8: New USB device found, idVendor=1d6b, idProduct=0003
[ 4.143313] usb usb8: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 4.143948] usb usb8: Product: xHCI Host Controller
[ 4.144378] usb usb8: Manufacturer: Linux 4.4.154-59-rockchip-g5e70f14 xhci-hcd
[ 4.145032] usb usb8: SerialNumber: xhci-hcd.8.auto
[ 4.152902] rockchip-dwc3 usb0: USB HOST connected
[ 21.275075] usb 6-1: new SuperSpeed USB device number 2 using xhci-hcd
[ 21.292838] usb 6-1: New USB device found, idVendor=152d, idProduct=0567
[ 21.292872] usb 6-1: New USB device strings: Mfr=10, Product=11, SerialNumber=5
[ 21.292894] usb 6-1: Product: USB to ATA/ATAPI Bridge
[ 21.292914] usb 6-1: Manufacturer: JMicron
[ 21.292934] usb 6-1: SerialNumber: 152D00539000
[ 21.445850] usb-storage 6-1:1.0: USB Mass Storage device detected
[ 21.446708] usb-storage 6-1:1.0: Quirks match for vid 152d pid 0567: 5000000
[ 21.446938] scsi host0: usb-storage 6-1:1.0
[ 21.447659] usbcore: registered new interface driver usb-storage
[ 21.452927] usbcore: registered new interface driver uas
rock@RockSvr:/var/log$

Here is the output of ‘sudo lsusb -t’:

rock@RockSvr:/var/log$ sudo lsusb -t
/: Bus 08.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
/: Bus 07.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
/: Bus 06.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 5000M
|__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 5000M
/: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=xhci-hcd/1p, 480M
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/1p, 12M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/1p, 12M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M

Here are some interesting result running hdparm. This was run on my 2tb ext4 formatted partition inside my 4 bay usb 3.0 enclosure:

rock@RockSvr:/mnt/3tb/UbuntuBackupConfigs$ sudo hdparm -t /dev/sdb2
/dev/sdb2:
Timing buffered disk reads: 236 MB in 3.01 seconds = 78.36 MB/sec
rock@RockSvr:/mnt/3tb/UbuntuBackupConfigs$ sudo hdparm -t /dev/sdb2
/dev/sdb2:
Timing buffered disk reads: 256 MB in 3.01 seconds = 84.98 MB/sec
rock@RockSvr:/mnt/3tb/UbuntuBackupConfigs$ sudo hdparm -t /dev/sdb2
/dev/sdb2:
Timing buffered disk reads: 306 MB in 3.02 seconds = 101.47 MB/sec
rock@RockSvr:/mnt/3tb/UbuntuBackupConfigs$ sudo hdparm -t /dev/sdb2
/dev/sdb2:
Timing buffered disk reads: 246 MB in 3.02 seconds = 81.47 MB/sec

Additional runs on a 320GB drive and 250GB drive inside the same enclousure:

rock@RockSvr:/mnt/3tb/UbuntuBackupConfigs$ sudo hdparm -t /dev/sdc1
/dev/sdc1:
Timing buffered disk reads: 296 MB in 3.01 seconds = 98.41 MB/sec
rock@RockSvr:/mnt/3tb/UbuntuBackupConfigs$ sudo hdparm -t /dev/sdc1
/dev/sdc1:
Timing buffered disk reads: 302 MB in 3.01 seconds = 100.44 MB/sec
rock@RockSvr:/mnt/3tb/UbuntuBackupConfigs$ sudo hdparm -t /dev/sdd1
/dev/sdd1:
Timing buffered disk reads: 272 MB in 3.02 seconds = 90.10 MB/sec
rock@RockSvr:/mnt/3tb/UbuntuBackupConfigs$ sudo hdparm -t /dev/sdd1
/dev/sdd1:
Timing buffered disk reads: 246 MB in 3.02 seconds = 81.55 MB/sec

However, actually copying any files and doing anything real results in terrible speeds.

EDIT:
Additional testing using dd:

rock@RockSvr:~$ sudo sync; sudo dd if=/dev/zero of=/mnt/2tb/tempfile bs=1M count=1024;sudo sync
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 9.89387 s, 109 MB/s
rock@RockSvr:~$

EDIT:
Another test. I created an image of my 320gb drive and stored it on my 2tb. The speed was slow.

rock@RockSvr:/mnt/2tb$ sudo dd if=/dev/sdc of=/mnt/2tb/320.img
625142448+0 records in
625142448+0 records out
320072933376 bytes (320 GB, 298 GiB) copied, 6430.96 s, 49.8 MB/s
rock@RockSvr:/mnt/2tb$

Can anyone at radxa shed some light on all this?

SSD: Samsung T5 512G
Cable: USB 3.0 type A to type C cable 1m long
Port: lower USB 3.0 port of ROCK Pi 4.
File system: ext4
Firmware: Ubuntu minimal 18.04, updated the kernel to 4.4.154-72-rockchip-g6520deb

root@localhost:/mnt# dd if=/dev/zero of=./z.img bs=1G count=2 oflag=direct
2+0 records in
2+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 6.99098 s, 307 MB/s
root@localhost:/mnt# sync
root@localhost:/mnt# dd if=/dev/zero of=./z.img bs=1G count=2 oflag=direct
2+0 records in
2+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 6.55475 s, 328 MB/s
root@localhost:/mnt# dd if=/dev/zero of=./z.img bs=1G count=2 oflag=direct
2+0 records in
2+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 7.2934 s, 294 MB/s
root@localhost:/mnt# dd if=/dev/zero of=./z.img bs=1G count=2 oflag=direct
2+0 records in
2+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 7.13251 s, 301 MB/s
root@localhost:/mnt# dd if=/dev/zero of=./z.img bs=1G count=2 oflag=direct
2+0 records in
2+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 6.30066 s, 341 MB/s
root@localhost:/mnt# uname -r
4.4.154-72-rockchip-g6520deb

root@localhost:~# hdparm -t /dev/sda1

/dev/sda1:
Timing buffered disk reads: 860 MB in 3.00 seconds = 286.64 MB/sec
root@localhost:~# hdparm -t /dev/sda1

/dev/sda1:
Timing buffered disk reads: 874 MB in 3.00 seconds = 291.16 MB/sec
root@localhost:~# hdparm -t /dev/sda1

/dev/sda1:
Timing buffered disk reads: 982 MB in 3.01 seconds = 326.69 MB/sec
root@localhost:~# hdparm -t /dev/sda1

/dev/sda1:
Timing buffered disk reads: 950 MB in 3.00 seconds = 316.58 MB/sec
root@localhost:~# hdparm -t /dev/sda1

/dev/sda1:
Timing buffered disk reads: 904 MB in 3.00 seconds = 301.08 MB/sec

1 Like

Do you know the usb chip of your drive? I think it’s some model from Jmicron? Does it support UAS?

I just noticed that UAS module should be automatically loaded. If not, please run:

sudo modprobe uas

and make sure lsmod shows it.

Here is my output of lsusb -v that pertains to the enclosure. It looks like a JMS567. I was able to reach decent speeds using dd as well. Could you try transferring a large file on your device using ‘rsync – progress’? I’m curious what a real world transfer speed would be for you. I had the same result with slow speeds when connecting my SanDisk extreme 3.0 is drive. This model:
SanDisk Extreme 32 GB USB 3.0 Flash Drive SDCZ80-032G-X46 https://www.amazon.com/dp/B007YXA5TC/ref=cm_sw_r_cp_apa_i_sKBqCbEGASYAX

Bus 008 Device 002: ID 152d:0567 JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 SATA 6Gb/s bridge
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 3.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 9
idVendor 0x152d JMicron Technology Corp. / JMicron USA Technology Corp.
idProduct 0x0567 JMS567 SATA 6Gb/s bridge
bcdDevice 2.05
iManufacturer 10 JMicron
iProduct 11 USB to ATA/ATAPI Bridge
iSerial 5 152D00539000
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 44
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 15
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 0
bMaxBurst 15
Binary Object Store Descriptor:
bLength 5
bDescriptorType 15
wTotalLength 22
bNumDeviceCaps 2
USB 2.0 Extension Device Capability:
bLength 7
bDescriptorType 16
bDevCapabilityType 2
bmAttributes 0x00000002
Link Power Management (LPM) Supported
SuperSpeed USB Device Capability:
bLength 10
bDescriptorType 16
bDevCapabilityType 3
bmAttributes 0x00
wSpeedsSupported 0x000e
Device can operate at Full Speed (12Mbps)
Device can operate at High Speed (480Mbps)
Device can operate at SuperSpeed (5Gbps)
bFunctionalitySupport 1
Lowest fully-functional device speed is Full Speed (12Mbps)
bU1DevExitLat 10 micro seconds
bU2DevExitLat 2047 micro seconds
Device Status: 0x0001
Self Powered

Here is my output from that:
rock@RockSvr:~$ sudo modprobe uas
[sudo] password for rock:
rock@RockSvr:~$ lsmod
Module Size Used by
uas 20480 0
usb_storage 61440 5 uas
ip_tables 24576 0
x_tables 32768 1 ip_tables
autofs4 40960 2
rock@RockSvr:~$

Here is a raw read using dd of my 3tb drive inside the enclosure. As you can see, the speed looks good for this old spinner. However, real life usage is a different story.

rock@RockSvr:~$ sudo dd if=/dev/sda of=/dev/null bs=100M
^C32+0 records in
31+0 records out
3250585600 bytes (3.3 GB, 3.0 GiB) copied, 25.6378 s, 127 MB/s
rock@RockSvr:~$

I’ve run modprobe uas, also added uas to /etc/modules, put the pendrive in lower USB 3.0 port and restarted the board. lsmod gives that uas is loaded. I have script:

#!/usr/bin/env bash
echo === WRITE 1GiB ===
echo -n "sync..." ; sync ; echo "ok"
time {
        dd if=/dev/zero of=temp conv=fdatasync bs=1024k count=1k
        echo -n sync...
        sync
        echo ok
}
rm -f temp
echo -n "sync..." ; sync ; echo "ok"
echo Done.

which now gives:

=== WRITE 1GiB ===
sync...ok
1024+0 records in
1024+0 records out
1073741824 bytes (1,1 GB, 1,0 GiB) copied, 35,9079 s, 29,9 MB/s
sync...ok

real    0m35,940s
user    0m0,000s
sys     0m6,064s
sync...ok
Done.

Surely the pendrive achieves higher speeds on PC. However I don’t know much about this pendrive (chip, controller etc.).

EDIT: Just tested HDD in USB 3.1 enclosure. Acts up to 26.4 MB/s. On PC full write speed is about 120 MB/s.

Wow, you’re facing worse results than I am. What do you get when you run hdparm?

Timing buffered disk reads: 198 MB in  3.03 seconds =  65.45 MB/sec

That’s really strange, because it says that pendrive is in USB 3.0 mode at this speed. Should give about 140 MB/s read and 80-90 MB/s write…

While HDD write is up to 26.4 MB/s, reading is blazing fast! I’ve got over 124 MB/s constant read speed. Still pendrives are too slow…

Just thought I would add my unusual experience that may shed some light on a possible issue.
I have done quite a bit of speed testing (fio) with my Samsung EVO 970 250GB NVMe and for what ever reason after some random amount of testing the speeds drop by about 70% and nothing I do restores it. I have no explanation why this happens but formatting the drive fixes the speed problem. Drive is formatted with ext4.

Maybe you are having a similar issue?

I tried using the Debian image yesterday, and I see the same results. The speed is just too slow for my needs. Such a bummer.

Same thing, too slow for my needs now

I just got these numbers on my 970 EVO Plus 250Gb, Rockpi4 V1.4 4GbRAM
1.3 GBps read
382 MBps write
Dangg:D

Ok, so first off, that device you are referring to is M2. This thread is about USB3.
And second, 1.3 Gbps is only 162.5 MB/s, and 382 Mbps is only 47.75 MB/s… this is eMMC territory. I’m seeing people displaying MUCH better results from USB3 devices in this thread. Despite the “:D” you share on your post, you certainly don’t have anything to smile about.

Its not for “whatever reason”. There is a VERY SPECIFIC reason why this happens. You can’t re-write to previously written blocks on a solid state storage device until those blocks have been wiped clean. The reason why it is much slower is because of the time it takes to wipe those previously used blocks.

Two easy solutions;

  1. Manually run fstrim on the filesystem:
# fstrim -v /mount/point
  1. automatically, by mounting the filesystem with the “discard” option.

Now this is the key to the process; the DRIVE can’t just trim itself, because after a block has been written to, it has no way to know if it is still in use or is available. That means that the OS has to TELL it what blocks are available and should be trimmed. The OS queries the filesystem, which tracks what is and is not in use, and sends the results to the disk, which should do the job in the background, rather than you actually having to wait for the whole disk to write over.

When you’re FORMATTING a disk, it issues a trim command for the entire, CONTIGUOUS, region that will be occupied by the new filesystem (typically the entire partition). Now formatting your disk just to trim it is, of course, very wasteful – both in terms of the longevity of the disk itself, as well as the work it takes to return the disk to the state it was in. My advice to you would be to mount the filesystem using the discard option, and then occasionally check with the fstrim command to make sure. This will optimize the disk performance without unduly hurting its longevity. After all, blocks need to be wiped prior to being rewritten anyway, might as well do it proactively.

Edit: one of the reasons why the discard mount option is so powerful, is because it has basically zero overhead. When you delete a file, that fact is recorded in the filesystem as an unlink. On a magnetic disk, that is ALL that happens, whatever data was pointed to by the inode that was just erased ends up being “lost” somewhere on the drive. Same happens without the discard option, which means that in order for the fstrim command to work, it has to run through the entire filesystem in order to track down all the blocks that are IN USE, and then invert that selection before feeding the results to the disk for a trim. So if you run the fstrim command, it can actually take quite a while sometimes. But if you mount with discard, then before unlinking, it takes the list of blocks from the inode RIGHT THEN and sends it to the disk to be trimmed. No need to search for it later.

1 Like