Creating a Software Raid Array in 600 seconds…

Recently I decided that I was going to build a array, after my disk failure on my previous server. This would allow my data to be redundant, even with a disk failure. I debated between hardware and software raid. Hardware raid would be faster, limited to one hardware controller. While with software raid or sometimes called fake raid. I can have the disks across multiple controllers. This again slows the performance of the software raid, but it is the tradeoff, I am willing to accept. I decided on software raid because, if a disk dies, and I cannot get a the same size. I can use a larger disk, and downsize the disk to the size of the other disks in the array.  Also with technology, larger disks do come down in price.

Ubuntu:

1. We need to first install the the raid software.

# apt-get install mdadm

2. Create the partitions on the hard disks.

# fdisk /dev/sda

Command (m for help): p

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xa3e937ed
Device Boot Start End Blocks Id System
/dev/sda1 1 60801 488384001 fd Linux raid autodetect

Next we need to change the partition type to “Linux raid auto”.

Command (m for help): t
Selected partition 1
fd  Linux raid auto
Hex code (type L to list codes): fd

3. Create the software raid array.

# mdadm –create /dev/md0 –chunk=4 –level=5 –raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1

–create creates the software array.
/dev/md0 is the name of the array, the array needs to be md[number]
–chunk the block size of the software array.
–raid-devices how many disks in the array.
/dev/sda1 is the disks that will be included in the array

4. Assemble the software raid array.

# mdadm –assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1

–assemble bundle the disks together.
/dev/md0 the name of the array.
/dev/sda1 the disks in the array.

5. To see the software raid sync you can use the following command.

# watch -n 10 cat /proc/mdstat

When the array is sync’ed it will have 100%. Time it takes depends on the size of the software array.

6. Create the file System upon the software array. You can partition the software array with fdisk.

# mkfs.ext3 /dev/md0

7. Now you can use the software disk array.