How to Configure RAID 0 on Rocky Linux 8.6

To Configure RAID 0 On Rocky Linux 8.6

Introduction:

RAID 0 (disk striping) is the process of separating a body of data into blocks and spreading the data blocks across multiple storage devices. Striping spreads data across more physical drives, and 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 below command

[root@linuxhelp ~]# cat /etc/os-release 
NAME="Rocky Linux"
VERSION="8.6 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky Linux"
ROCKY_SUPPORT_PRODUCT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8"

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

[root@linuxhelp ~]# yum install mdadm
Last metadata expiration check: 0:01:37 ago on Thu 08 Sep 2022 04:36:01 PM EDT.
Dependencies resolved.
=======================================================================================================
 Package               Architecture           Version                     Repository              Size
=======================================================================================================
Installing:
 mdadm                 x86_64                 4.2-2.el8                   baseos                 459 k

Transaction Summary
=======================================================================================================
Install  1 Package
Total download size: 459 k
Installed size: 1.1 M


Is this ok [y/N]: y
Downloading Packages:
mdadm-4.2-2.el8.x86_64.rpm                                             1.2 MB/s | 459 kB     00:00    
-------------------------------------------------------------------------------------------------------
Total                                                                  466 kB/s | 459 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                               1/1 
  Installing       : mdadm-4.2-2.el8.x86_64                                                        1/1 
  Running scriptlet: mdadm-4.2-2.el8.x86_64                                                        1/1 
  Verifying        : mdadm-4.2-2.el8.x86_64                                                        1/1 

Installed:
  mdadm-4.2-2.el8.x86_64                                                                               
Complete!

Step 3: Check whether the device is available to configure RAID by using the below command

[root@linuxhelp ~]# lsblk
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                     8:0    0   25G  0 disk 
├─sda1                  8:1    0    1G  0 part /boot
└─sda2                  8:2    0   24G  0 part 
  ├─rl_linuxhelp-root 253:0    0 21.5G  0 lvm  /
  └─rl_linuxhelp-swap 253:1    0  2.5G  0 lvm  [SWAP]
sdb                     8:16   0    5G  0 disk 
sdc                     8:32   0    5G  0 disk 
sr0                    11:0    1 1024M  0 rom  

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

[root@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 0xbc22ad16.

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-10485759, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-10485759, default 10485759): 
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): 1
Changed type of partition 'Linux' to 'FAT12'.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): l
 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden or  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi ea  Rufus alignment
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         eb  BeOS fs        
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ee  GPT            
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f1  SpeedStor     
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f4  SpeedStor      
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      f2  DOS secondary  
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fb  VMware VMFS    
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fc  VMware VMKCORE 
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fd  Linux raid auto
1c  Hidden W95 FAT3 75  PC/IX           bc  Acronis FAT32 L fe  LANstep        
1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot    ff  BBT            
Hex code (type L to list all codes): fd
Changed type of partition 'FAT12' to 'Linux raid autodetect'.

Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 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: 0xbc22ad16
Device     Boot Start      End  Sectors Size Id Type
/dev/sdb1        2048 10485759 10483712   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.

[root@linuxhelp ~]# fdisk /dev/sdc 
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 0xf943b623.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 
Using default response p.
Partition number (1-4, default 1): 
First sector (2048-10485759, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-10485759, default 10485759): 
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
 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden or  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
1c  Hidden W95 FAT3 75  PC/IX           bc  Acronis FAT32 L fe  LANstep        
1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot    ff  BBT            
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/sdc: 5 GiB, 5368709120 bytes, 10485760 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: 0xf943b623
Device     Boot Start      End  Sectors Size Id Type
/dev/sdc1        2048 10485759 10483712   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.

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 ~]# 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 ~]# 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 ~]# mdadm -E /dev/sd[b-c]1
/dev/sdb1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : b888d1e6:e3c5248e:6a038448:5ec15415
           Name : linuxhelp:0  (local to host linuxhelp)
  Creation Time : Thu Sep  8 16:43:57 2022
     Raid Level : raid0
   Raid Devices : 2
 Avail Dev Size : 10473472 sectors (4.99 GiB 5.36 GB)
    Data Offset : 10240 sectors
   Super Offset : 8 sectors
   Unused Space : before=10160 sectors, after=0 sectors
     State : clean
    Device UUID : dd4c3970:4a47b89d:e7877ba4:97947ae4
    Update Time : Thu Sep  8 16:43:57 2022
  Bad Block Log : 512 entries available at offset 8 sectors
       Checksum : bbc3c40c - correct
         Events : 0
     Chunk Size : 512K		 
   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)

/dev/sdc1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : b888d1e6:e3c5248e:6a038448:5ec15415
           Name : linuxhelp:0  (local to host linuxhelp)
  Creation Time : Thu Sep  8 16:43:57 2022
     Raid Level : raid0
   Raid Devices : 2
 Avail Dev Size : 10473472 sectors (4.99 GiB 5.36 GB)
    Data Offset : 10240 sectors
   Super Offset : 8 sectors
   Unused Space : before=10160 sectors, after=0 sectors
          State : clean
    Device UUID : 3406ae27:9a6dc583:00e3f52d:e1b465a7
    Update Time : Thu Sep  8 16:43:57 2022
  Bad Block Log : 512 entries available at offset 8 sectors
       Checksum : a5ab1f16 - correct
         Events : 0
     Chunk Size : 512K
   Device Role : Active device 1
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)

Step 8: To verify the md device status by using the below command

[root@linuxhelp ~]# mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Thu Sep  8 16:43:57 2022
        Raid Level : raid0
        Array Size : 10473472 (9.99 GiB 10.72 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent
       Update Time : Thu Sep  8 16:43:57 2022
             State : clean 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0
            Layout : -unknown-
        Chunk Size : 512K

Consistency Policy : none
              Name : linuxhelp:0  (local to host linuxhelp)
              UUID : b888d1e6:e3c5248e:6a038448:5ec15415
            Events : 0
    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

[root@linuxhelp ~]# mkfs.ext4 /dev/md0
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 2618368 4k blocks and 655360 inodes
Filesystem UUID: aedbf3b0-2127-4056-bb71-a2e2ca110431
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 ~]# mkdir /mnt/raid0
 [root@linuxhelp ~]# blkid /dev/md0
/dev/md0: UUID="aedbf3b0-2127-4056-bb71-a2e2ca110431" BLOCK_SIZE="4096" TYPE="ext4"

 [root@linuxhelp ~]# vim /etc/fstab 
UUID=aedbf3b0-2127-4056-bb71-a2e2ca110431 /mnt/raid0 ext4 defaults 0 0 

Step 11: The device is mounted successfully and to verify the status of the device by using the below command

[root@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 ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
devtmpfs                       1.8G     0  1.8G   0% /dev
tmpfs                          1.9G     0  1.9G   0% /dev/shm
tmpfs                          1.9G  9.7M  1.8G   1% /run
tmpfs                          1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/rl_linuxhelp-root   22G  5.5G   17G  26% /
/dev/sda1                     1014M  255M  760M  26% /boot
tmpfs                          371M   32K  371M   1% /run/user/0
/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 Rocky 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.