This tutorial is all about how to configure software raid-0 in RedHat Enterprise Linux.Even if you are new to Linux you can easily configure RAID-0 by reading this article.I have written raid-0 creation notes step wise from begining to end.In this article instead of two hard drive i have used two different partitions to show you how to create and configure software RAID-0 in Linux.RAID-0 is also known as No RAID because it doesn’t provides redundancy.To create RAID-0 array minimum device/partitions required is two.RAID-0 write data on different hard drives and hence increase the read-write speed.RAID-0 is needed only where we needs performance but no redundancy.
STEP-1:See the Partition Table before creating RAID.
[root@localhost ~]# fdisk -l Disk /dev/sda: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 2611 20972826 83 Linux
STEP-2:CREATE two disk/partitions which you need to configure software RAID-0.After creating partitions change it partition id to RAID Type.
[root@localhost ~]# fdisk /dev/sda The number of cylinders for this disk is set to 6527. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (2612-6527, default 2612): Using default value 2612 Last cylinder or +size or +sizeM or +sizeK (2612-6527, default 6527): +500M Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First cylinder (2674-6527, default 2674): Using default value 2674 Last cylinder or +size or +sizeM or +sizeK (2674-6527, default 6527): +500M Command (m for help): p Disk /dev/sda: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 2611 20972826 83 Linux /dev/sda2 2612 2673 498015 83 Linux /dev/sda3 2674 2735 498015 83 Linux Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): fd Changed system type of partition 2 to fd (Linux raid autodetect) Command (m for help): t Partition number (1-4): 3 Hex code (type L to list codes): fd Changed system type of partition 3 to fd (Linux raid autodetect) Command (m for help): p Disk /dev/sda: 53.6 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 2611 20972826 83 Linux /dev/sda2 2612 2673 498015 fd Linux raid autodetect /dev/sda3 2674 2735 498015 fd Linux raid autodetect Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks.
STEP3:After creating partitions update the change made to partition table using partprobe command.
Note:In RHEL6 partprobe command doesn’t work.In place of partprobe you can use partx command in RHEL6.
[root@localhost ~]# partprobe
STEP-4:Now create RAID-0 Array using mdadm.
[root@localhost ~]# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sda{2,3} mdadm: /dev/sda2 appears to be part of a raid array: level=raid0 devices=2 ctime=Sun Jun 7 23:01:21 2015 mdadm: /dev/sda3 appears to be part of a raid array: level=raid0 devices=2 ctime=Sun Jun 7 23:01:21 2015 Continue creating array? y mdadm: array /dev/md0 started.
STEP-5:Confirm your RAID Creation using below linux commands.
[root@localhost ~]# cat /proc/mdstat Personalities : [raid0] md0 : active raid0 sda3[1] sda2[0] 995840 blocks 64k chunks unused devices: <none>
You can also see the raid details using below command.
[root@localhost ~]# mdadm --detail /dev/md0 /dev/md0: Version : 0.90 Creation Time : Mon Jun 8 01:48:23 2015 Raid Level : raid0 Array Size : 995840 (972.66 MiB 1019.74 MB) Raid Devices : 2 Total Devices : 2 Preferred Minor : 0 Persistence : Superblock is persistent Update Time : Mon Jun 8 01:48:23 2015 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Chunk Size : 64K UUID : 770729ea:52291fbf:5ce056c3:fed4ebec Events : 0.1 Number Major Minor RaidDevice State 0 8 2 0 active sync /dev/sda2 1 8 3 1 active sync /dev/sda3
STEP-6:Now create a directory,assign a file system and mount it,so that raid array can be used to store data.
[root@localhost ~]# mkdir /RAID0 [root@localhost ~]# mkfs.ext3 /dev/md0 [root@localhost ~]# mount /dev/md0 /RAID0
STEP-7:Now using df command you can check whether your RAID Array is properly created and ready for use or not.
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 20G 2.0G 17G 11% / tmpfs 1014M 0 1014M 0% /dev/shm /dev/md0 958M 18M 892M 2% /RAID0