Keep the Hard Drive Bugs Away With RAID

I recently had a hard drive crash and I lost some important files. So I decided to safeguard my backups a little better buy building a RAID (Redundant Array of Independent Disks). The basic idea behind RAID is to combine multiple small, inexpensive disk drives into an array which is more stable than independent disks. This array of drives will appear to the computer as a single logical storage unit or drive.

RAID: Hardware vs. Software

Hardware RAID is just like it sounds, it is a piece of hardware. It is usually faster than a software RAID but you need to have the piece of hardware. The RAID SATA controllers are really coming down in price but you still need to have the hardware.

Software RAID is controlled by the Kernel and it is little slower than the hardware RAID but if you are using it for backups it only has be be faster than the network connection. Plus it is Free!

I went with a software RAID. I had 3 300gig IDE hard drives so I installed them and then configured the RAID.

First you have to set the drives up to take the RAID.

Run fdisk to find all you drives, you don’t want to wipe out the wrong drive by accident.

sudo fdisk -l

In my case the drives were sdc sdd and sde.

sudo fdisk /dev/sde

You must set the tag to fd (Raid Auto-detect), if you need to know how to use fdisk let me know and I can post a short how-to. Repeat this for each drive.

After I change each drive I run partprobe, you probably don’t have to run that until you are done with all of them but I do it just to be sure.

sudo partprobe

Now that your drives are configured lets build the array. I opted for RAID 5. Run the following command to create the array. Be sure to change the drive letters for the ones you configured during the fdisk steps.

sudo mdadm -C /dev/md0 –chunk=64 – -level=5 –raid-devices=3 /dev/sd{c,d,e}1

Now format the array.

sudo mke2fs -j -b 4096 -E stride=16 /dev/md0

After the format is complete check to see if your array is up and running.

sudo mdadm –detail /dev/md0

Next we need to ad the array to the fstab so it comes up during boot.

sudo gedit /etc/fstab

Add in your drive by adding a line something like this (you fstab may be slightly different).

/dev/md0 /RaidArray ext2 defaults,errors=remount-ro 0 1

Remount the drives,

sudo mount -a

Then watch what you have done, the array should be building.

sudo watch cat /proc/mdstat


Now for extra credit, lets set up email notification. This way you can get an email id there is a failure or a drve goes to a degraded state.

sudo gedit /etc/mdadm/mdadm.conf

Add your email

MAILADDR yourname@hostname.com

Start the monitor

sudo mdadm – -monitor /dev/md0 &

There you go! It will be used like a regular drive from now on. If something goes wrong with one of your drives you will not loose all the data, and you should get a email of the failure.

Enjoy!

Leave a Reply

*
Get Adobe Flash player