How to configure RAID 0 on CentOS 7

To configure RAID 0 on CentOS 7  

RAID (Redundant Array of Independent Disks) is a data storage virtualization technology that combines multiple physical disk drive components into a single logical unit for the purposes of data redundancy, performance improvement, or both. The data is distributed across the drives in one of several ways, referred to as RAID levels, depending on the required level of redundancy and performance. The disks are connected together to make a logical volume. It offers an excellent performance and this performance will vary depending on the RAID level. The two types of RAID are hardware RAID and software RAID. This tutorial covers the configuration procedure of RAID 0 on CentOS 7. 

 

RAID Levels

  • RAID 0
  • RAID 1
  • RAID 5
  • RAID 6 
  • RAID 10

RAID 0 – Stripe
RAID 0


RAID 0 consists of striping, without mirroring or parity. The capacity of a RAID 0 volume is the sum of the capacities of the disks in the set, the same as with a spanned volume. There is no added redundancy for handling disk failures, just as with a spanned volume. Both disks appear as a single partition, so when one of them fails, it breaks the array and results in data loss. RAID 0 uses all the disk capacity . To configure RAID 0, a minimum of two hard disks are required.

 

Configuration procedure

To proceed with the configuration process, install the mdadm package which is a RAID managing tool in the target system for easier partitioning of disks. Run the following command and press y to continue with the installation.

[root@server2 Desktop]# yum install mdadm -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.myfahim.com
 * extras: centos.myfahim.com
* updates: mirror.ehost.vn
.
.
.

  Verifying  : mdadm-3.2.6-31.el7.x86_64                                                            2/2 

Updated:
  mdadm.x86_64 0:4.0-5.el7                                                                              

Complete


The mdadm package has been installed. Now check the if the device is available to configure RAID by running the following lsblk command. The report is shown as below.  

[root@server2 Desktop]#  lsblk

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   30G  0 disk 
sda1     8:1    0  500M  0 part  /boot
sda2     8:2    0 14.7G  0 part  /
sda3     8:3    0  2.5G  0 part  [SWAP]
sdb      8:16   0   10G  0 disk 
sdc      8:32   0   10G  0 disk 

The disk is available for partitioning. Next create the partition for two disks by executing the following command. Enter the following set of commands to create the partition. 

[root@server2 Desktop]# fdisk /dev/sdb

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +5G
Partition 1 of type Linux and of size 5 GiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Command (m for help): p

partition

 

Repeat the above mentioned steps to create partition for another block and provide the Hex code for the partition as 'fd' which is the Linux Raid Autodetect assigned to the partition. 

Next check the block details for any previous configuration that has been made in the disk. Execute the following command to check it. The output shown below states that the disks have no previous RAID partition in the target system.  

[root@server2 Desktop]# mdadm -E /dev/sd[b-c]1
mdadm: No md superblock detected on /dev/sdb1.
mdadm: No md superblock detected on /dev/sdc1.

Create the md device and select the RAID levels in the command. Execute the following commands along with its options. 

[root@server2 Desktop]# mdadm --create /dev/md5 --level=stripe --raid-devices=2 /dev/sd[b-c]1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.

The partition has been done successfully. Now to verify the status of RAID level, run the following command. 

[root@server2 Desktop]# mdadm -E /dev/sd[b-c]1

mdadm command

You can also verify the status of RAID level by executing the following cat command as shown below. 

[root@server2 Desktop]# cat /proc/mdstat

cat command
To verify the md device status, run the following command. 

[root@server2 Desktop]# mdadm --detail /dev/md5

device status
Next create a filesystem for md device by executing the mkfs command followed by the type of filesystem. 

[root@server2 Desktop]# mkfs.ext4 /dev/md5

Now permanently mount the md device by running the blkid command and copy the UUID number. Now create a fstab file using vim editor and enter the copied UUID number in the file. Save and exit the file. 

[root@server2 Desktop]# mkdir /mnt/raid0

[root@server2 ~]# blkid /dev/md5
/dev/md5: UUID= 1de8a17f-bdab-4cf4-9811-fd92af3e9188" TYPE= "ext4"

[root@server2 Desktop]# vim /etc/fstab 
UUID=1de8a17f-bdab-4cf4-9811-fd92af3e9188    /mnt/raid0    ext4    defaults 0 0

The device is mounted successfully and to verify the status of the device, run the following set of commands. 

[root@server2 ~]# mount -av
[root@server2 ~]# df -h

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        15G  4.4G   11G  30% /
devtmpfs        741M     0  741M   0% /dev
tmpfs           749M  140K  749M   1% /dev/shm
tmpfs           749M  8.9M  741M   2% /run
tmpfs           749M     0  749M   0% /sys/fs/cgroup
/dev/sda1       497M  116M  382M  24% /boot
/dev/sr0        3.9G  3.9G     0 100% /run/media/root/CentOS 7 x86_64
/dev/md5        9.8G   37M  9.2G   1% /mnt/raid0

RAID 0 is mainly used for speed and performance, not for fault tolerance. So when one disk fails, the other disk also will fail along with it. 
 

Thus we conclude the configuration procedure of RAID 0 on CentOS 7. 


Thank you! for using Linux Help.

You find this tutorial helpful? Share with your friends to keep it alive.
For more help topics browse our website www.linuxhelp.com
Be the first to comment, we value your suggestions. For further queries please comment below.

Tags: CentOS RAID
user image Author :  Lucas