RAID is abbreviated as (Redundant Array of Independent Disks)

Pre Configured Task for configuring RAID Disc Mirroring

  • Create 4 partitions of size 200 MB each.
  • Combine the first three partitions into a raid  5  array.
  • Make one of the partitions as faulty.
  • Remove the faulty partitions from the raid array.
  • Add the fourth partitions to the raid array.

Configure RAID (Redundant Array of Independent Disks) Disc Mirroring on CentOS/RHEL 7/6/5

Create partition using fdisk
[root@techbrown~]# fdisk /dev/hda

The number of cylinders for this disk is to 9729.
There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with :
Software that runs at boot time (e.g., old versions of LILO)
Booting and partitioning software from other OSs (e.g., DOS FDISK, OS/ 2 FDISK)
Command (m for help) : n

First cylinder (2439-4865,default 2439) :

Using default value 2439

Check if the new partitions have been created

Command I(m for help) : p

Disk/ dev/ hda : 40.0 GB, 40020664320 bytes
255  heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065* 512 = 8225280 bytes
Saving the partitions

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 to update the kernel without restarting the system
[root@techbrown~]# partprobe  /dev/hda
Create the raid device

Syntax :-

[root@techbrown~]# mdadm -C /dev/ md0 -n<number of partitions> <partition1> <partition2> -|<raid level>

Example :- For raid level 5

[root@techbrown~]# mdadm -C /dev/mdo -n3 /dev/hda8 /dev/ hda9 /dev /hda10 -|5
To view the information regarding the raid device
[root@techbrown~]# mdadm -D /dev/mdo
Format the partition

Example :- To format the raid device

[root@techbrown~]# mkfs.ext3 /dev/md0

Mounting
Syntax :-

[root@techbrown~]# mount <option><arguments><partition name><mount point dir>

Example :-

[root@techbrown~]# mount /dev/md0 /mnt

Creating some date
Example :-

[root@techbrown~]# cd  /mnt
[root@techbrown~]# touch file 1 file 2 file 3 file4
[root@techbrown~]# ls
Adding a spare

Syntax :-

[root@techbrown~]# mdadm -a /dev/md0 <new partition>

Example :-

[root@techbrown~]# mdadm  -a /dev/md0 /dev/hda1 1
To view  the information regarding the raid device

Command :-

[root@techbrown~]# mdadm -D /dev /md0
To make a device as faulity
[root@techbrown~]# mdadm  -f  /dev/md0 /dev /hda8
mdadm:set /dev/hda8 faulty in /dev /md0
To see the detail information of /dev/md0
[root@techbrown~]# mdadm -D /dev/md0
To remove the faulty device
[root@techbrown~]# mdadm -r /dev/md0 /dev/hda8
mdadm : hot removed /dev/hda8
[root@techbrown~]# mdadm -D /dev/md0
To stop the raid first unmount the metadevice.
[root@techbrown~]# cd
[root@techbrown~]# umount /dev/md0
[root@techbrown~]# mdadm -S /dev/md0
mdadm:stopped /dev/md0
To activate or assemble the raid metadevice
[root@techbrown~]# mdadm -A /dev/md0 /dev/hda9 /dev/hda10 /dev/hda11
mdadm: /dev/md0 has been started with 3 drives.

Congratulations Now you have configured RAID on CentOS/RHEL 7/6/5