Software RAID using mdadm provides redundant disk storage without requiring a hardware RAID controller, making it ideal for cost-effective high-availability storage on RHEL 8. RAID 1 (mirroring) writes identical data to two disks simultaneously; if one disk fails, the other continues serving data without interruption and the array can be rebuilt onto a replacement drive. This tutorial walks you through installing mdadm, creating a RAID 1 array, formatting and mounting it persistently, monitoring array health, simulating a disk failure, and adding a hot spare for automated rebuilds. All commands require root or sudo access.
Prerequisites
- RHEL 8 system with root or sudo access
- Two or more unpartitioned disks of equal or larger size (e.g.,
/dev/sdband/dev/sdc) - An optional third disk for a hot spare (
/dev/sdd) - Basic familiarity with disk layout commands (
lsblk,fdisk)
Step 1 — Install mdadm and Identify Disks
The mdadm package is the standard tool for managing Linux software RAID arrays. Install it with dnf, then use lsblk and fdisk -l to confirm the disks you intend to use are visible and do not contain existing partitions or data.
dnf install -y mdadm
# List all block devices
lsblk
fdisk -l /dev/sdb /dev/sdc
# Ensure disks have no existing filesystem signatures
wipefs -a /dev/sdb
wipefs -a /dev/sdc
Running wipefs -a removes any leftover partition tables or filesystem signatures. This prevents mdadm from detecting stale superblocks that could cause assembly errors.
Step 2 — Create the RAID 1 Array
Use mdadm --create to assemble the two disks into a RAID 1 mirror. The --level=1 flag sets the RAID type, and --raid-devices=2 tells mdadm how many active members the array requires. The device name /dev/md0 is the resulting virtual block device.
mdadm --create /dev/md0
--level=1
--raid-devices=2
/dev/sdb /dev/sdc
# Monitor initial sync progress
watch -n 2 cat /proc/mdstat
# View detailed array information
mdadm --detail /dev/md0
The initial synchronization (resync) writes identical data to both drives. The array is fully usable immediately but degraded performance during sync is normal. Watch /proc/mdstat until the resync completes before writing critical data.
Step 3 — Format and Mount the Array
Once created, /dev/md0 is treated like any other block device. Format it with XFS and mount it, then add it to /etc/fstab for persistent mounting across reboots.
mkfs.xfs /dev/md0
mkdir -p /data/raid1
mount /dev/md0 /data/raid1
df -h /data/raid1
# Add to /etc/fstab
echo '/dev/md0 /data/raid1 xfs defaults 0 0' >> /etc/fstab
mount -a
Step 4 — Save the mdadm Configuration
RHEL 8 does not automatically persist mdadm array definitions across reboots unless the configuration is written to /etc/mdadm.conf. The --detail --scan flags output the array definition in the correct format to append to the config file.
# Create or update /etc/mdadm.conf
mdadm --detail --scan >> /etc/mdadm.conf
cat /etc/mdadm.conf
# Rebuild the initramfs so the array is assembled at early boot
dracut --force
Running dracut --force regenerates the initramfs image to include the updated mdadm configuration. Without this step, the array may not assemble correctly on the next boot if the system needs it before reaching the root filesystem mount.
Step 5 — Simulate a Disk Failure and Rebuild
Testing your RAID’s fault tolerance before a real failure is essential. Use mdadm --fail to mark a drive as failed, observe the degraded state, then remove the failed drive and replace it with a new one. The array rebuilds automatically once a replacement is added.
# Simulate a failure on /dev/sdb
mdadm --manage /dev/md0 --fail /dev/sdb
mdadm --detail /dev/md0
# Remove the failed device from the array
mdadm --manage /dev/md0 --remove /dev/sdb
# After replacing the disk, add the replacement
# (In a real scenario you would use the new disk here)
wipefs -a /dev/sdb
mdadm --manage /dev/md0 --add /dev/sdb
# Monitor the rebuild
watch -n 2 cat /proc/mdstat
Step 6 — Add a Hot Spare
A hot spare is an idle disk attached to the array that mdadm will automatically use to begin rebuilding the moment a member disk fails, without any manual intervention. Add a third disk as a spare to make your RAID 1 fully self-healing.
# Wipe and add /dev/sdd as a hot spare
wipefs -a /dev/sdd
mdadm --manage /dev/md0 --add /dev/sdd
# Confirm the spare is registered
mdadm --detail /dev/md0 | grep -i spare
# Update /etc/mdadm.conf to reflect the new member
mdadm --detail --scan > /etc/mdadm.conf
dracut --force
Conclusion
You have built a resilient software RAID 1 array on RHEL 8 using mdadm, formatted and persistently mounted it, persisted the configuration in /etc/mdadm.conf, and verified the fault-tolerance mechanism by simulating and recovering from a disk failure. Attaching a hot spare takes redundancy one step further by enabling automatic, zero-intervention rebuilds. Software RAID with mdadm is a mature, production-proven solution that costs nothing beyond the disks themselves and integrates seamlessly with LVM for additional storage flexibility.
Next steps: How to Configure LVM on RHEL 8, How to Automate Backups with rsync and cron on RHEL 8, and How to Set Up NFS File Sharing on RHEL 8.