I could see quite a few posts about USB and RAID on the raspberry PI but I'd like to share some thoughts about it, so here we go:
I'm using my raspberry PI for a more-or-less critical function that is domotics and burglar alarm in my house. Whenever a sensor detects presence, an entry is logged in a text log file. Even with a quality SD card (Kingston 4GB Class 4) I lost everything due to filesystem corruption, so I recently moved the root partition to a 8GB USB 2.0 stick, connected via a powered USB2.0 HUB. When I got the corruption, I was out on vacations - therefore unable to provide immediate local assistance. As you can understand, this is not acceptable for a burglar alarm...
I don't know how much time will take until I have an eventual corruption in the new USB stick (it seems the number of read/writes on flash drives is limited), but now I have an image backup of it (made with the Win32DiskManager) and if it fails I can use it to recover from the fault. However, this always requires immediate local assistance (I need to be around to change the USB stick - Not good enough if it gets corrupted when I'm on vacations). I call this Manual Fault Recovery
I'd like to improve this Manual Fault Recovery
to a Fault Avoidance
setup, where I could use two USB sticks (still to decide if USB2.0 or 3) mirrored in RAID 1. Since its unlikely that both fail at the same time, I'd still have the system up and running in case of a single USB stick gets corrupted, giving me time to prepare the change (or to continue having relaxed vacations
). As you can agree, performing a rsync every night wouldn't help.
Now, considering a raid1 setup, we all know both USB sticks will share the same USB2.0 BUS on the PI (that is also shared with the Ethernet port), so, I assume that the writing would be sequential: First into a USB stick and only then into the second one (Reading will be the same, as it shouldn't matter where to get the information from). At least, when writing, a performance degradation should happen.
A common USB2.0 USB stick would have reading speeds
and ~14MB/s writing speeds
and the effective throughput of the USB2.0 bus
is around 35 MB/s
, which leads me to assume that if there isn't anything else using the USB bus, the bottleneck is the USB2.0 Stick. So I'm considering the use USB3.0 sticks. Any USB3.0 stick that has higher reading/writing speeds than 35MB/s will use all the available bandwidth of the USB2.0 BUS, and reduce the writing performance drop introduced by the RAID1 setup.
Of course this is just true if there is nothing else using the USB bus. If I create a SMB/NFS share (and use it) or if a attach a webcam to the system, the available bandwidth on the USB2.0 bus will be much less and there will be no difference on using an USB3 or USB2 stick.
I think that's why RPI shouldn't be used as a RAID NAS when performance is a requirement. When writing, the same information would be passing through the USB bus 3 times: Firstly when coming via IP, secondly when writing on the first mirror, and thirdly when writing on the second mirror.
Although all of this seems to make sense, Id like to ask if t would be technically accurate.
What comments could you kindly share about this?