Tuesday, February 9, 2010

Software RAID in Linux (RHEL,CentOS)

This RAID Practical is tested on RHEL & CentOS 5x

Remember :-
For RAID 5, minimum 3 physical partitions.
For RAID 0, minimum 2 physical partitions.(Disk data striping across both drives)
For RAID 1, minimum 2 physical partitions.(Disk Mirroring)

* Use fdisk /dev/sd* OR fdisk /dev/hd* command to create more then two (whatever you need) partitions. (where sd*/hd* means sda,sdb,hda,hdb......)

(sd : SATA/SCSI Drive ; hd : IDE Drive)

* To check your drive identity, use "fdisk -l" & check the partition identity.

I am taking "sda" as physical drive & creating 4 partitions. So, the command will be

fdisk /dev/sda


(Note : Create 4 partitions, 250MB each for practical purpose only,which is necessary to create data redundancy. In real world,you can assign whatever size available in your server/desktop)


Press "n" for new partition.
Press "t" to change the partition id.

Select the partition to want to assign "RAID" id.

Press "L" to select from the available list. In our case, select "fd"

Press "w" to write changes to disk & exit

* use "partprobe" command

Now, to create RAID 5,

mdadm -C /dev/md0 -a yes -l 5 -n 4 /dev/sda{2,3,4,5}

( -l means RAID Level which is 5 here)
( -n means number of physical drives,which is 4 here)


mkfs.ext3 /dev/md0 (To make file system)

mdadm --detail /dev/md0 (To check whether RAID has created or not)

Create a directory,i.e. "data1" on "/" partition.& mount /dev/md0 on it. The commnd is
mount /dev/md0 /data


Finally, mount RAID drives permanently during Linux Reboot,
/etc/fstab, make following entry.

/dev/md0 /data ext3 defaults 0 0

That's it.

No comments:

Post a Comment