# Slow _actual_ disk performance, ok according to hdparm

## rndusr

I believe I have a problem with my disk performance. According to hdparm, I should be able to get about 85 MBps.

```
weirdwolf ~ # hdparm -t /dev/sdb

/dev/sdb:

 Timing buffered disk reads: 262 MB in  3.02 seconds =  86.81 MB/sec
```

However, when I for example copy a large file to the disk, I cannot get more than about 9 MBps. Why?

I know the 85 MBps are obtained when reading, not when writing, but 9 MBps still feels way too slow.

It's a dedicated disk (no other partitions), and I get the same results with both ext3, ext4 and xfs. I have really no clue where to start troubleshooting, any help would be welcome!

----------

## PaulBredbury

Run "mount" - how does it show the partition mounted? Using the unwise "sync" option?

----------

## rndusr

No sign of sync..

```
weirdwolf ~ # mount

rootfs on / type rootfs (rw)

/dev/sda1 on / type ext4 (rw,noatime,commit=0)

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)

tmpfs on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)

udev on /dev type devtmpfs (rw,nosuid,relatime,size=10240k,nr_inodes=506054,mode=755)

devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620)

shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)

/dev/sda3 on /home type xfs (rw,noatime)

binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nodev,noexec,nosuid)

/dev/sdb1 on /mnt/wddisk type ext4 (rw,noatime,noexec,nosuid,nodev,user)

```

----------

## NeddySeagoon

PanzerKanzler,

Please tell the drive part number, how its connected and show its fdisk -l output.

I suspect a misaligned 'Advanced Format' drive.

----------

## rndusr

I believe WDBKXH5000ABK-01 is the part number.

The relevant part of fdisk -l:

```
Disk /dev/sdb: 500.1 GB, 500074283008 bytes, 976707584 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0004a183

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048   976707583   488352768   83  Linux
```

Perhaps I should have mentioned that the disk is connected via USB 3.0. However, I don't believe that this is what causes it, since all my other removable media (USB) have decent write speeds.

----------

## NeddySeagoon

PanzerKanzler,

Your fdisk confirms that your partition alignment is correct for Advanced Format hard drives.

Thats harmlesss even if the drive lies about its physical sector size - many do.

USB3 needs a special USB3 cable - it uses differential signalling so has twice as many wires.

If you use a normal USB cable, at best you get USB2 data rates ... say around 25Mb sec.

How is your USB3 device tree set up?

Which driver are you using in the kernel?

----------

## rndusr

 *NeddySeagoon wrote:*   

> Your fdisk confirms that your partition alignment is correct for Advanced Format hard drives.
> 
> Thats harmlesss even if the drive lies about its physical sector size - many do.

 

Ok, this is good to hear.

 *NeddySeagoon wrote:*   

> USB3 needs a special USB3 cable - it uses differential signalling so has twice as many wires.
> 
> If you use a normal USB cable, at best you get USB2 data rates ... say around 25Mb sec.

 

I'm using the cable that came with the disk, and it is supposed to be a USB3 cable.

My USB2 memory stick achieves about 18 MBps (it was advertised as 20 MBps) when writing, so even if the disk for some reason decided to use USB2 mode, it should write more than 9 MBps..

 *NeddySeagoon wrote:*   

> How is your USB3 device tree set up?

 

How can I find out? (I don't even know what a USB device tree is..)

 *NeddySeagoon wrote:*   

> Which driver are you using in the kernel?

 

I'm using the xhci_hcd driver, and not as a module. From lspci -v:

```

...

02:00.0 USB controller: NEC Corporation uPD720200 USB 3.0 Host Controller (rev 03) (prog-if 30 [XHCI])

        Subsystem: ASUSTeK Computer Inc. P8P67 Deluxe Motherboard

        Flags: bus master, fast devsel, latency 0, IRQ 19

        Memory at f9ffe000 (64-bit, non-prefetchable) [size=8K]

        Capabilities: [50] Power Management version 3

        Capabilities: [70] MSI: Enable- Count=1/8 Maskable- 64bit+

        Capabilities: [90] MSI-X: Enable+ Count=8 Masked-

        Capabilities: [a0] Express Endpoint, MSI 00

        Capabilities: [100] Advanced Error Reporting

        Capabilities: [140] Device Serial Number ff-ff-ff-ff-ff-ff-ff-ff

        Capabilities: [150] Latency Tolerance Reporting

        Kernel driver in use: xhci_hcd

...

```

----------

## Ant P.

What does `cat /sys/class/block/sdb/queue/scheduler` say? Does changing that affect it at all?

----------

## NeddySeagoon

PanzerKanzler,

Your USB device tree shows how all of your USB devices are connected, like the branches of a tree, back to your PC.

Your PC contains devices called USB root hubs. each root hub is normally a pair of USB sockets.  

Oh dear ....  Amazon Technical Info says

```
 Special Features

    USB Powered
```

A USB root hub (both sockets) can provide at most 500mA at 5v of power.  Thats only 2.5W.  

What happens when you overload a USB root hub varies, from absolutely nothing to total shutdown.

I suspect you have a USB power problem

----------

## rndusr

 *Ant P. wrote:*   

> What does `cat /sys/class/block/sdb/queue/scheduler` say? Does changing that affect it at all?

 

It was using cfq, and changing to noop, anticipatory or deadline did not change things for me (at least not noticable).

 *NeddySeagoon wrote:*   

> Your USB device tree shows how all of your USB devices are connected, like the branches of a tree, back to your PC.
> 
> Your PC contains devices called USB root hubs. each root hub is normally a pair of USB sockets.

 

This is what I see in KInfoCenter. Does this illustrate my USB device tree?

 *NeddySeagoon wrote:*   

> I suspect you have a USB power problem

 

The disk is designed for being USB powered, and I have no other devices connected (save the keyboard and mouse). For this reason, I find it unlikely that the power should be insufficient. Or do you mean it could be some power saving function which causes the USB power to be too low for the disk?

----------

## NeddySeagoon

PanzerKanzler,

The 500mA limit comes with a tolerance at the PC end and the HDD end.  When the tolerances work against you, you are in trouble.

Personally, I would not buy a USB powered HDD because of the known power issues.

Even hacks like a USB Y-cable to use power from two root hubs are not reliable.

I assume the keyboard and mouse are on a different root hub to the HDD?

If not, that may push the root hub over the power limit.

Is there anything in dmesg?

----------

## rndusr

Hmm.. After some more testing, it seems that the problem is dependent on file size.

Writing 26.2G (1274 files, smallest 3.5M, largest 95M) gives a transfer time of 489,797 seconds (~55 MBps, which is acceptable)

Writing 6.6G (six 1.1G files) gives a transfer time of 91.423 seconds (~74 MBps, which is good).

Writing one 2.5G file gives a transfer time of 168.837 seconds (~15 MBps, which is poor).

Writing one 3.6G file gives a transfer time of 386.342 seconds (~10 MBps, which is really poor).

What can be the cause?

(Of course, by the innate mischief of things, the files which I need to write are 3.5G-3.8G.)

----------

## eccerr0r

I highly doubt file size is the issue, and have to agree with Neddyseagoon, this is most likely a power issue.  Can you replicate this on another machine?

Standard USB3 ports can provide a bit more power than USB2, if you have a true usb3 cable and straight connection (no usb2 extensions) to the host powered port, you should be able to get 900mA (4.5W) from USB3.  Most laptop HDDs should be satisfied by this though there are a few 5W outliers out there.

I also have this issue with plugs/connectors.  I have a Nokia N900 phone that can draw up to 5W through USB2 given the right conditions for charging the battery.  But contact quality tends to limit this greatly.  Given cheap cables, it won't charge right.  I have only 2 USB cables that will charge this phone correctly and get the 5W to charge the phone.

----------

## rndusr

I have now tried on two other computers (USB2 only, though), and there I do not experience this issue. They both were able to write at about 24 MBps, no matter file size. Unfortunately, I have just one computer with USB3.

I also tried using one of the USB2 ports instead of USB3, but I still have the same issues on this computer.

The transfer times in my last post are still reproducible on this computer. (Writing those same files to another computer over ethernet is very fast, so it is not reading the files that is slow.)

I understand that laptops may be parsimonious with power for the USB ports, but this computer is an ordinary desktop.

(By now, I have written all the large files I needed to write. I had to leave it overnight. Reading them from the disk gives me good rates.)

----------

