How to Set Up Software RAID with mdadm on RHEL 7

Software RAID (Redundant Array of Independent Disks) allows you to combine multiple physical disks into a single logical device that provides redundancy, improved performance, or both — without requiring a dedicated hardware RAID controller. On RHEL 7, the mdadm utility is the standard tool for creating and managing Linux software RAID arrays. Software RAID is cost-effective, highly configurable, and often more portable across hardware platforms than controller-based solutions. This tutorial walks through creating a RAID 1 mirror array with mdadm, formatting and mounting it, persisting it across reboots, simulating a disk failure, and replacing a failed drive — all essential skills for RHEL 7 system administrators responsible for server storage reliability.

Prerequisites

  • A RHEL 7 system with root or sudo access
  • At least two additional block devices of equal or similar size (e.g., /dev/sdb and /dev/sdc)
  • The mdadm package (may need to be installed)
  • Basic understanding of disk layouts and partitioning

The examples in this tutorial use RAID 1 (mirroring). Other levels such as RAID 5 (striping with parity) and RAID 6 (dual parity) follow the same general workflow with different --level and --raid-devices values.

Step 1: Install mdadm

Install the mdadm package using yum:

yum install -y mdadm

Verify the installation and check the version:

mdadm --version

Step 2: Identify Available Disks

Identify the block devices that will form the array. They must not be currently mounted or in use by another partition or LVM:

lsblk

Sample output showing two unused disks:

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   20G  0 disk
└─sda1   8:1    0   20G  0 part /
sdb      8:16   0   10G  0 disk
sdc      8:32   0   10G  0 disk

In this example, /dev/sdb and /dev/sdc are available. Confirm there is no existing data or partition table on them:

fdisk -l /dev/sdb /dev/sdc

Warning: Creating an mdadm array on a disk will destroy all existing data on it. Double-check device names before proceeding.

Step 3: Create the RAID 1 Array

Use mdadm --create to assemble the array. The following command creates a RAID 1 mirror named /dev/md0 using two devices:

mdadm --create /dev/md0 
    --level=1 
    --raid-devices=2 
    /dev/sdb /dev/sdc

You will be prompted to confirm:

mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? y

Enter y to proceed. The RAID 1 synchronization (initial resync) begins immediately in the background.

RAID Level Reference

  • RAID 0 — Striping, no redundancy. Maximum performance and capacity, zero fault tolerance.
  • RAID 1 — Mirroring. Full redundancy, survives one disk failure. Requires minimum 2 disks.
  • RAID 5 — Striping with distributed parity. Survives one disk failure. Requires minimum 3 disks.
  • RAID 6 — Striping with dual parity. Survives two simultaneous disk failures. Requires minimum 4 disks.
  • RAID 10 — Mirrored stripes. High performance and redundancy. Requires minimum 4 disks.

Step 4: Monitor Array Status

Check the RAID array status using mdadm --detail or by reading /proc/mdstat:

mdadm --detail /dev/md0

Sample output:

/dev/md0:
           Version : 1.2
     Creation Time : Mon May 11 14:32:18 2026
        Raid Level : raid1
        Array Size : 10475520 (9.99 GiB 10.73 GB)
     Used Dev Size : 10475520 (9.99 GiB 10.73 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

       Update Time : Mon May 11 14:33:01 2026
             State : clean, resyncing
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : resync

           Name : rhel7:0 (local to host rhel7)
           UUID : 1234abcd:5678ef01:23456789:abcdef01
         Events : 17

    Number   Major   Minor   RaidDevice State
       0       8       16        0      active sync   /dev/sdb
       1       8       32        1      active sync   /dev/sdc

Check the real-time sync progress:

cat /proc/mdstat

Sample output during resync:

Personalities : [raid1]
md0 : active raid1 sdc[1] sdb[0]
      10475520 blocks super 1.2 [2/2] [UU]
      [===========>.........]  resync = 62.3% (6530304/10475520) finish=0.4min speed=153600K/sec

unused devices: <none>

When the resync is complete, the array state will change to clean and the progress line will disappear.

Step 5: Format and Mount the RAID Array

Once the array is active (even before resync completes), format it with XFS:

mkfs.xfs /dev/md0

Create a mount point and mount the array:

mkdir -p /mnt/raid1
mount /dev/md0 /mnt/raid1

Verify the mount:

df -hT /mnt/raid1

Step 6: Persist the Array in /etc/fstab

Get the UUID of the RAID device:

blkid /dev/md0

Add the entry to /etc/fstab:

UUID=your-uuid-here  /mnt/raid1  xfs  defaults  0  0

Test the fstab entry:

umount /mnt/raid1
mount -a
df -hT /mnt/raid1

Step 7: Save the RAID Configuration

The mdadm configuration file at /etc/mdadm.conf tells the system how to assemble RAID arrays at boot. Without it, the array may not assemble automatically after a reboot.

mdadm --detail --scan >> /etc/mdadm.conf

Verify the file was updated:

cat /etc/mdadm.conf

Sample output:

ARRAY /dev/md0 metadata=1.2 name=rhel7:0 UUID=1234abcd:5678ef01:23456789:abcdef01

Update the initramfs to include the mdadm configuration so the array can be assembled early in the boot process:

dracut --force

Step 8: Simulate a Disk Failure and Replace the Drive

Testing your failure-recovery process before a real failure occurs is essential. Simulate a disk failure by marking a device as faulty:

mdadm --manage /dev/md0 --fail /dev/sdc

Check the array status — you should see one failed device:

mdadm --detail /dev/md0
cat /proc/mdstat

The array will be in a degraded state but still fully operational, serving reads and writes from the remaining good disk.

Remove the failed device from the array:

mdadm --manage /dev/md0 --remove /dev/sdc

In a real scenario, you would now physically replace the failed disk. Once the new disk is available (e.g., /dev/sdc after replacement), add it back to the array. mdadm will automatically begin rebuilding the mirror:

mdadm --manage /dev/md0 --add /dev/sdc

Monitor the rebuild progress:

watch cat /proc/mdstat

Step 9: Monitor the Array with mdadm –monitor

The mdadm --monitor daemon watches RAID arrays and sends email alerts on events such as disk failures, rebuild completion, or degraded states. Configure the monitoring email in /etc/mdadm.conf:

echo "MAILADDR root@localhost" >> /etc/mdadm.conf

Start and enable the mdadm monitoring service:

systemctl start mdmonitor
systemctl enable mdmonitor

Test the monitoring by running it manually in the foreground:

mdadm --monitor --scan --oneshot -t

You can also configure a scan interval (in seconds):

mdadm --monitor --scan --delay=60 --daemonise

Conclusion

Software RAID with mdadm on RHEL 7 provides a robust, hardware-independent solution for protecting critical data against disk failures. RAID 1 mirroring ensures that a single disk failure results in no data loss and minimal disruption, as the array continues to operate in degraded mode until the failed drive is replaced and the mirror is rebuilt. By saving the array configuration to /etc/mdadm.conf and regenerating the initramfs with dracut, you ensure reliable automatic assembly at boot. Regular simulated failure tests give you confidence that your recovery procedures work before you need them under pressure. Combined with mdadm --monitor alerting, you gain proactive visibility into the health of your storage infrastructure.