Friday, February 23, 2007


Simple Software RAID in Linux

RAID is commonly used in production environments to spread the data among multiple disks for higher performance, reliability or capacity. This is a small tutorial for quick setup of RAID 0 or 1 under Linux using mdadm. Fore more advanced configuration and options look elsewhere. Just for records, I have tested this on RHEL 4 update 4.

This document outlines creation of a RAID 0 drive consisting of three partitions /dev/sdb1, /dev/sdc1, and /dev/sdd1. Procedure for RAID 1 should be similar. First we need to prepare the three partitions for RAID. Use fdisk and set partition's system id of all three partitions to fd (Linux raid auto). You may need to reboot after this.

[root@trinity]# fdisk /dev/sdb1
<press t to change partition id>
<type fd as partition id>
<press w to write changes to disk>

Use mdadm to create the array.

mdadm --create /dev/md0 --level=0 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1 --chunk=512

This will create a new drive /dev/md0 with chunk size 512KB. Choice of chunk size depends on application. Default chunk size is 64K. This new drive now ready for use. There is no need to sotre these configurations in any file as mdadm remembers everything for you even after reboot. For example, to create a new ext3 filesystem here use mkfs.ext3 /dev/md0.

Information about the active RAID arrays is displayed in /proc/mdstat. mdadm --detail --scan can also be used.

[root@matrix]# cat /proc/mdstat
Personalities : [raid0]
md0 : active raid0 sdd1[2] sdc1[1] sdb1[0]
      215043072 blocks 1024k chunks

unused devices: 

Labels: , ,

This comment has been removed by a blog administrator.
Post a Comment

Links to this post:

Create a Link

<< Home

This page is powered by Blogger. Isn't yours?