Operations 13 min read

Master RAID: Theory, Levels, and Hands‑On mdadm Configuration

This article explains why RAID is needed, breaks down striping and redundancy, compares common RAID levels, contrasts software and hardware implementations, and provides a step‑by‑step mdadm guide for creating, monitoring, and recovering Linux software RAID arrays.

AI Agent Super App
AI Agent Super App
AI Agent Super App
Master RAID: Theory, Levels, and Hands‑On mdadm Configuration

Why Use RAID?

Disk failures are common in servers; RAID mitigates risk by using multiple disks together to provide performance and fault tolerance.

How RAID Works

RAID relies on two core techniques:

Striping : Data is split into chunks and written across several disks simultaneously, increasing throughput roughly by the number of disks.

Redundancy : Data is duplicated (mirroring) or protected with parity calculations so that a failed disk can be reconstructed.

Common RAID Levels

RAID 0 – Pure Striping

Highest read/write performance (N‑fold speed with N disks).

100% capacity utilization.

No redundancy – a single disk failure loses all data.

Typical use: temporary video‑editing cache, high‑speed compute buffers.

Minimum disks: 2.

RAID 1 – Pure Mirroring

Read performance improves (both disks can be read); write speed equals a single disk.

50% capacity utilization.

Can tolerate one disk failure.

Typical use: system/boot partitions, small critical datasets.

Minimum disks: 2.

RAID 5 – Distributed Parity (Most Common)

Read performance good; write incurs a parity‑calculation penalty.

Usable capacity (N‑1)/N (e.g., 4 × 20 GB → 60 GB).

Can tolerate one disk failure.

Risk: if another disk fails during rebuild, data is lost.

Typical use: file servers, web servers, general‑purpose storage.

Minimum disks: 3.

RAID 6 – Dual Parity

Can tolerate two simultaneous disk failures.

Usable capacity (N‑2)/N (e.g., 4 × 20 GB → 40 GB).

Write performance lower than RAID 5 due to extra parity work.

Recommended for large‑capacity arrays where rebuild times are long.

Minimum disks: 4.

RAID 10 – Mirror + Striping

Excellent read/write performance.

Can survive multiple disk failures as long as no mirrored pair loses both disks.

50% capacity utilization.

Typical use: databases, high‑I/O applications where cost is less of a concern.

Minimum disks: 4 (must be an even number).

Level‑by‑Level Comparison

RAID 0 : fastest, zero redundancy.

RAID 1 : safest, highest overhead.

RAID 5 : best price‑performance for most production workloads.

RAID 6 : suited for very large disks, tolerates two failures.

RAID 10 : high performance and redundancy, but costly.

Software RAID vs. Hardware RAID

Hardware RAID uses dedicated RAID cards with processors and cache, delivering strong performance at higher cost. Software RAID relies on the OS kernel; on Linux the md module and mdadm tool manage the array. Modern CPUs make the performance gap small, making software RAID a cost‑effective choice for most scenarios.

mdadm Hands‑On Guide

Install mdadm

yum install -y mdadm   # CentOS/RHEL
apt install -y mdadm   # Ubuntu/Debian

Create RAID 5

Assume five 20 GB disks: sda (system) and sdb‑sde for the array.

mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde

To add a hot‑spare:

mdadm --create /dev/md0 --level=5 --raid-devices=4 --spare-devices=1 /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf

Check RAID Status

Fast status view: /proc/mdstat Detailed view: mdadm --detail /dev/md0 Key fields: Raid Level, Array Size, State (clean or degraded), Active/Working/Failed Devices.

Format and Mount

mkfs.ext4 /dev/md0
mkdir -p /data
mount /dev/md0 /data
df -h /data
echo "/dev/md0 /data ext4 defaults 0 0" >> /etc/fstab

Simulate Failure and Recovery

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

Status changes from [UUUU] to [UU_U], indicating one failed disk while data remains accessible. Replace the failed disk and monitor rebuild progress via /proc/mdstat. Example output shows 45.2% complete, estimated 12 minutes. During rebuild the array is degraded; another failure would cause data loss.

Save Configuration

Write the RAID UUID to /etc/mdadm.conf so the array assembles automatically on boot. Update the initramfs if required:

update-initramfs -u   # Debian/Ubuntu
dracut -f             # CentOS/RHEL

Common mdadm Commands

Stop RAID

umount /data
mdadm --stop /dev/md0

Reassemble existing RAID mdadm --assemble --scan View RAID events in kernel log dmesg | grep -i raid Delete RAID (use with caution)

mdadm --stop /dev/md0
mdadm --zero-superblock /dev/sdb /dev/sdc /dev/sdd /dev/sde

Monitoring and Alerts

Cron job: mdadm --monitor --scan --oneshot [email protected] Daemon mode: mdadm --monitor --scan --daemonize [email protected] Integrate /proc/mdstat parsing into external monitoring systems such as Zabbix or Prometheus.

Conclusion

RAID’s core ideas are striping for performance and redundancy for data safety. Selecting a level balances speed, capacity, and reliability. Linux’s mdadm makes software RAID straightforward; mastering creation, monitoring, and recovery ensures data remains available when a disk fails.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxstorageSystem AdministrationRAIDmdadmdisk redundancy
AI Agent Super App
Written by

AI Agent Super App

AI agent applications, installation, large-model testing, computer fundamentals, IT operations and maintenance exchange, network technology exchange, Linux learning

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.