Creating RAID 0, 1 & 5 in Linux/Unix

Few months back we created a tutorial on how to create filesystem partition for your RAID requirement and we got a very good response. Today, in this tutorial we are going to create RAID 0, 1 and 5 using our RAID partitions.

 

Creating RAID 0, 1 and 5 in Linux

 

As we told earlier RAID is acronym of Redundant Array of Inexpensive disk and is a widely used technology in IT and storage industry. RAID is mainly used due to its good performance and fault tolerance capability. In industry mainly hardware RAID is used but software is important too and today we are going to make software RAID.

We have already learned how to make RAID partition and had made 3 RAID partition for our tutorial which are sda5, sda6, sda7…sda11, all with hex code “fd” as shown below for only 3 partition.

 

RAID Partition for RAID 5

 

Steps to create RAID 0

 

RAID 0 (Zero) is popularly know as stripping in which data is written/divided into each block of disc one by one and does not have any fault tolerance capability. If any one disk is failed, you cannot retrieve the data.

 

Create 2 RAID partition for making RAID 0, here we will take /dev/sda5 and /dev/sda6 for creating RAID 0. Two minimum disk are required to make RAID 0 and and it can be made using below command.

 

#mdadm -Cv /dev/md0 --level=0 -n 2 /dev/sda5 /dev/sda6

 

Software RAID 0 creation

 

Here,

mdadm : Manage MD devices or Linux Software raid
/dev/md0: Name of new RAID 0
–level: This defines the RAID level
-n: Specify number of active devices in array.

 

Steps to create RAID 1

RAID 1 is also know as mirroring and provide good fault tolerance then RAID 0. RAID 1 also needs minimum 2 devices and data in one disk is exact replica of data in disk 2 thus providing good fault tolerance.

 

Recommended Article: How to do Online Storage Migration in Unix/Linux

 

We will use same command mdadm to create RAID 1 as we did in RAID 0 creation, just we have to replace 0 with 1 on level switch like below.

 

#mdadm -Cv /dev/md1 --level=1 -n 2 /dev/sda7 /dev/sda8

 

Raid level 1 creation

 

Steps to create RAID 5

 

RAID 5 is the most used RAID level and is a combination of striping and parity. It provide best fault tolerance and performance. It requires minimum 3 devices and we are using /dev/sda9, /dev/sda10 and /dev/sda11 to create software RAID 5 here.

Below is the command to create RAID level 5, it is similar to above commands.

 

#mdadm -Cv /dev/md2 --level=5 -n 3 /dev/sda9 /dev/sda10 /dev/sda11

 

RAID level 5 Creation

 

Command to check to RAID statistics

 

After creating different RAID levels, you can easily check their mini detail by using cat /proc/mdstat command. This command will show RAID name, partition used in making RAID, RAID size etc. You can check from below screenshot that RAID 1 is showing only 1 partition space because it only use one disk to save the data and other is used for replication only.

 

RAID stats

 

Hope you like and found this article useful. If you have any questions or doubt in creating the RAID, let us know through your comments. You can subscribe to our newsletter also to get latest tutorials and storage news.

Add Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Privacy Preference Center