How to Configure RAID 0 on Oracle Linux 8.6

To Configure RAID 0 On Oracle Linux 8.6

Introduction:

RAID 0 (disk striping) is the process of dividing a body of data into blocks and spreading the data blocks across multiple storage devices. Striping spreads data across more physical drives, multiple disks can access the contents of a file, enabling writes and reads to be completed more quickly, so when one disk fails, the other disk also will fail along with it.

Installation Steps:

Step1: Check the Oracle Linux version by using the following command.

[root@linuxhelp linuxhelp]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="8.6"
ID="ol"

Step 2: Install the mdadm package which is a RAID managing tool by using the following command.

[root@linuxhelp linuxhelp]# 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.v
  Verifying  : mdadm-4.2-2.el8.x86_64 2/2 
Updated:
  mdadm-4.2-2.el8.x86_64  
Complete

Step 3: check whether the device is available to configure RAID by running the following lsblk command.

[root@linuxhelp linuxhelp]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    0   20G  0 disk 
├─sda1        8:1    0    1G  0 part /boot
└─sda2        8:2    0   19G  0 part 
  ├─ol-root 252:0    0   17G  0 lvm  /
  └─ol-swap 252:1    0    2G  0 lvm  [SWAP]
sdb           8:16   0   10G  0 disk 
sdc           8:32   0   10G  0 disk 
sr0          11:0    1 1024M  0 rom  

Step 4: Create the partition for two disks by executing the below command

[root@linuxhelp linuxhelp]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x9fbd27d7.
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-20971519, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-20971519, default 20971519): +5G
Created a new partition 1 of type 'Linux' and of size 5 GiB.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): l

Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.

Command (m for help): p
Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9fbd27d7
Device      Boot Start       End              Sectors      Size   Id       Type
/dev/sdb1   2048        10487807      10485760   5G    fd     Linux raid autodetect
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

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

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

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

Step 6: Create the md device and select the RAID levels by using the below command.

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

Step 7: Verify the status of RAID level by using the below command.

[root@linuxhelp linuxhelp]# mdadm -E /dev/sd[b-c]1
/dev/sdb1:
  Raid Level : raid0
Device Role : Active device 0
/dev/sdc1:
  Raid Level : raid0
Device Role : Active device 1

Step 8: To verify the md device status, run the below command.

[root@linuxhelp linuxhelp]# mdadm --detail /dev/md0
Number   Major    Minor  RaidDevice    State
       0          8             17            0                active sync   /dev/sdb1
       1           8            33            1                active sync   /dev/sdc1

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

[root@linuxhelp linuxhelp]# mkfs.ext4 /dev/md0
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 2618880 4k blocks and 655360 inodes
Filesystem UUID: 43b2f1de-bebe-412b-bc2a-645e86dfb8c5
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

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

[root@linuxhelp linuxhelp]# mkdir /mnt/raid0
 [root@linuxhelp linuxhelp]# blkid /dev/md0
/dev/md0: UUID="43b2f1de-bebe-412b-bc2a-645e86dfb8c5" BLOCK_SIZE="4096" TYPE="ext4"

 [root@linuxhelp linuxhelp]# vim /etc/fstab
UUID=43b2f1de-bebe-412b-bc2a-645e86dfb8c5  /mnt/raid0 ext4 defaults 0 0

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

[root@linuxhelp linuxhelp]# mount -av
/                        : ignored
/boot                    : already mounted
none                     : ignored
mount: /mnt/raid0 does not contain SELinux labels.
       You just mounted an file system that supports labels which does not
       contain labels, onto an SELinux box. It is likely that confined
       applications will generate AVC messages and not be allowed access to
       this file system.  For more details see restorecon(8) and mount(8).
/mnt/raid0               : successfully mounted

[root@linuxhelp linuxhelp]# df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             315M     0  315M   0% /dev
tmpfs                344M     0  344M   0% /dev/shm
tmpfs                344M  5.8M  339M   2% /run
tmpfs                344M     0  344M   0% /sys/fs/cgroup
/dev/mapper/ol-root   17G  5.9G   12G  35% /
/dev/sda1           1014M  323M  692M  32% /boot
tmpfs                 69M   28K   69M   1% /run/user/1000
/dev/md0             9.8G   37M  9.3G   1% /mnt/raid0

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to Configure RAID 0 on Oracle Linux 8.6. Your feedback is much welcome.

FAQ
Q
What is the advantage of RAID 0?
A
The main advantage of RAID 0 and disk striping is improved performance.
Q
How is data stored in RAID 0?
A
A stream of data is divided into multiple segments or blocks and each of those blocks is stored on different disks.
Q
What happens if you reset disks to non-raid?
A
When performing this operation, all data on the RAID drives is lost.
Q
Does a RAID 0 protect against data loss?
A
It does not provide any protection against data loss.
Q
How many disks can a RAID 0 have?
A
The minimum Driver required for RAID 0 is 2.