Creating RAID 0, 1 & 5 in Linux/Unix

A 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 an 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 the software is important too and today we are going to make software RAID.

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

 

RAID Partition for RAID 5

 

Steps to create RAID 0

 

RAID 0 (Zero) is popularly known 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 anyone’s disk is failed, you cannot retrieve the data.

 

Create 2 RAID partitions for making RAID 0, here we will take /dev/sda5 and /dev/sda6 for creating RAID 0. Two minimum disks are required to make RAID 0 and it can be made using the 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 known as mirroring and provides good fault tolerance than RAID 0. RAID 1 also needs a minimum of 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 the 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 provides the best fault tolerance and performance. It requires a minimum of 3 devices and we are using /dev/sda9, /dev/sda10, and /dev/sda11 to create a software RAID 5 here.

 

 

Below is the command to create a RAID level 5, it is similar to the 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 the RAID name, partition used in making RAID, RAID size, etc. You can check from the 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

 

We hope you like and found this article useful. If you have any questions or doubts about creating the RAID, let us know through your comments. You can also subscribe to our newsletter to get the latest tutorials and storage news for free.

Buy me a coffeeBuy me a coffee

Add Comment

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