Software RAID (Redundant Array of Independent Disks) allows you to combine multiple physical disks into a single logical device that provides redundancy, performance, or both — entirely in software without dedicated hardware. On RHEL 9, mdadm is the standard tool for creating and managing software RAID arrays and is included in the default repositories. Unlike hardware RAID, software RAID is transparent, portable across systems, and easily monitored through standard Linux tools. This tutorial covers creating RAID 1 and RAID 5 arrays, checking status, simulating failure, and replacing failed drives.

Prerequisites

  • RHEL 9 system with root or sudo access
  • At least two unformatted block devices (e.g., /dev/sdb, /dev/sdc, /dev/sdd)
  • No existing partitions or filesystems on the target disks
  • Basic familiarity with Linux block devices and disk management

Step 1 — Install mdadm

Install the mdadm package from the default RHEL 9 repositories:

dnf install -y mdadm

# Verify installation
mdadm --version

# List block devices to identify your target disks
lsblk

Step 2 — Create a RAID 1 (Mirror) Array

RAID 1 mirrors data across two disks. If one disk fails, the array continues operating using the other. It offers full redundancy at the cost of half the raw capacity:

# Create RAID 1 with two disks
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc

# Accept the prompt to proceed (type 'y')
# Monitor the initial sync progress
cat /proc/mdstat
watch cat /proc/mdstat   # live updates, Ctrl+C to exit

# Check detailed status
mdadm --detail /dev/md0

The initial resync mirrors all data between the drives. This runs in the background and the array is usable immediately, though performance may be reduced until sync completes.

Step 3 — Create a RAID 5 Array

RAID 5 stripes data and parity across three or more disks. It can survive one disk failure and provides better read performance than RAID 1, with a usable capacity of (n-1) disks:

# Create RAID 5 with three disks
mdadm --create /dev/md1 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd

# Add a hot spare (automatically used if a disk fails)
mdadm --create /dev/md1 --level=5 --raid-devices=3 --spare-devices=1 
  /dev/sdb /dev/sdc /dev/sdd /dev/sde

# Check status
mdadm --detail /dev/md1
cat /proc/mdstat

Step 4 — Create a Filesystem, Mount, and Save Configuration

Format the RAID array with XFS and mount it. Then save the array configuration so it survives reboots:

# Format with XFS
mkfs.xfs /dev/md0

# Create mount point and mount
mkdir -p /raid1
mount /dev/md0 /raid1

# Add to /etc/fstab for persistence
UUID=$(blkid -s UUID -o value /dev/md0)
echo "UUID=$UUID  /raid1  xfs  defaults  0 0" >> /etc/fstab

# Save mdadm configuration so the array assembles on boot
mdadm --detail --scan >> /etc/mdadm.conf

# Update initramfs to include RAID configuration
dracut --force

The dracut --force command rebuilds the initramfs to include the updated RAID configuration, which is essential for the root filesystem RAID to assemble at early boot.

Step 5 — Simulate Disk Failure and Replace a Drive

Testing your failure response procedure before an actual failure is critical. Use mdadm --fail to simulate a failed drive, then remove and replace it:

# Mark a disk as failed (simulated failure)
mdadm --fail /dev/md0 /dev/sdc

# Check status - array should be degraded
mdadm --detail /dev/md0
cat /proc/mdstat

# Remove the failed disk from the array
mdadm --remove /dev/md0 /dev/sdc

# Add a replacement disk (hot-add)
mdadm --add /dev/md0 /dev/sdd

# Watch the rebuild progress
watch cat /proc/mdstat

The array begins rebuilding onto the new disk immediately. During a rebuild, the array is operational but not fully protected. On SSDs, rebuilds complete in minutes; on large HDDs this can take hours.

Step 6 — Monitor RAID Health with Email Alerts

Configure mdadm to send email alerts on array events such as degradation or rebuild completion:

# Add monitoring config to /etc/mdadm.conf
echo "MAILADDR root" >> /etc/mdadm.conf
echo "MAILFROM mdadm@$(hostname)" >> /etc/mdadm.conf

# Enable the mdadm monitoring service
systemctl enable --now mdmonitor.service

# Test alert email
mdadm --monitor --scan --test --oneshot

Conclusion

You have installed mdadm on RHEL 9, created RAID 1 and RAID 5 arrays, formatted and persistently mounted them, saved the configuration to survive reboots, and practiced the full disk failure and replacement workflow. Software RAID with mdadm is a cost-effective and reliable approach to storage redundancy that every Linux administrator should be comfortable managing.

Next steps: How to Configure LVM on RHEL 9, How to Automate Backups with rsync and cron on RHEL 9, and How to Set Up NFS File Sharing on RHEL 9.