# Bad USB HDD performance

## manuels

Hi guys,

I had no luck with the german board so I decided to try this one.

I'm using a usb harddisk which is very slow under linux:

```
dd if=/dev/sda of=/dev/sdb
```

I'm getting about 2.8 MB/s.

(sdb is the usb hd, sda the "normal" one, the normal one is working fine)

Using windows gives much better performance: I copied a 1,3GB with 12 MB/s

Here are some specs:

```
# uname -a

Linux fuckup 2.6.23-tuxonice-r9 #22 SMP PREEMPT Sun Feb 24 00:44:48 CET 2008 x86_64 AMD Turion(tm) 64 X2 Mobile Technology TL-50 AuthenticAMD GNU/Linux
```

/proc/config.gz

dmesg

lsusb -v

lspci

Any hints or ideas appreciated!

Cheers,

Manuel

----------

## poly_poly-man

First of all, make sure that it's the drive and not the filesystem: run hdparm -t /dev/sdb a few times.

If that's still low, make sure the correct USB drivers are in the kernel (are you in USB 1.1 mode?)

poly-p man

----------

## manuels

looks like its working fine (usb hd is sdc now):

```
# hdparm -t /dev/sdc

/dev/sdc:

 Timing buffered disk reads:   66 MB in  3.07 seconds =  21.50 MB/sec

# hdparm -t /dev/sdc

/dev/sdc:

 Timing buffered disk reads:   66 MB in  3.07 seconds =  21.51 MB/sec

# hdparm -t /dev/sdc

/dev/sdc:

 Timing buffered disk reads:   66 MB in  3.06 seconds =  21.58 MB/sec

```

But the copy from drive to drive is slow:

```
dd if=/dev/sda of=/dev/sdc

210177+0 Datensätze ein

210177+0 Datensätze aus

107610624 Bytes (108 MB) kopiert, 39,2579 s, 2,7 MB/s

```

But the other drive (sda) is fast too:

```

# hdparm -t /dev/sda

/dev/sda:

 Timing buffered disk reads:  116 MB in  3.04 seconds =  38.19 MB/sec

# hdparm -t /dev/sda

/dev/sda:

 Timing buffered disk reads:  116 MB in  3.03 seconds =  38.31 MB/sec

# hdparm -t /dev/sda

/dev/sda:

 Timing buffered disk reads:  116 MB in  3.02 seconds =  38.45 MB/sec

```

Whose fault is it?

----------

## manuels

Just writing to the usb disk is slow:

```
# dd if=/dev/zero of=/dev/sdb

204569+0 Datensätze ein

204569+0 Datensätze aus

104739328 Bytes (105 MB) kopiert, 38,4477 s, 2,7 MB/s

```

How can I change this?

----------

## poly_poly-man

Try:dd if=/dev/zero of=/dev/sdb count=66 bs=1M

Also, play around with count, and maybe make bs bigger.

Also try reading like that.

poly-p man

----------

## manuels

ok, here I played around with the blocksize:

```
dd if=/dev/zero of=/dev/sdb count=66 bs=1M

66+0 Datensätze ein

66+0 Datensätze aus

69206016 Bytes (69 MB) kopiert, 6,19132 s, 11,2 MB/s

# dd if=/dev/zero of=/dev/sdb count=66 bs=3M

66+0 Datensätze ein

66+0 Datensätze aus

207618048 Bytes (208 MB) kopiert, 13,846 s, 15,0 MB/s

# dd if=/dev/zero of=/dev/sdb count=66 bs=10M

66+0 Datensätze ein

66+0 Datensätze aus

692060160 Bytes (692 MB) kopiert, 44,5045 s, 15,6 MB/s

# dd if=/dev/zero of=/dev/sdb count=66 bs=50M

66+0 Datensätze ein

66+0 Datensätze aus

3460300800 Bytes (3,5 GB) kopiert, 228,734 s, 15,1 MB/s

```

This looks fine.

```
# dd if=/dev/zero of=/dev/sdb count=100 bs=1M

100+0 Datensätze ein

100+0 Datensätze aus

104857600 Bytes (105 MB) kopiert, 7,07509 s, 14,8 MB/s

# dd if=/dev/zero of=/dev/sdb count=10 bs=1M

10+0 Datensätze ein

10+0 Datensätze aus

10485760 Bytes (10 MB) kopiert, 0,81573 s, 12,9 MB/s

# dd if=/dev/zero of=/dev/sdb count=30 bs=1M

30+0 Datensätze ein

30+0 Datensätze aus

31457280 Bytes (31 MB) kopiert, 2,30071 s, 13,7 MB/s

# dd if=/dev/zero of=/dev/sdb count=50 bs=1M

50+0 Datensätze ein

50+0 Datensätze aus

52428800 Bytes (52 MB) kopiert, 3,47977 s, 15,1 MB/s

# dd if=/dev/zero of=/dev/sdb count=1000 bs=1M

1000+0 Datensätze ein

1000+0 Datensätze aus

1048576000 Bytes (1,0 GB) kopiert, 67,851 s, 15,5 MB/s

```

Looks ok, too.

There is no information about the default blocksize dd is using in the manpage.

Does anybody know this?

----------

## bunder

 *Quote:*   

> There is no information about the default blocksize dd is using in the manpage. 

 

512 bytes.

cheers

----------

## manuels

Ok, so with a small blocksize I get low throughput:

```
#dd if=/dev/zero of=/dev/sdb count=100000 bs=512

100000+0 Datensätze ein

100000+0 Datensätze aus

51200000 Bytes (51 MB) kopiert, 17,4202 s, 2,9 MB/s

# dd if=/dev/zero of=/dev/sdb count=1000 bs=51200

1000+0 Datensätze ein

1000+0 Datensätze aus

51200000 Bytes (51 MB) kopiert, 4,50755 s, 11,4 MB/s

#dd if=/dev/zero of=/dev/sdb count=10000 bs=5120

^[[1;2F10000+0 Datensätze ein

10000+0 Datensätze aus

51200000 Bytes (51 MB) kopiert, 11,4611 s, 4,5 MB/s

```

I'm having the same problems when rsyncing to the disk.

So I think I should enlarge the write cache, shouldn't I?

EDIT: But how can I do this?

Nobody ever did this before?

----------

## manuels

Hmm, looks like the device has no write cache:

```

# sdparm /dev/sdc --set=WCE

    /dev/sdc: ST312002  6A

change_mode_page: failed fetching page: Caching (SBC)

# sdparm /dev/sdc --get=WCE

    /dev/sdc: ST312002  6A

WCE not found in Caching (SBC) mode page

# sdparm /dev/sdc -v -a

    /dev/sdc: ST312002  6A

>> Read write error recovery mode page [0x1] not supported

>> Disconnect-reconnect (SPC + transports) mode page [0x2] not supported

>> Format (SBC) mode page [0x3] not supported

>> Rigid disk (SBC) mode page [0x4] not supported

>> Verify error recovery (SBC) mode page [0x7] not supported

>> Caching (SBC) mode page [0x8] not supported

>> Control mode page [0xa] not supported

>> Control extension mode subpage [0xa,0x1] not supported

>> SAT pATA control mode subpage [0xa,0xf1] not supported

>> Power condition - old version mode page [0xd] not supported

>> XOR control (SBC) mode page [0x10] not supported

>> Protocol specific logical unit mode page [0x18] not supported

>> Protocol specific port mode page [0x19] not supported

>> Power condition mode page [0x1a] not supported

>> Informational exceptions control mode page [0x1c] not supported

>> Background control (SBC) mode subpage [0x1c,0x1] not supported

```

But is there no OS dependent write cache I can enable? (should be, because I can write to this USB disk under windows with high speed)

----------

## manuels

No ideas?

----------

## eccerr0r

Most of those USB-IDE controllers only emulate a subset of SCSI function passthroughs, so sdparm and smarttctl are virtually useless for most USB-IDE controllers.

----------

## manuels

so the driver should emulate a cache?

It it possible and already implemented anywhere?

----------

## eccerr0r

It's still using the on-drive cache, but it's probably not using it as effectively as it could as USB is usually the limiting factor.

----------

## manuels

hmm, looks like I should have mounted it async:

copying 160MB files each 512 byte:

```

async 15,8s

sync 11m 24s
```

  :Laughing: 

----------

