⚡ RAID Overview

Storage Series: Part 1 — LVM Basics  |  Part 2 — LVM Management  |  Part 3 — LVM Snapshots  |  Part 4 — RAID Overview

What is RAID?

RAID — Redundant Array of Independent Disks — combines multiple physical disks into a single logical unit to achieve redundancy, performance, or both. On Linux, software RAID is implemented by the kernel's MD (Multiple Devices) subsystem and managed with mdadm.

RAID protects against disk failure — not against accidental deletion, filesystem corruption, or ransomware. It is a high-availability tool, not a backup solution. RAID and backups serve different purposes and both are needed in production.

RAID Levels

RAID 0 — Striping

Min disks: 2

Redundancy: None

Capacity: 100% of all disks

Read/Write: Fastest — parallel I/O

Data striped across all disks. One disk fails → all data lost. Pure performance play.

RAID 1 — Mirroring

Min disks: 2

Redundancy: N-1 disks can fail

Capacity: 50% (one disk worth)

Read/Write: Fast reads, normal writes

Every disk is a complete mirror. Simplest redundancy. Good for boot/OS drives.

RAID 5 — Striping + Parity

Min disks: 3

Redundancy: 1 disk can fail

Capacity: (N-1) disks

Read/Write: Good reads, slower writes

Parity distributed across all disks. Good balance of capacity and redundancy.

RAID 6 — Double Parity

Min disks: 4

Redundancy: 2 disks can fail

Capacity: (N-2) disks

Read/Write: Good reads, slowest writes

Two parity blocks. Recommended for large arrays where rebuild time is long.

RAID 10 — Mirror + Stripe

Min disks: 4

Redundancy: 1 per mirror pair

Capacity: 50% of all disks

Read/Write: Fastest with redundancy

Stripes across mirrored pairs. Best performance and redundancy — costs capacity.

RAID Level Diagrams

RAID 0 (Stripe) — 4 disks, maximum speed, zero redundancy: Disk1 Disk2 Disk3 Disk4 A1 A2 A3 A4 B1 B2 B3 B4 RAID 1 (Mirror) — 2 disks, full redundancy, half capacity: Disk1 Disk2 A A B B RAID 5 (Stripe+Parity) — 4 disks, 3 usable, 1 disk can fail: Disk1 Disk2 Disk3 Disk4 A1 A2 A3 Ap B1 B2 Bp B3 C1 Cp C2 C3 RAID 10 (Mirror+Stripe) — 4 disks, 2 usable, best performance+redundancy: Disk1 Disk2 Disk3 Disk4 A1 A1 A2 A2 B1 B1 B2 B2

Examples

1
Create a RAID Array — mdadm --create
# Install mdadm if not present
sudo dnf install -y mdadm     # RHEL/CentOS
sudo apt install -y mdadm     # Debian/Ubuntu

# Create RAID 1 (mirror) from two disks
sudo mdadm --create /dev/md0 \
    --level=1 \
    --raid-devices=2 \
    /dev/sdb /dev/sdc

# Create RAID 5 from four disks
sudo mdadm --create /dev/md1 \
    --level=5 \
    --raid-devices=4 \
    /dev/sdb /dev/sdc /dev/sdd /dev/sde

# Create RAID 6 — double parity
sudo mdadm --create /dev/md2 \
    --level=6 \
    --raid-devices=6 \
    /dev/sd{b,c,d,e,f,g}

# Create RAID 10 — four disks
sudo mdadm --create /dev/md3 \
    --level=10 \
    --raid-devices=4 \
    /dev/sdb /dev/sdc /dev/sdd /dev/sde

# Confirm creation started (sync in progress)
cat /proc/mdstat
/proc/mdstat during initial sync:
Personalities : [raid1] [raid5] [raid6] md0 : active raid1 sdc[1] sdb[0] 976773120 blocks super 1.2 [2/2] [UU] md1 : active raid5 sde[3] sdd[2] sdc[1] sdb[0] 2930231296 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [UUU_] [=====>...............] recovery = 28.3% (277504/976773120) finish=142.4min
Initial sync takes time. A new RAID array must sync all disks before it is fully redundant. The array is usable during sync but not yet protected. Monitor with cat /proc/mdstat or watch -n5 cat /proc/mdstat.
2
Format, Mount, and Make Persistent
# Format the RAID device like any block device
sudo mkfs.xfs /dev/md0
sudo mkfs.ext4 /dev/md1

# Mount it
sudo mkdir -p /data/raid
sudo mount /dev/md0 /data/raid

# Save mdadm configuration (essential for persistence)
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
# or on RHEL:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf

# Update initramfs so array assembles at boot
sudo update-initramfs -u          # Debian/Ubuntu
sudo dracut --force               # RHEL/CentOS

# Add to /etc/fstab for automatic mount
echo "/dev/md0  /data/raid  xfs  defaults  0 2" | sudo tee -a /etc/fstab

# Verify
sudo mount -a
df -h /data/raid
⚠️ Always save the mdadm config and update initramfs. Without these steps the RAID array may not assemble automatically on reboot — the system may boot with degraded or missing storage. This is the most commonly skipped step in RAID setup.
3
Monitor RAID Status
# Quick status of all arrays
cat /proc/mdstat

# Detailed status of one array
sudo mdadm --detail /dev/md0

# Status of all arrays
sudo mdadm --detail --scan

# Check individual disk status within array
sudo mdadm --examine /dev/sdb

# Watch sync/rebuild progress live
watch -n5 cat /proc/mdstat

# Enable email alerts for RAID events
sudo vi /etc/mdadm/mdadm.conf
# Add: MAILADDR admin@yourdomain.com

# Test email alerting
sudo mdadm --monitor --scan --test --oneshot
mdadm --detail /dev/md0 output:
/dev/md0: Version : 1.2 Creation Time : Mon Apr 14 09:00:00 2026 Raid Level : raid1 Array Size : 976773120 (931.51 GiB 1000.22 GB) Used Dev Size : 976773120 (931.51 GiB 1000.22 GB) Raid Devices : 2 Total Devices : 2 Persistence : Superblock is persistent Update Time : Tue Apr 15 10:00:00 2026 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Name : server:0 UUID : abcd1234:ef567890:... Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sdb 1 8 32 1 active sync /dev/sdc
💡 State field tells the story: clean = healthy, degraded = disk failed but array operational, recovering = rebuilding after replacement, resyncing = initial sync or check in progress, failed = array non-functional.
4
Simulate and Handle a Disk Failure
# Mark a disk as faulty (simulate failure for testing)
sudo mdadm /dev/md0 --fail /dev/sdb

# Check degraded status
cat /proc/mdstat
sudo mdadm --detail /dev/md0

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

# Physically replace the disk, then add the new disk
sudo mdadm /dev/md0 --add /dev/sdb

# Watch the rebuild
watch -n10 cat /proc/mdstat
/proc/mdstat during rebuild:
md0 : active raid1 sdb[2] sdc[1] 976773120 blocks super 1.2 [2/1] [_U] [=========>...........] recovery = 47.2% (460914688/976773120) finish=88.2min speed=97.4M/s
[UU] means healthy, [_U] means degraded. Each U in the bracket represents an active disk. An underscore _ means that disk position is failed or missing. For RAID 1 with 2 disks: [UU] = both healthy, [_U] = one failed but array still running.
5
Add a Hot Spare

A hot spare sits idle in the array and automatically begins rebuilding the moment a disk fails:

# Add a spare disk to an existing array
sudo mdadm /dev/md0 --add /dev/sdd

# Verify spare is listed
sudo mdadm --detail /dev/md0 | grep -A5 "Spare"

# Create array with spare included from the start
sudo mdadm --create /dev/md1 \
    --level=5 \
    --raid-devices=4 \
    --spare-devices=1 \
    /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf
mdadm --detail showing spare:
Number Major Minor RaidDevice State 0 8 16 0 active sync /dev/sdb 1 8 32 1 active sync /dev/sdc 2 8 48 - spare /dev/sdd
💡 Hot spares are worth the disk cost. Without a spare, a disk failure leaves the array degraded until someone physically replaces the disk — which could be hours or days. With a spare, the rebuild starts in seconds automatically. For 24/7 production arrays, always include at least one hot spare.
6
Grow a RAID Array — Add Disks
# Add a new disk to RAID 5 (increases array size)
sudo mdadm /dev/md1 --add /dev/sdf

# Grow the array to use the new disk
sudo mdadm --grow /dev/md1 --raid-devices=5

# Watch the reshape (can take hours on large arrays)
watch -n10 cat /proc/mdstat

# After reshape completes — resize the filesystem
# ext4:
sudo resize2fs /dev/md1

# XFS (must be mounted):
sudo xfs_growfs /data/raid

# Verify
df -h /data/raid
⚠️ RAID reshape is risky. Growing a RAID 5 array involves a reshape operation — every block is rewritten. If power is lost during reshape the array can be corrupted. Take a full backup before growing any RAID array. The reshape can take many hours on large arrays.
7
Stop, Assemble, and Remove Arrays
# Stop a RAID array (unmount first)
sudo umount /data/raid
sudo mdadm --stop /dev/md0

# Manually assemble an array from its member disks
sudo mdadm --assemble /dev/md0 /dev/sdb /dev/sdc

# Auto-assemble all arrays from config
sudo mdadm --assemble --scan

# Completely destroy an array (DESTRUCTIVE)
sudo umount /data/raid
sudo mdadm --stop /dev/md0
sudo mdadm --zero-superblock /dev/sdb
sudo mdadm --zero-superblock /dev/sdc
# Now disks are clean — no RAID metadata remains
⚠️ --zero-superblock is permanent. This wipes the RAID metadata from the disk — the disk is no longer a member of any array. All data on the array is lost. There is no undo.
8
RAID Monitoring and Maintenance
# Run a periodic array check (checks parity consistency)
sudo echo check > /sys/block/md0/md/sync_action

# Monitor the check progress
cat /proc/mdstat

# Enable weekly automatic checks (already set up on most distros)
cat /etc/cron.d/mdadm        # Debian/Ubuntu
systemctl status mdmonitor   # RHEL/CentOS

# Start mdadm monitor daemon (alerts on failures)
sudo mdadm --monitor --scan --daemonize --mailaddr=admin@example.com

# Check SMART status of member disks
sudo smartctl -a /dev/sdb | grep -E "Health|Reallocated|Pending"
sudo smartctl -a /dev/sdc | grep -E "Health|Reallocated|Pending"

# Full health check script
for dev in /dev/sd{b,c,d,e}; do
    echo "=== $dev ==="
    sudo smartctl -H "$dev" | grep "overall-health"
done
💡 Run array checks monthly. A RAID check verifies parity consistency across all disks — it catches silent data corruption before it becomes a problem. RAID 5/6 arrays that are never checked can have corrupt parity that only reveals itself during a rebuild — exactly when you need it most.

Quick Reference

RAID Level Comparison

LevelMin DisksUsable CapacityCan LoseBest For
RAID 02100% of all0 disksScratch/temp — maximum speed, no redundancy
RAID 1250%N-1 disksOS/boot drives, small critical data
RAID 53(N-1)/N1 diskGeneral purpose — good balance
RAID 64(N-2)/N2 disksLarge arrays, long rebuild times
RAID 10450%1 per pairDatabases, high I/O workloads

mdadm Command Reference

CommandWhat it does
mdadm --create /dev/mdN --level=N --raid-devices=N /dev/sd...Create new array
mdadm --detail /dev/mdNDetailed array status
mdadm --detail --scanStatus of all arrays
cat /proc/mdstatQuick status and sync progress
mdadm /dev/mdN --fail /dev/sdXMark disk failed (testing)
mdadm /dev/mdN --remove /dev/sdXRemove failed disk
mdadm /dev/mdN --add /dev/sdXAdd disk (replacement or spare)
mdadm --grow /dev/mdN --raid-devices=NGrow array with new disk
mdadm --stop /dev/mdNStop array
mdadm --assemble --scanReassemble all arrays from config
mdadm --zero-superblock /dev/sdXWipe RAID metadata (destructive)
mdadm --detail --scan | tee -a /etc/mdadm.confSave config for persistence
echo check > /sys/block/mdN/md/sync_actionRun parity check

RAID vs LVM — Working Together

LayerRoleExample
Hardware/mdadm RAIDRedundancy — protects against disk failure4 disks → /dev/md0 (RAID 10)
LVM on top of RAIDFlexibility — resize, snapshot, multiple LVs/dev/md0 → PV → VG → LVs
FilesystemData organizationXFS or ext4 on each LV

← Back to Storage Index ↑ Back to EXPANDED