jabss
Posts: 69
Joined: Thu May 09, 2013 11:47 am

USB2 or USB3 sticks for RAID1 in the PI?

Thu Jan 09, 2014 3:04 pm

Hello,

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 around 22MB/s 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?

Thanks,
Jabss

User avatar
RaTTuS
Posts: 10616
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: USB2 or USB3 sticks for RAID1 in the PI?

Thu Jan 09, 2014 3:11 pm

personally I've not seen SD card curruption for about a year now.
if you want long term goodness then I would suggest using a small [1.8" or 2.5"] hard disk not a usb stick, it may also be worth using a battery backup system so a power outage is not terminal.

edit
usb3 sticks will not help
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

shuckle
Posts: 565
Joined: Sun Aug 26, 2012 11:49 am
Location: Finland

Re: USB2 or USB3 sticks for RAID1 in the PI?

Thu Jan 09, 2014 3:16 pm

Send data using ethernet, so that you are not dependent on pi files.

jabss
Posts: 69
Joined: Thu May 09, 2013 11:47 am

Re: USB2 or USB3 sticks for RAID1 in the PI?

Thu Jan 09, 2014 3:22 pm

Hello,

Good point, in the post I also wanted to mention that the system is in an attic, but the post was so long that I forgot.
The problem is that in the winter the moisture there can go up to 85% and in the summer, the temperature can go up to 45º, so not so good for HDD disks.

The system is also powered via an UPS, so I guess the power outage situation is covered.

Could you also share why do you think USB3 sticks will not help? Bring some ideas to the table so we could discuss the pros and cons.

Yes, I also considered to store the log files in a remote share. While this could reduce significantly the probability of having a SD/USB corruption (if it is really created by writing log files), it would not eliminate it entirely because the root partition is still being used for the RPI normal operation.

Thanks,
Jabss

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: USB2 or USB3 sticks for RAID1 in the PI?

Sat Jan 11, 2014 11:04 am

For something so critical, maybe you should also look into SLC SD cards rather than the more common MLC cards.

User avatar
hojnikb
Posts: 128
Joined: Mon Jun 04, 2012 3:59 pm
Location: @Home

Re: USB2 or USB3 sticks for RAID1 in the PI?

Sat Jan 11, 2014 2:33 pm

SLC cards won't help, as hes not making so much writes.

Your best bet is to use a quality USB drive and setup your fs to have as little writes as possible. Maybe a F2FS filesystem, that acts writeable, but its really read only would be one option.
For logs, setup a script that sends them to a remote server.

But as far as my expericence go, Pi tends to be quiete stable, when running from USB drive.
+°´°+,¸¸,+°´°~ Everyone should have a taste of UK Raspberry Pie =D ~°´°+,¸¸,+°´°+
Rasberry Pi, SoC @ 1225Mhz :o, 256MB Ram @ 550Mhz, 16GB SD-Card, Raspbian

jabss
Posts: 69
Joined: Thu May 09, 2013 11:47 am

Re: USB2 or USB3 sticks for RAID1 in the PI?

Mon Feb 29, 2016 5:29 pm

Hello,

Some years after (better late then never), I've found a way to overcome SD corruption: FS2RAM.

Code: Select all

sudo apt-get install fs2ram

(and edit /etc/fs2ram/fs2ram accordingly)
Basically this package moves most read/writting to RAM. Its mainly useful in systems that aren't so much RAM hungry.

Hope this helps,
Jabss

User avatar
GTR2Fan
Posts: 1601
Joined: Sun Feb 23, 2014 9:20 pm
Location: South East UK

Re: USB2 or USB3 sticks for RAID1 in the PI?

Mon Feb 29, 2016 5:41 pm

jabss wrote:The problem is that in the winter the moisture there can go up to 85% and in the summer, the temperature can go up to 45º, so not so good for HDD disks.
The moisture might be a problem unless the connectors and logic boards are protected in some way, but according to the millions of spin-hours of data collected by Google across a test group of 100,000 hard drives in 2007, the optimum operating temperature for highest reliability is between 40 and 45°C. Has something happened since 2007 to change this?

http://storagemojo.com/2007/02/19/googl ... xperience/
Pi2B Mini-PC/Media Centre: ARM=1GHz (+3), Core=500MHz, v3d=500MHz, h264=333MHz, RAM=DDR2-1200 (+6/+4/+4+schmoo). Sandisk Ultra HC-I 32GB microSD card on '50=100' OCed slot (42MB/s read) running Raspbian/KODI16, Seagate 3.5" 1.5TB HDD mass storage.

Jsnow0187
Posts: 16
Joined: Sat Feb 27, 2016 11:36 pm

Re: USB2 or USB3 sticks for RAID1 in the PI?

Tue Mar 01, 2016 11:51 am

Honestly, you can get quality usb 3.0 sticks for a few dollars more, (i got a 3 pack of toshiba 16gb for around 15 at best buy.). Unless you are saving pennies to eat, just get the USB 3 n be done with it. If you ever have to use the if you ever use them for another application youll thank yourself.

Usb 3 may not be an improvement but usb 2 has no pros over usb3 only possible cons

Return to “Advanced users”