Improving write speeds on External WD Black P10 drive from 24MB/s to 120MB/s

I had a problem where trying benchmarking tests and rsync (not at the same time obviously) to an external WD HDD maxed out at 24MB/s when I know the drive can go up to 150MB/s write speed.

Things I checked initially:

  • Made sure that the drive is plugged into a USB 3.0 port on my PC (tried both front ports as well as the motherboard ports)
  • Tried a different USB 3.0 cable (I tried 3 different cables but got the same result)
  • Tested the cable with an external SSD drive to make sure that there is nothing wrong with the cable itself (I was able to reach 100MB/s with that same cable)

Finally what resolved it (after several hours of research) was enabling the cache on the external drive

Check first:

sudo hdparm -W /dev/sdx
(replace sdx with the correct device name in your case, you can check this using lsblk)

This returned a 0 which means that the cache is off/disabled

then I did:

sudo hdparm -W1 /dev/sdx

(Mod edit: corrected a typo in the above commands)

to enable cache on the drive (check again with the previous command and it should return 1 this time)

Now speeds went from a max of 24MB/s to 120MB/s

Note: the above fix works only temporarily and you’ll need to apply it again each time you connect/disconnect a USB drive. For a permanent solution you’ll need to make a new Udev rule that applies on device connect. Edited: remove udev-usb-sync

System Specs in case it is useful to anyone:
Operating System: Manjaro Linux
KDE Plasma Version: 6.6.4
KDE Frameworks Version: 6.25.0
Qt Version: 6.11.0
Kernel Version: 6.18.26-1-MANJARO (64-bit)
Graphics Platform: Wayland

Edit: Made a few improvements to the text and added a note that this fix is only a temporary solution - also thanks to scotty65 for correcting my inital typo with the hdparm command.

7 Likes

You may want to check if you have the package udev-usb-sync installed on your system.

The script may interfere with your device as it tries to adapt the tranfer to match the device and port capability

3 Likes
❯ pacman -Q udev-usb-sync
udev-usb-sync 1.1-1

Do you recommend that I should remove this package in my situation?

Edit: Below part is not required you just need to remove udev-usb-sync as linux-aarhus suggested (as long as you safely eject the external drive every time to avoid any loss or corruption of data)

I was thinking of making a new udev rule for a more permanent solution as outlined below (I added explanations for whoever might read this in the future):

### Make a new udev rule:

sudo nano /etc/udev/rules.d/99-hdd-cache.rules

### Then write:

ACTION==“add”, SUBSYSTEM==“block”, KERNEL==“sd[a-z]”, ENV{ID_BUS}==“usb”, ATTR{queue/rotational}==“1”, RUN+=“/usr/bin/hdparm -W1 /dev/%k”

(if using nano: control + O to save the file > press enter > control + X to exit)

### Explanation:

ACTION=="add"

# Triggers action when a device is added

SUBSYSTEM=="block"

# has to be a block device i.e. storage device

KERNEL=="sd[a-z]"

# considers any sata disk added (sda, sdb, sdc etc…)

ENV{ID_BUS}=="usb"

# only applied to usb device as opposed to including internal drives as well

ATTR{queue/rotational}=="1"

# this means that it’s a mechanical hard drive, 1 implies a spinning disk

RUN+="/usr/bin/hdparm -W1 /dev/%k"

# runs the hdparm command to that sata disk (%k substitutes the correct sata disk label specified with KERNEL==“sd[a-z]”) which in turn enables the cache write for a big performance boost

What do you think?

If anyone else has other suggestions and/or best practices for this please let me know.

I think it is your system.

Manjaro has included the udev-usb-sync package with all ISO so it is present on all systems.

This has been done to make the use of removable devices more safe for the average user - avoiding data corruption if cache has not yet been written when disk is removed.

If you are aware of the implications you can remove the package - no harm done.

Just remember - be sure to sync cache before removing your device, wait for the prompt to return - cmdline

sync

Or use the eject button in the file manager - don’t remove until the file manager has removed the device.

3 Likes

Ok after doing sudo pacman -Rn udev-usb-sync it seems that write cache is enabled by default now for newly attached usb drives.

no need for hdparm -W1 /dev/sdx or a custom udev rule anymore! :partying_face:

Thank you for clarifying this I appreciate it! :cowboy_hat_face:

As you said I will keep in mind to always eject the drive properly through the system first using KDE’s eject icon from the file manager to avoid any data loss or corruption (I usually do this anyway since I consider it best practice)

Cheers!

1 Like

Yes - because hdparm -W 0 $DEVICE is one of the measures implemented by the package.

1 Like

At least my experience with enclosures, they are not created equal.

But to be fair, the PCIe protocol wasn’t designed for this.

NVMe over USB always incur overhead because they rely on a bridge chip translating NVMe/PCIe commands over the USB protocol, which adds latency and limits performance compared to native PCIe.

The numbers sound about around what I get for consecutive IO for my m.2 enclosure/adapters.

I had one out of my system a couple months ago, just sending and receiving snapshots. Inside my system it was around 300 MB/s, but the same drive in my Ugreen enclosure was 30 MB/s doing the same thing.

Something feels wrong, speeds shouldn’t tank THAT much especially on Nvme or SSDs (even with not the best usb enclosures)

I just tested right now a Crucial BX100 SSD in an external ORICO enclosure [ASMT105x] with KDiskMark (details below)

Bus 002 Device 004: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge, ASM1153 SATA 3Gb/s bridge, ASM1153E SATA 6Gb/s bridge

Try removing udev-usb-sync if you have it installed, otherwise there may be some other reason at play here… don’t settle for 30MB/s over USB! There is a glitch in the Matrix somewhere! :alien_monster:

After the experience I had, I recommend not installing udev-usb-sync by default for users or disabling it for recent kernels (6.18+ maybe? is that safer?)

Because most users (including myself) won’t have any idea why their external drives are running so slow and might just assume that there is something wrong with their drive, or their cables or even linux not being “optimised” for external USB drives/enclosures when the real issue is that write cache has been disabled for them.

It took me several hours of research over a few days to discover the real reason. I even purchased a new USB 3.0 cable thinking that there might have been something wrong with mine (even though I had already tested 3 different cables)

I’m just politely requesting that this be reconsidered internally since a 5x speedup from write cache being enabled is not a small thing at all. It makes an enormous real world difference, especially for people with busy lives… and again most users will not even realise what the issue is or be able to diagnose it while feeling frustrated at why their hardware or why “linux” just isn’t working properly for them.

Thank you once again for helping me find the root cause of the problem. :folded_hands:t2:

Mod edit: Consecutive posts merged.