Saturday, May 5, 2012

Hybrid HDD + SSD RAID1

Not really security-related at all, but this is just damn cool. After killing three SSDs in 18 months (thankfully the drives were under warranty, but my data wasn't), I went looking for a better solution. When SSDs crap out, they go suddenly and catastrophically. There's no putting them in the freezer or swapping controller boards with another unit like you can with a mechanical hard drive. Once the sector mapping tables - which are constantly being updated due to wear-leveling algorithms - get corrupted, you're pretty much not getting your data back. Turns out there's a simple way to combine the speed benefits of an SSD with the reliability of an HDD-backed RAID1 mirror.

How to do it with Linux Software RAID

The trick is to create the RAID1 array and set the HDD(s) during creation as "write-mostly". This will cause the kernel to only do (slow) reads from the HDD if they are really needed. All other reads will go to the SSD. This option was originally added when mirroring over a slow network interface, but performs equally well to concentrate reads on an SSD. Here is how to do it. http://tansi.info/hybrid

How to convert a single drive into a mirror (RAID1 or RAID10) using Linux mdadm

Drives are cheap nowadays, and your data is valuable. Buy a second disk, and convert your system to a RAID1 or RAID10 mirrored drive setup using Linux software RAID. http://iiordanov.blogspot.com/2011/04/how-to-convert-your-single-drive-linux.html

How to do it from scratch in one command

So there's actually one more mdadm command line option that we want to use to help out with the HDD's slower write performance: "write-behind". It takes a parameter representing the maximum number of outstanding write operations. The default is 256, so I've quadrupled that to 1024 to give the SSD a decent head start on the mirroring. Unfortunately there doesn't seem to be a good way to turn this on after the fact (even if you already have the prerequisite write-intent bitmap in place), so here's the full command you'll want to run from a rescue environment to do the initial RAID setup *before* installing Linux:

# mdadm --create /dev/md0 --level=1 --raid-devices=2 --bitmap=internal --write-behind=1024 /dev/sda1 --write-mostly /dev/sdb1

No comments:

Post a Comment