I was doing some tests today with the Linux kernel’s software RAID support to find out if the Raspberry Pi would be powerful enough for it. I plugged in four identical USB pendrive of 4 GB each, and installed mdadm to setup the RAID volume.
sudo apt-get install mdadm
I created one partition on each USB pendrive with fdisk.
Is is then really easy to setup a RAID volume. First I tried a level 5 raid to see what the overhead of having to calculate parity would do to the write speed.
sudo mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
Next we create a filesystem on the new volume:
sudo mkfs /dev/md0
We mount it:
sudo mount /dev/md0 /testvolume
and that’s all there’s to it.
Testing the write performance:
sudo dd if=/dev/zero of=/testvolume/testfile bs=1024K count=300
300+0 records in
300+0 records out
314572800 bytes (315 MB) copied, 123.694 s, 2.5 MB/s
Now that was somewhat disappointing!
Perhaps a RAID 10 would be a better choice for the Pi because it needs less of its precious CPU cycles.
pi@raspberrypi ~ $ sudo dd if=/dev/zero of=/repository/testfile bs=1024K count=300
300+0 records in
300+0 records out
314572800 bytes (315 MB) copied, 27.508 s, 11.4 MB/s
This performance is comparable, but slightly faster than using no RAID at all and writing straight to the pendrive(~ 7MB/s) .
Then I tested read performance, which again shows similar performance when compared to using a single USB pendrive.
pi@raspberrypi ~ $ sudo dd if=/repository/testfile of=/dev/null bs=1024K count=300
300+0 records in
300+0 records out
314572800 bytes (315 MB) copied, 1.66819 s, 189 MB/s
My conclusion: When it comes to performance, the Pi doesn’t benefit at all from putting multiple pendrives in RAID because the IO of the drive isn’t the limiting factor. However using RAID 1 or 10 on the Pi is still a nice solution for those looking to add some redundancy to the filesystem. For example when using the Pi as a NAS or SVN repository.
Stefan Heid
April 10th, 2016 at 09:47
Without the “conv=fsync” option your dd comparison is not really saying anything, because you can not make sure that linux doesn’t cache the data.
Since usb2 is limited to theoreticly 60MB/s and pratically to 35MB/s your 189MB/s gives a slight hint for cache.