What is Software RAID?
Software RAID uses the Linux kernel's md (multiple devices) driver to combine multiple disks into a single logical volume, providing redundancy and/or performance improvements without a dedicated hardware RAID controller. This is particularly useful on Breezes and dedicated servers where hardware RAID is unavailable.
RAID Level Overview
- RAID 0 — Striping. Combines disks for speed. No redundancy. If one disk fails, all data is lost.
- RAID 1 — Mirroring. Exact copy across two disks. Can survive one disk failure.
- RAID 5 — Striping with distributed parity. Requires 3+ disks. Survives one disk failure.
- RAID 10 — Mirrored stripes. Requires 4+ disks. Excellent performance and redundancy.
Installation
sudo apt update
sudo apt install -y mdadm
Creating a RAID 1 Array
This example mirrors two disks (/dev/sdb and /dev/sdc):
# Wipe existing partition tables
sudo wipefs -a /dev/sdb /dev/sdc
# Create the RAID 1 array
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
# Verify creation
cat /proc/mdstat
# Watch the sync progress
watch cat /proc/mdstat
Format and Mount
# Create filesystem
sudo mkfs.ext4 /dev/md0
# Create mount point and mount
sudo mkdir -p /mnt/raid1
sudo mount /dev/md0 /mnt/raid1
# Add to fstab for persistence
echo "/dev/md0 /mnt/raid1 ext4 defaults 0 2" | sudo tee -a /etc/fstab
Save RAID Configuration
# Save the config so the array is assembled at boot
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u
Monitoring and Management
# Check array status
sudo mdadm --detail /dev/md0
# Check all arrays
cat /proc/mdstat
# Enable email alerts
sudo mdadm --monitor --mail=admin@example.com --delay=300 /dev/md0 --daemonise
Handling Disk Failures
# Mark a disk as failed (for testing)
sudo mdadm --manage /dev/md0 --fail /dev/sdc
# Remove the failed disk
sudo mdadm --manage /dev/md0 --remove /dev/sdc
# Add a replacement disk
sudo mdadm --manage /dev/md0 --add /dev/sdd
# Monitor rebuild progress
watch cat /proc/mdstat
Creating RAID 5
# Requires 3+ disks
sudo mdadm --create /dev/md1 --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
# With a hot spare
sudo mdadm --create /dev/md1 --level=5 --raid-devices=3 --spare-devices=1 \
/dev/sdb /dev/sdc /dev/sdd /dev/sde
Best Practices
- Always save the mdadm config and update initramfs after creating arrays
- Monitor arrays with
mdadm --monitoror integrate with your monitoring stack - RAID is not a backup — always maintain separate backups
- Test failover scenarios before relying on RAID in production