RAID Pi – Raspberry Pi as a RAID file server

This mini-project uses a Raspberry Pi as a RAID array controller.  Now it won’t be the fastest raid controller on the planet, but if you’re only doing a bit of streaming, and a bit of backup, and would like a bit of redundancy, then this solution might be for you. OK, maybe not. The performance will be slow. Very slow. This article is not meant to be a serious solution, I just did it because I could. I did it to see if it would work. And it seemed to.
I didn’t even leave it set up long enough to see if the array build would complete. Anyway, while the array was building itself, it seemed to work ok, I could fdisk the partitions, make a file system, etc. So it’s really a proof-of-concept rather than a serious suggestion for a RAID solution. Still, There are crazier things being done with Raspberry Pi! 🙂
Anyway, here’s the physical setup, showing 3 drives connected to a 4-port USB hub connected to the Raspberry Pi. I had a bunch of USB to SATA controllers in a box, recovered from un-used external drive bays. It’d be neater to get some drives in enclosures that sit neatly beside each other, or put them all in one larger case.
3 drives with 1 primary partition each.
# cat /proc/partitions
major minor  #blocks  name
 179        0    7761920 mmcblk0
 179        1      57344 mmcblk0p1
 179        2    7700480 mmcblk0p2
   8        0  156290904 sda
   8        1  156289880 sda1
   8       16  156249999 sdb
   8       17  156248975 sdb1
   8       32  156250000 sdc
   8       33  156248976 sdc1
root@raspberrypi:/home/pi#
# apt-get install mdadm
# mdadm –create /dev/md0 –level=5 –raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1
Now an extra drive appears, /dev/md0
cat /proc/partitions
major minor  #blocks  name
 179        0    7761920 mmcblk0
 179        1      57344 mmcblk0p1
 179        2    7700480 mmcblk0p2
   8        0  156290904 sda
   8        1  156289880 sda1
   8       16  156249999 sdb
   8       17  156248975 sdb1
   8       32  156250000 sdc
   8       33  156248976 sdc1
   9        0  312235008 md0
root@raspberrypi:/home/pi#

Check the status of the array # cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md0 : active raid5 sdc1[3] sdb1[1] sda1[0] 312235008 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [UU_] [=>……………….]  recovery =  8.3% (12961348/156117504) finish=184.8min speed=12909K/sec unused devices: <none> Now fdisk the new virtual disk  and create the desired partition(s). This will create /dev/md0p1 Create a mountable filesystem # mkfs /dev/md0p1 -t ext3 (the mkfs will take a while) Now, mount the drive: # mount /dev/md0p1 /mnt # cd /mnt #mkdir test Raid partition created. A RAID 5 partition will survive one drive failure, giving you time to swap out the failed drive with a good one, and the array will re-build all the parity information automatically, bringing you back up to full redundancy again. Next steps, install SAMBA and share out your new partition on your network….   It’s a this stage that I tore down the setup. The array was only building at 10MB/sec. With the amount of data that I have lying around, (thousands of images from my DSLRs), it’d take ages to put anything onto this array, and almost as long to get anything off. The Raspberry Pi is not to blame in this case, it’s the fact that I’ve put all those drives onto the one USB port. OK, it’d be nice to have SATA interfaces on the Pi. But we don’t. No matter, it’s still a fantastic piece of kit. 🙂  Anyway, I thought it was an interesting exercise. –edit– If you really do want to go ahead an get something like this set up as a file server, you could use the above instructions to set up the raid array, then use the excellent guide by Jeremy Morgan to get samba set up and the whole thing available on the network. –edit– If you’re into serious speed, check out my other blog articles where I use an Infiniband fabric to get over 900MB/sec between PC’s. Now that’s serious performance! 🙂 Be sure to subscribe to the newsletter (top right) and I’ll let you know when I post any interesting new projects or updates. 🙂

9 thoughts on “RAID Pi – Raspberry Pi as a RAID file server”

  1. Great idea, could you initially image one drive and write it onto the other two? would this reduce the build time?
    Would there potentially be an issue with burning out the SD card over a short space of time due to volume of read write?

  2. If you want to try an alternative that may be significantly faster, you can use btrfs instead of mdadm + filesystem. Using btrfs with the RPi may be a serious issue if you want it for the root filesystem, but not for an external device.

    btrfs is still considered experimental, but I think it fits your goal.

    I used it to build a Time Machine equivalent.

  3. One issue can be that you used samba to transfer files to it, did you tried using FTP?

  4. I was thinking of trying the same thing for a home raid server. You’ve saved me the bother and given food for though on the speed limitations. Thanks (from Mayo).

  5. How about using cubieboard? It has SATA…you know what?! I just might do it! 😀

Comments are closed.

%d bloggers like this: