RAID (Redundant array of independent disks) is used to combines multiple physical disk drive components into a single logical unit for the purposes of data redundancy, performance improvement, or both. In this article, we will configure RAID on 2 Disks. Now since we are talking about 2 disks, means we can either go for RAID0 or RAID1.

RAID0 :: Blocks striping is done on the disks with no mirroring.
RAID1 :: Blocks mirroring is done on the disks with no striping.

Below are the easy steps to configure RAID on the two devices.


1) Install the below mdadm Package.

[root@system /]# yum install mdadm-3.2.6-7.el6.x86_64

2) Run the below command to know the number of disks available in the system.

Here the system is booted from sda1 partition, hence we cannot use sda device as it is being used and is in a busy condition. However, we have two more disks here i.e sdb & sdc of 5GB each as shown below.

[root@system /]# lsblk
 sr0          11:0       1  1024M   0    rom
 sda           8:0       0  30G     0    disk
 sda1          8:1       0  300M    0    part       /boot
 sda2          8:2       0  3G      0    part       [SWAP]
 sda3          8:3       0  26.7G   0    part       /
 sdb           8:16      0  5G      0    disk
 sdc           8:32      0  5G      0    disk

3) Now we will have to create a partition on both the disk for RAID.

Please find the inputs to be given below after running the fdisk command.

[root@system /]# fdisk /dev/sdb
Command (m for help): n                     *n = Create New Partition
Partition number (1-4): 1                   *1-4 partitions can be created
Command (m for help): t                     *t = Change Partition system ID
Selected partition 1
Hex code (type L to list codes): fd         *fd system ID is for LINUX RAID AUTODETECT
Command (m for help): p                     *p = Print Partition table
Command (m for help): w                     *w = write or save the changes done
The partition table has been altered!
[root@system /# fdisk /dev/sdc              *Please provide the same inputs as above to create                                                                            the sdc partition for RAID.

4) We need to run the below command to check if the Raid is already configured on the device partition1 or not.

From the below logs, it is confirmed that no RAID is configured on the devices.

[root@system ~]# mdadm -E /dev/sd[b-c]1
mdadm: No md superblock detected on /dev/sdb1.
mdadm: No md superblock detected on /dev/sdc1.
[root@system /]# cat /proc/mdstat
Personalities :
unused devices:

5) Now, we will create /dev/md0 device and apply RAID level on it.

Please find below commands to create RAID0 or RAID1 on sdb & sdc device as per the requirement.

To Create RAID1 on sdb1 & sdc1 :--
 [root@system /]# mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sd[b-c]1
To Create RAID0 on sdb1 & sdc1 :--
 [root@system /]# mdadm --create /dev/md0 --level=stripe --raid-devices=2 /dev/sd[b-c]1

Suggested Article: 5 Easy Steps to Mount NFS Shared Directory on another Linux Machine

6) We can check from the below command that the RAID is configured successfully.

You can see here ,that after combining both the disk – Array size of RAID1 is 5 GB because of mirroring & Array Size of RAID0 is 10 GB because of stripping.

[root@system /]# mdadm --detail /dev/md0
 Raid Level : raid1
 Array Size : 5233024 (4.99 GB)
 Raid Devices : 2
 Total Devices : 2
 [root@system /]# mdadm --detail /dev/md0
 Raid Level : raid0
 Array Size : 10473472 (9.99 GB)
 Raid Devices : 2
 Total Devices : 2


7) Now we will Create an ext4 filesystem for a RAID device /dev/md0 and mount it under /mnt.

[root@system /]# mkfs.ext4 /dev/md0
[root@system /]# mkdir mnt
[root@system /]# mount /dev/md0 /mnt
[root@system /]# df -ah
Filesystem Size Used Avail Use% Mounted on
/dev/md0    5.0G 138M 4.6G  3%    /mnt

8) Save the array mount point in the /etc/fstab using vi editor to make it persistent even after system reboots.

[root@system /]# vi /etc/fstab
/dev/md0    /mnt     ext4      defaults   1    1

9) Now suppose we want to convert the RAID level from RAID1 to RAID0 or vice versa.

To do that simply we will unmount /dev/md0 FS & then stop /dev/md0 device and finally re-create RAID device as per the requirement.Please find the below steps to do so.

[root@system /]# umount /mnt
[root@system /]# mdadm --stop /dev/md0
mdadm: stopped /dev/md0
[root@system /]# mdadm --create /dev/md0 --level=stripe --raid-devices=2 /dev/sd[b-c]1

Now you are all set to Configure RAID0 or RAID1 on the 2 free devices.

Please leave your comments and feedback in the comment box if you find it beneficial or in case of any doubts.

Leave a Reply

Be the First to Comment!

Notify of