How to Fix Raspberry Pi Slow USB Drive Write Speed Problem

A simple guide to fix the super slow USB HDD write speed on Raspberry Pi

One thing I notice after owning some Rapsberry Pis for about 4 years, the default write speed on one of its USB port is very slow, especially when you attach an external HDD with NTFS format.

To see what I mean, let’s check the write speed directly.

I assume you’re using Raspbian, or its derivative, as the OS.

First, change the working directory to your attached usb drive.

cd /media/pi/$HARD_DRIVE_LABEL

Then we can simulate file writing using dd tool. The following command will create binary file called test.bin with 1000 MB of size (or roughly 1 GB).

$ dd if=/dev/zero of=test.bin bs=10M count=100
100+0 records in
100+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 755.422 s, 1.4 MB/s

As you can see, the last line is the avergage write speed when performing dd command. It’s only 1.4 MB/s! That’s slower than my fiber optic internet.

The results may vary for everyone, but you get the idea how slow it is.

To solve this, we need to remove sync from MOUNTOPTIONS variable. This variable is written at /etc/usbmount/usbmount.conf file.

So let’s open the file and modify it.

sudo -E vim /etc/usbmount/usbmount.conf

Find MOUNTOPTIONS variable declaration. The default text will look like following snippet.

MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime,uid=1000,gid=1000"

Next, remove sync text from it. After you’ve done that, the text will look like following snippet.

MOUNTOPTIONS="noexec,nodev,noatime,nodiratime,uid=1000,gid=1000"

Save and close your editor. Then reboot your Raspberry pi.

sudo reboot

To see the updated speed, let’s test it again with dd similar with previous test.

$ dd if=/dev/zero of=test.bin bs=10M count=100
100+0 records in
100+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 44.0051 s, 23.8 MB/s

Now as you can see, the new write speed become 23.8 MB/s! It’s 17x times faster than previous test. That should be normal speed for an external HDD attached to USB 2.0 port.

That’s all I can write today. As always, thanks for reading. Will post more articles like this in the future.

References

Cover Photo by Harrison Broadbent on Unsplash