Page 1 of 1

Copying to USB HDD is very slow

Posted: Sun Oct 13, 2019 6:52 am
by zeitalex
Seagate 8TB Backup Plus USB3 Hdd (formated with ext4) is very slow on my RPi3. If i download via ftp for example it is about 300KB/s while other usb drives and SD Card gives about 7MB/s. Local copying to it is also very slow. The strange thing is that if I copy to this drive connected to RPi from my Notebook over NFS it copies with 5MB/s. On RPi i have Raspbian 9 (stretch).

Re: Copying to USB HDD is very slow

Posted: Sun Oct 13, 2019 10:55 am
by LTolledo
RPi3B has only USB2.0 ports.
smb copy over LAN connection gave me about 7MB/s

what does
hdparm -tT /dev/sda1 (assuming your HDD is auto-mounted as /dev/sda1) give you?

Re: Copying to USB HDD is very slow

Posted: Sun Oct 13, 2019 11:16 am
by zeitalex

Code: Select all

sudo hdparm -tT /dev/sda1
/dev/sda1:
 Timing cached reads:   1282 MB in  2.00 seconds = 640.70 MB/sec
 Timing buffered disk reads:  16 MB in  3.33 seconds =   4.80 MB/sec
If i am on Pi and doing rsync locally (from one local usb drive to "problematic" local usb drive), it copies with 1MB/s, but if i am on my notebook an copying over nfs from/to same drives connected to RPi it is much faster and gives about 5MB/s. I noticed that this problem is mainly occurs if copying with sudo. Without sudo rsync local copy on RPi gives sometimes 20MB/s.

Re: Copying to USB HDD is very slow

Posted: Sun Oct 13, 2019 2:13 pm
by LTolledo
just to compare, below is the output when I ran the same command on this SSD boot RPi3B Raspbian Stretch with Full Desktop.
with a hard disk (2.5" Marshal 1TB in Orico HDD to SATA case adapter) connected to the RPi3B via powered USB 2.0 hub

Code: Select all

 $ sudo hdparm -tT /dev/sdb1

/dev/sdb1:
 Timing cached reads:   1314 MB in  2.00 seconds = 657.03 MB/sec
 Timing buffered disk reads:  98 MB in  3.01 seconds =  32.51 MB/sec
the result of the buffered disk read is the expected value for a drive connected to a USB2.0 port of RPi

and here is there result when I plugged in my "very old" 2.5" 80GB PATA drive in a PATA to USB2.0 case

Code: Select all

~ $ sudo hdparm -tT /dev/sdb1

/dev/sdb1:
 Timing cached reads:   1174 MB in  2.00 seconds = 586.77 MB/sec
 Timing buffered disk reads:  88 MB in  3.05 seconds =  28.89 MB/sec
and its still within expectations

Re: Copying to USB HDD is very slow

Posted: Mon Oct 14, 2019 7:51 am
by zeitalex
Today I started hdparm -tT /dev/sda1 again and "Timing buffered disk reads" was 28 MB/sec. Obviously first time was another process that was writing to hdd at the same time and this was the reason why "Timing buffered disk reads" was 4.80 MB/sec. But still I have problem that /dev/sda1 is very slow even if "sudo rsync" is only process that is writing to hdd.

Re: Copying to USB HDD is very slow

Posted: Mon Oct 14, 2019 8:14 am
by RaTTuS
buffered reads is a red herring

Code: Select all

dd if=/dev/zero of=test bs=524288 count=2048 
will write 1GB to your device in a file called test
change test to point to your mounted drive
and give the results

rsync will give various results depending on what it there already etc..

Re: Copying to USB HDD is very slow

Posted: Mon Oct 14, 2019 10:06 am
by gkreidl
RaTTuS wrote:
Mon Oct 14, 2019 8:14 am
buffered reads is a red herring

Code: Select all

dd if=/dev/zero of=test bs=524288 count=2048 
will write 1GB to your device in a file called test
change test to point to your mounted drive
and give the results

rsync will give various results depending on what it there already etc..
FYI, on my RPi 3B this gives 27,5 MB/s (USB HDD connected via USB2)

On my RPi 4B I get 142 MB/s (USB HDD connected via USB3)

Re: Copying to USB HDD is very slow

Posted: Mon Oct 14, 2019 10:22 am
by zeitalex
RaTTuS wrote:
Mon Oct 14, 2019 8:14 am
buffered reads is a red herring

Code: Select all

dd if=/dev/zero of=test bs=524288 count=2048 
will write 1GB to your device in a file called test
change test to point to your mounted drive
and give the results

rsync will give various results depending on what it there already etc..

I am getting 3,7 MB/s:

Code: Select all

pi@raspberrypi:/media/usb0/Tests $ dd if=/dev/zero of=./test bs=524288 count=2048
2048+0 records in
2048+0 records out
1073741824 bytes (1,1 GB, 1,0 GiB) copied, 293,408 s, 3,7 MB/s

Re: Copying to USB HDD is very slow

Posted: Tue Oct 15, 2019 3:54 pm
by zeitalex
Following I am getting on RPi (usb0 connected to RPi):

Code: Select all

pi@raspberrypi:~ $ dd if=/dev/zero of=/media/usb0/Tests/test bs=524288 count=2048
2048+0 records in
2048+0 records out
1073741824 bytes (1,1 GB, 1,0 GiB) copied, 296,676 s, 3,6 MB/s

and this I am getting on my notebook on the same folder connected with NFS:

Code: Select all

user@notebook:/media/user/NFS/Tests$ dd if=/dev/zero of=test bs=524288 count=2048
2048+0 Datensätze ein
2048+0 Datensätze aus
1073741824 Bytes (1,1 GB, 1,0 GiB) kopiert, 193,729 s, 5,5 MB/s
Why writing over network is faster than local writing?

Re: Copying to USB HDD is very slow

Posted: Tue Oct 15, 2019 4:08 pm
by RaTTuS
what filesystem are you running on those usb drives

Re: Copying to USB HDD is very slow

Posted: Tue Oct 15, 2019 5:41 pm
by zeitalex
In both cases it is the same disk and it is ext4. It is connected to RPi. In first case i am starting dd on RPi directly, and in second case i am starting dd on my notebook over NFS mount pointing to the same disk connected to RPi.

Re: Copying to USB HDD is very slow

Posted: Tue Oct 15, 2019 6:50 pm
by zeitalex
If this hdd connected to notebook directly, it gives 42,1 MB/s:

Code: Select all

$ dd if=/dev/zero of=test1 bs=524288 count=2048
2048+0 Datensätze ein
2048+0 Datensätze aus
1073741824 Bytes (1,1 GB, 1,0 GiB) kopiert, 25,5065 s, 42,1 MB/s
even if I connect hdd directly to very old RPi1 it gives me 12.0MB/s

Re: Copying to USB HDD is very slow

Posted: Wed Oct 16, 2019 3:09 am
by zeitalex
If after reboot I unmount hdd and do

Code: Select all

sudo mount /dev/sda1 /media/usb0/
then I am able to write to it with 36,1 MB/s

Probably something is wrong in my fstab:

Code: Select all

PARTUUID=25d6e1ac-01  /boot           vfat    defaults          0       2
PARTUUID=25d6e1ac-02  /               ext4    defaults,noatime  0       1

UUID=fb769947-7836-4897-b2fd-107a6718e413   /media/usb0   ext4   auto,nofail,sync,users,rw   0   0
UUID=1BFD083548529955 /media/usb1 ntfs auto,users,rw 0 0

Re: Copying to USB HDD is very slow

Posted: Wed Oct 16, 2019 6:35 am
by Kendek
zeitalex wrote:
Wed Oct 16, 2019 3:09 am

Code: Select all

sudo mount /dev/sda1 /media/usb0/
then I am able to write to it with 36,1 MB/s

Probably something is wrong in my fstab:

Code: Select all

UUID=fb769947-7836-4897-b2fd-107a6718e413   /media/usb0   ext4   auto,nofail,sync,users,rw   0   0
Yes, the sync mount option.